use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class LoginDatabaseTaskTest method testCancel.
public void testCancel() {
ServerInfo serverInfo = new ServerInfo();
DatabaseInfo dbInfo = new DatabaseInfo("dbname", serverInfo);
ServerUserInfo serverUserInfo = new ServerUserInfo();
List<DatabaseInfo> dbInfoList = new ArrayList<DatabaseInfo>();
dbInfoList.add(dbInfo);
serverUserInfo.setDatabaseInfoList(dbInfoList);
serverInfo.setLoginedUserInfo(serverUserInfo);
LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
task.setDbName("dbname");
task.cancel();
assertFalse(serverInfo.getLoginedUserInfo().getDatabaseInfo("dbname").isLogined());
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class LoginDatabaseTaskTest method testSetCMUser.
public void testSetCMUser() {
ServerInfo serverInfo = new ServerInfo();
serverInfo.setServerVersion("8.2.0");
LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
task.setCMUser("user");
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class TestRawScript method connect.
public static void connect() {
serverInfo = new ServerInfo();
serverInfo.setHostAddress(SERVER_IP);
serverInfo.setHostMonPort(SERVER_AUTH_PORT);
serverInfo.setHostJSPort(SERVER_TASK_PORT);
serverInfo.setUserName(MAN_USERID);
serverInfo.setUserPassword(MAN_PASSWD);
MonitoringTask monTask = new MonitoringTask(serverInfo);
serverInfo = monTask.connectServer(CLIENT_VERSION, 1000);
if (monTask.getErrorMsg() != null) {
System.exit(-1);
}
ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
ServerManager.getInstance().setConnected(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), true);
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTaskTest method testSend.
public void testSend() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/mondashboard/task/test.message/GetHeartbeatNodeInfoTask_send");
String msg = Tool.getFileContent(filepath);
//replace "token" field with the latest value
msg = msg.replaceFirst("token:.*\n", "token:" + token + "\n");
//composite message
GetHeartbeatNodeInfoTask task = new GetHeartbeatNodeInfoTask(serverInfo);
task.setAllDb(false);
List<String> dbList = new ArrayList<String>();
dbList.add("demodb");
dbList.add("tb1");
task.setDbList(dbList);
//compare
assertEquals(msg, task.getRequest());
//test special case1
ServerInfo server = new ServerInfo();
server.setConnected(true);
EnvInfo envInfo = new EnvInfo();
envInfo.setServerVersion("CUBRID 2008 R2.0(8.2.0.1150)");
envInfo.setOsInfo("NT");
server.setEnvInfo(envInfo);
task = new GetHeartbeatNodeInfoTask(server);
task.execute();
//test special case2
envInfo.setServerVersion("CUBRID 2008 R2.0(8.3.1.1150)");
task.execute();
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class JDBCConnectionManager method testShardBroker.
public static boolean testShardBroker(DatabaseInfo dbInfo, int shardId) {
String dbName = dbInfo.getDbName();
ServerInfo serverInfo = dbInfo.getServerInfo();
String brokerIP = dbInfo.getBrokerIP();
DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
String url = "jdbc:cubrid:" + brokerIP + ":" + dbInfo.getBrokerPort() + ":" + dbName + ":::";
Driver cubridDriver = CubridClassLoaderPool.getCubridDriver(serverInfo.getJdbcDriverVersion());
if (cubridDriver == null) {
LOGGER.error("The cubridDriver is a null.");
return false;
}
Properties props = new Properties();
props.put("user", userInfo.getName());
props.put("password", userInfo.getNoEncryptPassword() == null ? "" : userInfo.getNoEncryptPassword());
Connection conn = null;
Statement stmt = null;
try {
conn = cubridDriver.connect(url, props);
conn.setAutoCommit(true);
stmt = conn.createStatement();
stmt.executeQuery("/*+ shard_id(" + shardId + ") */ SELECT * FROM db_root");
} catch (Exception e) {
LOGGER.error("", e);
return false;
} finally {
QueryUtil.freeQuery(conn, stmt);
}
return true;
}
Aggregations