Search in sources :

Example 56 with Navajo

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);
}
Also used : NavajoClient(com.dexels.navajo.client.NavajoClient) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 57 with Navajo

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);
    }
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 58 with Navajo

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);
    }
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 59 with Navajo

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);
}
Also used : Header(com.dexels.navajo.document.Header) Access(com.dexels.navajo.script.api.Access) NavajoResponseHandler(com.dexels.navajo.client.NavajoResponseHandler) Navajo(com.dexels.navajo.document.Navajo)

Example 60 with Navajo

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();
}
Also used : NavajoReactiveJettyClient(com.dexels.navajo.client.stream.jetty.NavajoReactiveJettyClient) JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) Logger(org.slf4j.Logger) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StringWriter(java.io.StringWriter) LoggerFactory(org.slf4j.LoggerFactory) NavajoReactiveJettyClient(com.dexels.navajo.client.stream.jetty.NavajoReactiveJettyClient) Test(org.junit.Test) StandardCharsets(java.nio.charset.StandardCharsets) HttpMethod(org.eclipse.jetty.http.HttpMethod) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Optional(java.util.Optional) XML(com.dexels.navajo.document.stream.xml.XML) JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) StreamDocument(com.dexels.navajo.document.stream.StreamDocument) TestConfig(com.dexels.navajo.runtime.config.TestConfig) Assert(org.junit.Assert) Navajo(com.dexels.navajo.document.Navajo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent) Test(org.junit.Test)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13