Package org.mule.tck.functional

Examples of org.mule.tck.functional.FunctionalTestComponent


        doTestInvalidMessageNack(serviceName);
    }

    private void doTestValidMessage(String serviceName) throws MuleException, Exception, InterruptedException
    {
        final FunctionalTestComponent ftc = getFunctionalTestComponent("test-service");
        final Latch latch = new Latch();
        ftc.setEventCallback(new EventCallback()
        {
            @Override
            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                latch.countDown();
            }
        });

        final Object validPayload = doTestValidMessageAck(serviceName);

        latch.await(getTestTimeoutSecs(), TimeUnit.SECONDS);
        assertEquals(1, ftc.getReceivedMessagesCount());
        assertEquals(validPayload, ftc.getLastReceivedMessage());
        ftc.initialise();
    }
View Full Code Here


    @Override
    protected void doSetUp() throws Exception
    {
        super.doSetUp();

        FunctionalTestComponent ftc = (FunctionalTestComponent) getComponent("SINGLE");
        ftc.setEventCallback(this);

        ftc = (FunctionalTestComponent) getComponent("CHAINED");
        ftc.setEventCallback(this);
    }
View Full Code Here

        String attachmentName = context.getFlowConstruct().getName();
        DataHandler dataHandler = new DataHandler(new PlainTextDataSource("text/plain", ATTACHMENT_CONTENT));
        message.addOutboundAttachment(attachmentName, dataHandler);

        // return the list of attachment names
        FunctionalTestComponent fc = (FunctionalTestComponent) component;
        fc.setReturnData(message.getOutboundAttachmentNames().toString());
    }
View Full Code Here

        doTestMathsService("vm://address-dynamic-endpoint-bridge.in", properties);
    }

    private void doJmsBasedTest(final String jmsDestinationUri, final String ftcName) throws Exception, MuleException, InterruptedException
    {
        final FunctionalTestComponent ftc = getFunctionalTestComponent(ftcName);
        final Latch latch = new Latch();
        ftc.setEventCallback(new EventCallback()
        {
            @Override
            public void eventReceived(final MuleEventContext context, final Object component) throws Exception
            {
                latch.countDown();
            }
        });

        final String payload = RandomStringUtils.randomAlphabetic(10);
        muleClient.dispatch(jmsDestinationUri, payload, null);
        latch.await(getTestTimeoutSecs(), TimeUnit.SECONDS);
        assertEquals(1, ftc.getReceivedMessagesCount());
        assertEquals(payload, byteArrayOrStringtoString(ftc.getReceivedMessage(1)));
    }
View Full Code Here

    @Test
    public void testReplyToIsHonoredInFlowUsingAsyncBlock() throws Exception
    {
        org.mule.api.client.LocalMuleClient client = muleContext.getClient();
        final org.mule.util.concurrent.Latch flowExecutedLatch = new org.mule.util.concurrent.Latch();
        FunctionalTestComponent ftc = getFunctionalTestComponent("replierService");
        ftc.setEventCallback(new EventCallback()
        {
            @Override
            public void eventReceived(org.mule.api.MuleEventContext context, Object component) throws Exception
            {
                flowExecutedLatch.release();
View Full Code Here

    }

    @Test
    public void testPropertiesPropagation() throws Exception
    {
        FunctionalTestComponent hop1 = getFunctionalTestComponent("hop1Service");
        FunctionalTestComponent hop2 = getFunctionalTestComponent("hop2Service");
        assertNotNull(hop1);

        final AtomicBoolean hop1made = new AtomicBoolean(false);
        EventCallback callback1 = new EventCallback()
        {
            @Override
            public void eventReceived(final MuleEventContext context, final Object component) throws Exception
            {
                assertTrue(hop1made.compareAndSet(false, true));
                FunctionalTestComponent ftc = (FunctionalTestComponent) component;
                ftc.setReturnData("Hop1 ACK");
            }
        };

        final AtomicBoolean hop2made = new AtomicBoolean(false);
        EventCallback callback2 = new EventCallback()
        {
            @Override
            public void eventReceived(final MuleEventContext context, final Object component) throws Exception
            {
                MuleMessage msg = context.getMessage();
                assertTrue(hop2made.compareAndSet(false, true));
                // this is a service callback, props are on the inbound
                assertEquals("Property not propagated from the first hop.", "hop1", msg.getInboundProperty("TICKET"));
                FunctionalTestComponent ftc = (FunctionalTestComponent) component;
                ftc.setReturnData(msg.getPayload() + " Hop2 ACK");
            }
        };

        hop1.setEventCallback(callback1);
        hop2.setEventCallback(callback2);
View Full Code Here

    @Test
    public void testRoutePayloadBeforeException() throws Exception
    {
        final Latch messageProcessedLatch = new Latch();
        FunctionalTestComponent ftc = getFunctionalTestComponent("LastMessageStateRouting");
        ftc.setEventCallback(new EventCallback()
        {
            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                messageProcessedLatch.release();
                throw new RuntimeException();
View Full Code Here

    @Test
    public void testRouteOriginalPayload() throws Exception
    {
        final Latch messageProcessedLatch = new Latch();
        FunctionalTestComponent ftc = getFunctionalTestComponent("OriginalMessageRouting");
        ftc.setEventCallback(new EventCallback()
        {
            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                messageProcessedLatch.release();
                throw new RuntimeException();
View Full Code Here

    @Test
    public void testRouteByExceptionType() throws Exception
    {
        final CountDownLatch messageProcessedLatch = new CountDownLatch(3);
        FunctionalTestComponent ftc = getFunctionalTestComponent("RouteByExceptionType");
        ftc.setEventCallback(new EventCallback()
        {
            public void eventReceived(MuleEventContext context, Object component) throws Exception
            {
                messageProcessedLatch.countDown();
                throw new RuntimeException();
View Full Code Here

    public void testComponent1Config() throws Exception
    {
        Object object = getComponent("testService1");
        assertNotNull(object);
        assertTrue(object instanceof FunctionalTestComponent);
        FunctionalTestComponent ftc = (FunctionalTestComponent) object;

        assertFalse(ftc.isEnableMessageHistory());
        assertFalse(ftc.isEnableNotifications());
        assertNull(ftc.getAppendString());
        assertEquals("Foo Bar Car Jar", ftc.getReturnData());
        assertNotNull(ftc.getEventCallback());
        assertTrue(ftc.getEventCallback() instanceof CounterCallback);
    }
View Full Code Here

TOP

Related Classes of org.mule.tck.functional.FunctionalTestComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.