Search in sources :

Example 11 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class MetadataDocumentCopierTest method testSplit_IOException.

@Test
public void testSplit_IOException() throws Exception {
    final int expectedSplitCount = 10;
    AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(LINE);
    msg.addMetadata(METADATA_KEY, String.valueOf(expectedSplitCount));
    MetadataDocumentCopier splitter = new MetadataDocumentCopier(METADATA_KEY, METADATA_KEY_INDEX);
    try (CloseableIterable<AdaptrisMessage> result = splitter.splitMessage(msg)) {
        for (AdaptrisMessage m : result) {
            fail();
        }
    } catch (RuntimeException expected) {
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 12 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class XpathSplitterTest method testSplitThrowsException.

@Test
public void testSplitThrowsException() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_MESSAGE);
    msg.setContent(XML_MESSAGE, msg.getContentEncoding());
    XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8);
    splitter.setMessageFactory(new DefectiveMessageFactory());
    try (CloseableIterable<AdaptrisMessage> closeable = splitter.splitMessage(msg)) {
        int count = 0;
        for (AdaptrisMessage m : closeable) {
            count++;
        }
    } catch (RuntimeException expected) {
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test) XpathMetadataServiceTest(com.adaptris.core.services.metadata.XpathMetadataServiceTest)

Example 13 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class BasicSchemaValidationTest method testBasicSchemaValidator_Exception.

@Test(expected = ServiceException.class)
public void testBasicSchemaValidator_Exception() throws Exception {
    String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
    BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl).withSchemaCache(new CacheConnection().withCacheInstance(new ExpiringMapCache()));
    XmlValidationService service = new XmlValidationService(validator);
    try {
        LifecycleHelper.initAndStart(service);
        AdaptrisMessage m1 = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
        service.doService(m1);
    } finally {
        LifecycleHelper.stopAndClose(service);
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) XmlValidationService(com.adaptris.core.transform.XmlValidationService) CacheConnection(com.adaptris.core.services.cache.CacheConnection) Test(org.junit.Test)

Example 14 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class RequestReplyProducerBaseTest method testCopyReplyContents_Failure.

@Test(expected = ProduceException.class)
public void testCopyReplyContents_Failure() throws Exception {
    AdaptrisMessage reply = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
    AdaptrisMessage original = new DefaultMessageFactory().newMessage();
    copyReplyContents(reply, original);
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) Test(org.junit.Test)

Example 15 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class AggregatingFtpConsumeServiceTest method testService_SingleFile_Failure.

@Test
public void testService_SingleFile_Failure() throws Exception {
    int count = 1;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener();
    FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
    try {
        // should be ftp://localhost/home/user/work/file0 which is created when you
        // create the filesystem.
        String ftpConsumeUrl = "ftp://localhost" + DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + 0;
        FtpConnection conn = createConnection(server);
        AggregatingFtpConsumer consumer = createConsumer(ftpConsumeUrl, null, new ReplaceWithFirstMessage());
        AggregatingFtpConsumeService service = new AggregatingFtpConsumeService(conn, consumer);
        AdaptrisMessage msg = new DefectiveMessageFactory().newMessage();
        try {
            execute(service, msg);
            fail();
        } catch (ServiceException expected) {
        }
    } finally {
        server.stop();
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) ReplaceWithFirstMessage(com.adaptris.core.services.aggregator.ReplaceWithFirstMessage) Test(org.junit.Test)

Aggregations

DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)26 Test (org.junit.Test)26 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)24 ServiceException (com.adaptris.core.ServiceException)13 CoreException (com.adaptris.core.CoreException)4 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)2 Cache (com.adaptris.core.cache.Cache)2 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 InsertNode (com.adaptris.util.text.xml.InsertNode)2 JMSException (javax.jms.JMSException)2 Session (javax.jms.Session)2 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)2 Channel (com.adaptris.core.Channel)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 IgnoreOriginalMimeAggregator (com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator)1 ReplaceWithFirstMessage (com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)1 CacheConnection (com.adaptris.core.services.cache.CacheConnection)1 StringPayloadCacheTranslator (com.adaptris.core.services.cache.translators.StringPayloadCacheTranslator)1 XpathMetadataServiceTest (com.adaptris.core.services.metadata.XpathMetadataServiceTest)1