Search in sources :

Example 1 with EmbeddedScriptingService

use of com.adaptris.core.services.EmbeddedScriptingService in project interlok by adaptris.

the class PollingTriggerTest method testTrigger_TemplateFails.

@Test
public void testTrigger_TemplateFails() throws Exception {
    // setContent must have a encoding...
    String script = "message.setContent('" + PAYLOAD + "')";
    Trigger trigger = new Trigger();
    MockMessageProducer mockProducer = new MockMessageProducer();
    Channel c = createChannel(new PollingTrigger(trigger, new DynamicPollingTemplate(new EmbeddedScriptingService().withScript("nashorn", script))), mockProducer);
    try {
        BaseCase.start(c);
        trigger.fire();
        assertEquals(0, mockProducer.getMessages().size());
    } finally {
        BaseCase.stop(c);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) EmbeddedScriptingService(com.adaptris.core.services.EmbeddedScriptingService) Test(org.junit.Test)

Example 2 with EmbeddedScriptingService

use of com.adaptris.core.services.EmbeddedScriptingService in project interlok by adaptris.

the class PollingTriggerTest method testTriggerWithDynamicTemplate.

@Test
public void testTriggerWithDynamicTemplate() throws Exception {
    Trigger trigger = new Trigger();
    String script = "message.setContent('" + PAYLOAD + "', 'UTF-8')";
    MockMessageProducer mockProducer = new MockMessageProducer();
    Channel c = createChannel(new PollingTrigger(trigger, new DynamicPollingTemplate(new EmbeddedScriptingService().withScript("nashorn", script))), mockProducer);
    try {
        BaseCase.start(c);
        trigger.fire();
        AdaptrisMessage msg = mockProducer.getMessages().get(0);
        assertEquals(PAYLOAD, msg.getContent());
    } finally {
        BaseCase.stop(c);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) EmbeddedScriptingService(com.adaptris.core.services.EmbeddedScriptingService) Test(org.junit.Test)

Example 3 with EmbeddedScriptingService

use of com.adaptris.core.services.EmbeddedScriptingService in project interlok by adaptris.

the class NashornCheckerTest method createAdapterConfig.

private Adapter createAdapterConfig(boolean hasNashorn) {
    Adapter result = new Adapter();
    result.setUniqueId(GUID.safeUUID());
    result.getSharedComponents().addService(new EmbeddedScriptingService(GUID.safeUUID()).withScript("jruby", ""));
    result.getSharedComponents().addService(new EmbeddedScriptingService(GUID.safeUUID()).withScript("jruby", ""));
    result.getSharedComponents().addService(new EmbeddedScriptingService(GUID.safeUUID()).withScript("jruby", ""));
    if (hasNashorn) {
        result.getSharedComponents().addService(new EmbeddedScriptingService("explicit_nashorn").withScript("nashorn", ""));
    }
    return result;
}
Also used : EmbeddedScriptingService(com.adaptris.core.services.EmbeddedScriptingService) Adapter(com.adaptris.core.Adapter)

Aggregations

EmbeddedScriptingService (com.adaptris.core.services.EmbeddedScriptingService)3 MockChannel (com.adaptris.core.stubs.MockChannel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 Test (org.junit.Test)2 Adapter (com.adaptris.core.Adapter)1