mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 16:28:48 +10:00
[강운덕] [LUCYSUS-1744] oracle jdbc url parser 1차로 thin url 파서 개발, rac의 경우 여러 address의 파싱이 정상적이지 않음. 추가 보완 필요.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1687 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
package com.profiler.modifier.db.util;
|
||||
|
||||
import com.profiler.modifier.db.DatabaseInfo;
|
||||
import com.profiler.modifier.db.JDBCUrlParser;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.profiler.common.ServiceType;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JDBCUrlParserTest {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(JDBCUrlParserTest.class);
|
||||
private com.profiler.modifier.db.JDBCUrlParser JDBCUrlParser = new JDBCUrlParser();
|
||||
|
||||
@Test
|
||||
public void testURIParse() throws Exception {
|
||||
|
||||
URI uri = URI.create("jdbc:mysql:replication://10.98.133.22:3306/test_lucy_db");
|
||||
logger.debug(uri.toString());
|
||||
logger.debug(uri.getScheme());
|
||||
|
||||
// URI로 파싱하는건 제한적임 한계가 있음.
|
||||
try {
|
||||
URI oracleRac = URI.create("jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)" +
|
||||
"(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.4) (PORT=1521))" +
|
||||
"(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.5) (PORT=1521))" +
|
||||
"(CONNECT_DATA=(SERVICE_NAME=service)))");
|
||||
|
||||
logger.debug(oracleRac.toString());
|
||||
logger.debug(oracleRac.getScheme());
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mysqlParse1() {
|
||||
|
||||
DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://ip_address:3306/database_name?useUnicode=yes&characterEncoding=UTF-8");
|
||||
Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL);
|
||||
Assert.assertEquals(dbInfo.getHost().get(0), ("ip_address:3306"));
|
||||
Assert.assertEquals(dbInfo.getDatabaseId(), "database_name");
|
||||
Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://ip_address:3306/database_name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mysqlParse2() {
|
||||
|
||||
DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://10.98.133.22:3306/test_lucy_db");
|
||||
Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL);
|
||||
Assert.assertEquals(dbInfo.getHost().get(0), "10.98.133.22:3306");
|
||||
|
||||
Assert.assertEquals(dbInfo.getDatabaseId(), "test_lucy_db");
|
||||
Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://10.98.133.22:3306/test_lucy_db");
|
||||
logger.info(dbInfo.toString());
|
||||
logger.info(dbInfo.getMultipleHost());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mysqlParse3() {
|
||||
DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://61.74.71.31/log?useUnicode=yes&characterEncoding=UTF-8");
|
||||
Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL);
|
||||
Assert.assertEquals(dbInfo.getHost().get(0), "61.74.71.31");
|
||||
Assert.assertEquals(dbInfo.getDatabaseId(), "log");
|
||||
Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://61.74.71.31/log");
|
||||
logger.info(dbInfo.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user