use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestClient method testClient.
@Test(timeout = 10000)
public void testClient() throws ClientException {
NavajoClient cl = new ApacheNavajoClientImpl();
cl.setAllowCompression(true);
cl.setForceGzip(true);
cl.useBasicAuthentication(true);
cl.setServerUrls(new String[] { TestConfig.NAVAJO_TEST_SERVER.getValue() });
cl.setUsername(TestConfig.NAVAJO_TEST_USER.getValue());
cl.setPassword(TestConfig.NAVAJO_TEST_PASS.getValue());
Navajo nc = NavajoFactory.getInstance().createNavajo();
Navajo result = cl.doSimpleSend(nc, "single");
result.write(System.err);
Assert.assertTrue(result.getErrorDescription() == null);
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class NavajoScriptingTests method testNavajoMap.
@Test
@Ignore
public void testNavajoMap() throws Exception {
Navajo result = myClient.doSimpleSend(input, "tests/InitNavajoMapTest");
List<Message> allMessages = result.getAllMessages();
for (int i = 0; i < allMessages.size(); i++) {
Message m = allMessages.get(i);
checkBooleans(m);
}
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class NavajoScriptingTests method testPropertyTypes.
@Test
@Ignore
public void testPropertyTypes() throws Exception {
myClient.doSimpleSend(input, "tests/ProcessTestProperties");
Navajo result = myClient.doSimpleSend(input, "tests/ProcessTestFields");
List<Message> allMessages = result.getAllMessages();
for (int i = 0; i < allMessages.size(); i++) {
Message m = allMessages.get(i);
checkBooleans(m);
}
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class AsyncClientImpl method callService.
// Only used from Rhino
@Override
public void callService(Access inputAccess, Navajo input, String service, TmlRunnable onSuccess, TmlRunnable onFail, NavajoResponseCallback navajoResponseCallback) throws IOException {
final Access currentAccess = inputAccess.cloneWithoutNavajos();
if (input == null) {
input = NavajoFactory.getInstance().createNavajo();
}
currentAccess.setInDoc(input);
Header header = input.getHeader();
if (header == null) {
header = NavajoFactory.getInstance().createHeader(input, service, currentAccess.rpcUser, currentAccess.rpcUser, -1);
input.addHeader(header);
}
header.setRPCName(service);
header.setRPCUser(currentAccess.rpcUser);
header.setRPCPassword(currentAccess.rpcPwd);
NavajoResponseHandler nrh = new NavajoResponseHandler() {
Throwable caughtException = null;
@Override
public void onResponse(Navajo n) {
setActualCalls(getActualCalls() - 1);
currentAccess.setOutputDoc(n);
if (onSuccess != null) {
onSuccess.setResponseNavajo(n);
if (navajoResponseCallback != null) {
navajoResponseCallback.responseReceived(n);
}
setActualCalls(getActualCalls() - 1);
SchedulerRegistry.submit(onSuccess, false);
}
}
@Override
public synchronized void onFail(Throwable t) throws IOException {
caughtException = t;
logger.warn("Error: ", caughtException);
setActualCalls(getActualCalls() - 1);
try {
if (onFail != null) {
SchedulerRegistry.submit(onFail, false);
}
} finally {
setActualCalls(getActualCalls() - 1);
}
}
@Override
public synchronized Throwable getCaughtException() {
return caughtException;
}
};
setActualCalls(getActualCalls() + 1);
callService(currentAccess.getRequestUrl(), input, nrh, null);
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class ITJettyClient method testJettyCLient.
@Test
public void testJettyCLient() throws Exception {
JettyClient jc = new JettyClient();
Flowable<byte[]> in = Flowable.<NavajoStreamEvent>empty().compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password))).lift(StreamDocument.serialize());
byte[] result = jc.callWithBodyToStream(uri, req -> req.header("X-Navajo-Reactive", "true").header("X-Navajo-Service", service).header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("Accept-Encoding", null).method(HttpMethod.POST), in, "text/xml;charset=utf-8").reduce(new ByteArrayOutputStream(), (stream, b) -> {
stream.write(b);
return stream;
}).map(stream -> stream.toByteArray()).blockingGet();
logger.info("result: {}", new String(result));
Assert.assertTrue(result.length > 5000);
jc.close();
}
Aggregations