Search in sources :

Example 46 with StandaloneConsumer

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

the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.

@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 47 with StandaloneConsumer

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

the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.

@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
    SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
    kvps.add(new KeyValuePair("UseCompression", "true"));
    sfc.setProperties(kvps);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    sendVendorImp.setExtraFactoryConfiguration(sfc);
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) SimpleFactoryConfiguration(com.adaptris.core.jms.jndi.SimpleFactoryConfiguration) PtpProducer(com.adaptris.core.jms.PtpProducer) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 48 with StandaloneConsumer

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

the class JmxNotificationConsumerTest method testConsumer.

@Test
public void testConsumer() throws Exception {
    MBeanServer mbeanServer = JmxHelper.findMBeanServer();
    String myObjectName = "com.adaptris:type=Junit,id=" + getName();
    StubNotificationBroadcaster broadcast = new StubNotificationBroadcaster();
    MockMessageListener listener = new MockMessageListener();
    JmxNotificationConsumer consumer = new JmxNotificationConsumer();
    consumer.setObjectName(myObjectName);
    StandaloneConsumer sc = wrap(new JmxConnection(), consumer, listener);
    try {
        mbeanServer.registerMBean(broadcast, ObjectName.getInstance(myObjectName));
        // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
        LifecycleHelper.prepare(sc);
        start(sc);
        broadcast.sendNotification(getName(), new Object());
        waitForMessages(listener, 1);
        assertEquals(1, listener.messageCount());
        assertNotNull(listener.getMessages().get(0).getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
    } finally {
        stop(sc);
    }
}
Also used : MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MBeanServer(javax.management.MBeanServer) Test(org.junit.Test)

Example 49 with StandaloneConsumer

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

the class JmxNotificationConsumerTest method wrap.

private StandaloneConsumer wrap(AdaptrisConnection conn, AdaptrisMessageConsumer consumer, AdaptrisMessageListener listener) throws Exception {
    StandaloneConsumer sc = new StandaloneConsumer(conn, consumer);
    sc.registerAdaptrisMessageListener(listener);
    sc.prepare();
    return sc;
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 50 with StandaloneConsumer

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

the class FsMessageConsumerTest method testConsumeImmediateEventPoller.

@Test
public void testConsumeImmediateEventPoller() throws Exception {
    String subDir = new GuidGenerator().safeUUID();
    MockMessageListener stub = new MockMessageListener(10);
    FsConsumer fs = createConsumer(subDir);
    fs.setReacquireLockBetweenMessages(true);
    fs.setPoller(new FsImmediateEventPoller());
    fs.setQuietInterval(new TimeInterval(500L, "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);
        LifecycleHelper.init(sc);
        createFiles(baseDir, ".xml", count);
        Thread.sleep(1000);
        LifecycleHelper.start(sc);
        waitForMessages(stub, count);
        assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
    } finally {
        stop(sc);
        FileUtils.deleteQuietly(new File(parentDir, subDir));
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) TimeInterval(com.adaptris.util.TimeInterval) LargeFsConsumer(com.adaptris.core.lms.LargeFsConsumer) GuidGenerator(com.adaptris.util.GuidGenerator) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Aggregations

StandaloneConsumer (com.adaptris.core.StandaloneConsumer)188 Test (org.junit.Test)164 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)160 StandaloneProducer (com.adaptris.core.StandaloneProducer)91 TimeInterval (com.adaptris.util.TimeInterval)49 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)37 File (java.io.File)31 GuidGenerator (com.adaptris.util.GuidGenerator)30 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)30 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 FilenameFilter (java.io.FilenameFilter)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 PtpProducer (com.adaptris.core.jms.PtpProducer)23 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)22 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)17 CoreException (com.adaptris.core.CoreException)16 PasProducer (com.adaptris.core.jms.PasProducer)15 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 PasConsumer (com.adaptris.core.jms.PasConsumer)14