Package org.mule.construct

Examples of org.mule.construct.Flow


        MuleMessage message = new DefaultMuleMessage("data", muleContext);
        MuleEvent event = new DefaultMuleEvent(message, MessageExchangePattern.REQUEST_RESPONSE,
            getTestService());

        SensingNullMessageProcessor flowListener = new SensingNullMessageProcessor();
        Flow flow = new Flow("flow", muleContext);
        flow.setMessageProcessors(Collections.<MessageProcessor> singletonList(flowListener));
        flow.initialise();
        flow.start();

        Object nonSerializable = new Object();
        event.getSession().setProperty("key", "value");
        event.getSession().setProperty("key2", nonSerializable);

        flow.process(event);

        flowListener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS);
        MuleEvent processedEvent = flowListener.event;

        // Event is copied, but session isn't
        assertNotSame(processedEvent, event);
        assertEquals(processedEvent, event);
        assertSame(processedEvent.getSession(), event.getSession());

        // Session properties available before new flow are available after too
        assertEquals(2, processedEvent.getSession().getPropertyNamesAsSet().size());
        assertEquals("value", processedEvent.getSession().getProperty("key"));
        assertEquals(nonSerializable, processedEvent.getSession().getProperty("key2"));

        // Session properties set after new flow are available in message processor
        // before new flow
        processedEvent.getSession().setProperty("newKey", "newValue");
        assertEquals(3, processedEvent.getSession().getPropertyNamesAsSet().size());
        assertEquals("newValue", processedEvent.getSession().getProperty("newKey"));
        assertEquals(3, event.getSession().getPropertyNamesAsSet().size());
        assertEquals("newValue", event.getSession().getProperty("newKey"));

        flow.stop();
        flow.dispose();
    }
View Full Code Here


        super(dataSourceConfigResource, testDatabase);
    }

    protected void doResolvedMetadataTest(String flowName)
    {
        Flow flowConstruct = (Flow) muleContext.getRegistry().lookupFlowConstruct(flowName);

        List<MessageProcessor> messageProcessors = flowConstruct.getMessageProcessors();
        AbstractSingleQueryDbMessageProcessor queryMessageProcessor = (AbstractSingleQueryDbMessageProcessor) messageProcessors.get(0);
        Result<MetaData> inputMetaData = queryMessageProcessor.getInputMetaData();

        DefinedMapMetaDataModel mapDataModel = (DefinedMapMetaDataModel) inputMetaData.get().getPayload();
        assertThat(mapDataModel.getKeys().size(), equalTo(2));
View Full Code Here

    }

    @Test
    public void returnsUpdateMetadata() throws Exception
    {
        Flow flowConstruct = (Flow) muleContext.getRegistry().lookupFlowConstruct("updateMetadata");

        List<MessageProcessor> messageProcessors = flowConstruct.getMessageProcessors();
        AbstractSingleQueryDbMessageProcessor queryMessageProcessor = (AbstractSingleQueryDbMessageProcessor) messageProcessors.get(0);
        Result<MetaData> outputMetaData = queryMessageProcessor.getOutputMetaData(null);

        SimpleMetaDataModel simpleMetaDataModel = (SimpleMetaDataModel) outputMetaData.get().getPayload();
        assertThat(simpleMetaDataModel.getDataType(), equalTo(DataType.DOUBLE));
View Full Code Here

        doSelectMetadataTest("selectStreamingMetadata", ResultSetIterator.class.getName());
    }

    private void doSelectMetadataTest(String flowName, String implementationClass)
    {
        Flow flowConstruct = (Flow) muleContext.getRegistry().lookupFlowConstruct(flowName);

        List<MessageProcessor> messageProcessors = flowConstruct.getMessageProcessors();
        AbstractSingleQueryDbMessageProcessor queryMessageProcessor = (AbstractSingleQueryDbMessageProcessor) messageProcessors.get(0);
        Result<MetaData> outputMetaData = queryMessageProcessor.getOutputMetaData(null);

        DefaultListMetaDataModel listMetaDataModel = (DefaultListMetaDataModel) outputMetaData.get().getPayload();
        assertEquals(implementationClass, listMetaDataModel.getImplementationClass());
View Full Code Here

    }

    @Test
    public void splitterAndAggregatorWithPersistentStore() throws Exception
    {
        Flow flow = (Flow) getFlowConstruct("synchronousCollectionAggregatorFlow");
        List<String> inputData = new ArrayList<String>();
        int numberOfElements = 10;
        for (int i = 0; i < numberOfElements; i++)
        {
            inputData.add(String.valueOf(i));
        }
        MuleEvent responseEvent = flow.process(getTestEvent(inputData));
        assertThat(responseEvent.<List>getSessionVariable("recordsToUpdate").size(), is(numberOfElements));
    }
View Full Code Here

    }

    @Test
    public void testResetServiceNamespaceHandler() throws Exception
    {
        Flow f = (Flow) muleContext.getRegistry().lookupFlowConstruct(FLOW_NAME);
       
        Component component = (Component) f.getMessageProcessors().get(0);
       
        assertTrue(component instanceof RestServiceWrapper);
        RestServiceWrapper restServiceWrapper = (RestServiceWrapper) component;
        assertEquals(restServiceWrapper.getServiceUrl(), FLOW_URL);
        assertEquals(restServiceWrapper.getHttpMethod(), "POST");
View Full Code Here

    @Test
    public void oneWayAsyncRequestException() throws MuleException, InterruptedException
    {
        TriggerableMessageSource source = new TriggerableMessageSource();
        Flow pipeline = new Flow("test", muleContext);
        pipeline.setProcessingStrategy(new AsynchronousProcessingStrategy());
        final CountDownLatch latch = new CountDownLatch(1);
        pipeline.setMessageSource(source);
        pipeline.setExceptionListener(new DefaultMessagingExceptionStrategy());
        List<MessageProcessor> processors = new ArrayList<MessageProcessor>();
        processors.add(new MessageProcessor()
        {
            @Override
            public MuleEvent process(MuleEvent event) throws MuleException
            {
                latch.countDown();
                throw new RuntimeException("error");
            }
        });
        pipeline.setMessageProcessors(processors);
        pipeline.initialise();
        pipeline.start();

        event = new DefaultMuleEvent(new DefaultMuleMessage("request", muleContext),
            MessageExchangePattern.ONE_WAY, pipeline);

        source.trigger(event);
View Full Code Here

    }

    public static Flow getTestFlow(String name, MuleContext context, boolean initialize)
            throws Exception
    {
        final Flow flow = new Flow(name, context);
        if (initialize)
        {
            context.getRegistry().registerFlowConstruct(flow);
        }
View Full Code Here

        assertInvalidRequest("proxy12_singlePort", getRequest(SOAP_12_SCHEMA));
    }

    private void assertValidRequest(String flowName, String request) throws Exception
    {
        Flow flow = (Flow) getFlowConstruct(flowName);
        MuleEvent result = flow.process(getTestEvent(request));

        // As there is nothing else after the service, if there were no problems the same contents of the request
        // will be returned.
        assertEquals(request, result.getMessage().getPayloadAsString());
    }
View Full Code Here

        assertEquals(request, result.getMessage().getPayloadAsString());
    }

    private void assertInvalidRequest(String flowName, String request) throws Exception
    {
        Flow flow = (Flow) getFlowConstruct(flowName);
        MuleEvent result = flow.process(getTestEvent(request));

        assertTrue(result.getMessage().getPayloadAsString().contains("VersionMismatch"));
    }
View Full Code Here

TOP

Related Classes of org.mule.construct.Flow

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.