use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetReplicatedTablesTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
//case 1
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/GetReplicatedTables_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetReplicatedTablesTask task = new GetReplicatedTablesTask(serverInfo);
task.setResponse(node);
String[] tables = task.getReplicatedTables();
assertTrue(tables.length == 2);
boolean isReplAll = task.isReplicateAll();
assertFalse(isReplAll);
//case 2
msg = msg.replaceFirst("all_repl:Y", "all_repl:N");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.isReplicateAll();
msg = msg.replaceFirst("all_repl:N", "");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.isReplicateAll();
//case 3
msg = msg.replaceFirst("open:repl_group_tablelist", "open:aa");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.getReplicatedTables();
msg = msg.replaceFirst("open:aa", "");
msg = msg.replaceFirst("close:repl_group_tablelist", "");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.getReplicatedTables();
//exception case1
task.setResponse(null);
tables = task.getReplicatedTables();
assertTrue(tables == null);
isReplAll = task.isReplicateAll();
assertFalse(isReplAll);
//exception case2
task.setResponse(node);
task.setErrorMsg("hasError");
tables = task.getReplicatedTables();
assertTrue(tables == null);
isReplAll = task.isReplicateAll();
assertFalse(isReplAll);
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class TestTask method main.
/**
* TODO: how to write comments What and why the member function does what it
* does What a member function must be passed as parameters What a member
* function re turns Known bugs Any exceptions that a member function throws
* Visibility decisions How a member function changes the object Include a
* history of any code changes Examples of how to invoke th e member
* function if appropriate Applicable preconditions and postconditions
* Document all concurrency
*
* @param args
*/
public static void main(String[] args) {
ClientSocket hostsocket = new ClientSocket("localhost", 8001, "admin");
String message = "id:admin\npassword:1111\n" + "clientver:8.1.4\n\n";
// send login message
hostsocket.sendRequest(message);
// get the latest token
TreeNode node = hostsocket.getResponse();
String token = node.getValue("token");
System.out.println(token);
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class AddTriggerTaskTest method testReceive.
public void testReceive() throws Exception {
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/trigger/task/test.message/addtrigger_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
task.setResponse(node);
boolean success = task.isSuccess();
assertTrue(success);
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/trigger/task/test.message/addtrigger_receive_error");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
boolean failure = task.isSuccess();
assertFalse(failure);
//assertEquals(" invalid use of keyword 'test', expecting { name }.",
// task.getErrorMsg());
task.setCondition("");
task.setAction(Trigger.TriggerAction.OTHER_STATEMENT, "test");
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class AlterTriggerTaskTest method testReceive.
public void testReceive() throws Exception {
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/trigger/task/test.message/altertrigger_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
task.setResponse(node);
boolean success = task.isSuccess();
assertTrue(success);
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetAnalyzeCasLogTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/logs/task/test.message/GetAnalyzeCasLog_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetAnalyzeCasLogTask task = new GetAnalyzeCasLogTask(serverInfo);
task.setResponse(node);
task.getAnalyzeCasLogResultList();
//compare
assertEquals("success", node.getValue("status"));
//case 2
msg = msg.replaceFirst("result:start", "");
msg = msg.replaceFirst("result:end", "");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.getAnalyzeCasLogResultList();
//case 3
msg = msg.replaceFirst("resultlist:start", "resultlist:start1");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.getAnalyzeCasLogResultList();
//case 4
msg = msg.replaceFirst("resultlist:start1", "");
msg = msg.replaceFirst("resultlist:end", "");
node = MessageUtil.parseResponse(msg);
task.setResponse(node);
task.getAnalyzeCasLogResultList();
//case 5
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/logs/task/test.message/GetAnalyzeCasLog_receive2");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetAnalyzeCasLogTask task2 = new GetAnalyzeCasLogTask(serverInfo);
task2.setResponse(node);
task2.getAnalyzeCasLogResultList();
//exception case1
task.setResponse(null);
task.getAnalyzeCasLogResultList();
//exception case2
task.setResponse(node);
task.setErrorMsg("has error");
task.getAnalyzeCasLogResultList();
}
Aggregations