Search in sources :

Example 96 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class BlobMessageTranslatorTest method testMoveMetadataJmsMessageToAdaptrisMessage.

@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage() throws Exception {
    MessageTypeTranslatorImp trans = new BlobMessageTranslator();
    JmsConnection conn = null;
    try {
        conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
        start(conn);
        Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Message jmsMsg = createMessage(session);
        addProperties(jmsMsg);
        trans.registerSession(session);
        trans.registerMessageFactory(new DefaultMessageFactory());
        start(trans);
        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertMetadata(msg);
    } finally {
        stop(trans);
        stop(conn);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) JmsConnection(com.adaptris.core.jms.JmsConnection) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.ActiveMQSession) Test(org.junit.Test)

Example 97 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class XmlRuleValidatorTest method testListContentValidation_DataNotInList.

@Test
public void testListContentValidation_DataNotInList() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.addValidationStage(new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_DEMETER, new SimpleListContentValidation(CHILDREN_OF_HERA)));
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
        fail("RuleValidationService success when expecting exception");
    } catch (ServiceException e) {
        // expected
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 98 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class LargeFsConsumerTest method testConsumeWithAlternateFactory.

@Test
public void testConsumeWithAlternateFactory() throws Exception {
    String subDir = GUID.safeUUID();
    MockMessageListener stub = new MockMessageListener(10);
    FsConsumer fs = createConsumer(subDir);
    fs.setResetWipFiles(false);
    fs.setMessageFactory(new DefaultMessageFactory());
    fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
    StandaloneConsumer sc = new StandaloneConsumer(fs);
    sc.registerAdaptrisMessageListener(stub);
    int count = 10;
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
    try {
        File baseDir = new File(parentDir, subDir);
        baseDir.mkdirs();
        super.createFiles(baseDir, ".xml", count);
        start(sc);
        waitForMessages(stub, count);
        assertEquals(count, stub.getMessages().size());
        super.assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
        assertDefaultMessageType(stub.getMessages());
    } finally {
        stop(sc);
        FileUtils.deleteQuietly(new File(parentDir, subDir));
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) FilenameFilter(java.io.FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) TimeInterval(com.adaptris.util.TimeInterval) FsConsumer(com.adaptris.core.fs.FsConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) File(java.io.File) FsMessageConsumerTest(com.adaptris.core.fs.FsMessageConsumerTest) Test(org.junit.Test)

Example 99 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class LineCountSplitterTest method testSetMessageFactory.

@Override
public void testSetMessageFactory() throws Exception {
    MessageSplitterImp splitter = createSplitterForTests();
    assertNull(splitter.getMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new StubMessageFactory());
    assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(null);
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory)

Example 100 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class SplitterCase method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    MessageSplitterImp splitter = createSplitterForTests();
    assertNull(splitter.getMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new StubMessageFactory());
    assertEquals(StubMessageFactory.class, splitter.getMessageFactory().getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(new DefaultMessageFactory());
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
    splitter.setMessageFactory(null);
    assertEquals(DefaultMessageFactory.class, splitter.selectFactory(new DefaultMessageFactory().newMessage()).getClass());
    assertEquals(StubMessageFactory.class, splitter.selectFactory(new StubMessageFactory().newMessage()).getClass());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10