scs.storeName = "global";
scs.debug = true;
scs.authScheme = AuthScheme.CHALLENGE_RESPONSE;
scs.keyStorePath = keyStoreFile.getAbsolutePath();
scs.keyStorePassword = keyStorePassword;
SyncClient client = new SyncClient(scs);
ByteArrayOutputStream out = new ByteArrayOutputStream();
client.out = new PrintStream(out);
ByteArrayOutputStream err = new ByteArrayOutputStream();
client.err = new PrintStream(err);
client.connect();
client.executeCommandLine("get \"key\"");
assertEquals("", err.toString());
assertEquals("Using remote sync service at localhost:40101\n" +
"Getting Key:\n" +
"\"key\"\n\n" +
"Not found\n",
out.toString());
out = new ByteArrayOutputStream();
err = new ByteArrayOutputStream();
client.out = new PrintStream(out);
client.err = new PrintStream(err);
client.executeCommandLine("put \"key\" {\"field1\": \"value1\", \"field2\": \"value2\"}");
assertEquals("", err.toString());
assertEquals("Putting Key:\n" +
"\"key\"\n\n" +
"Value:\n" +
"{\n" +
" \"field1\" : \"value1\",\n" +
" \"field2\" : \"value2\"\n" +
"}\n" +
"Success\n",
out.toString());
out = new ByteArrayOutputStream();
err = new ByteArrayOutputStream();
client.out = new PrintStream(out);
client.err = new PrintStream(err);
client.executeCommandLine("get \"key\"");
assertEquals("", err.toString());
assertEquals("Getting Key:\n" +
"\"key\"\n\n" +
"Value:\n" +
"{\n" +
" \"field1\" : \"value1\",\n" +
" \"field2\" : \"value2\"\n" +
"}\n",
out.toString());
out = new ByteArrayOutputStream();
err = new ByteArrayOutputStream();
client.out = new PrintStream(out);
client.err = new PrintStream(err);
client.executeCommandLine("delete \"key\"");
assertEquals("", err.toString());
assertEquals("Deleting Key:\n" +
"\"key\"\n\n" +
"Success\n",
out.toString());
out = new ByteArrayOutputStream();
err = new ByteArrayOutputStream();
client.out = new PrintStream(out);
client.err = new PrintStream(err);
client.executeCommandLine("get \"key\"");
assertEquals("", err.toString());
assertEquals("Getting Key:\n" +
"\"key\"\n\n" +
"Not found\n",
out.toString());
out = new ByteArrayOutputStream();
err = new ByteArrayOutputStream();
client.out = new PrintStream(out);
client.err = new PrintStream(err);
client.executeCommandLine("quit");
assertEquals("", err.toString());
assertEquals("",
out.toString());
client.executeCommandLine("help");
assert(!"".equals(out.toString()));
}