Package org.mule.api.routing

Examples of org.mule.api.routing.OutboundRouterCollection


    public void testComponent3RouterEndpoints() throws Exception
    {
        // test inbound
        Service service = muleContext.getRegistry().lookupService("TestComponent3");
        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(2, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router1 = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router1.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router1.getRoutes().get(0);
        assertEquals("tcp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("tcp://localhost:60201", endpoint.getEndpointURI().getAddress());
        assertTrue(endpoint instanceof OutboundEndpoint);

        // second Router
        OutboundRouter router2 = (OutboundRouter)outboundRouter.getRoutes().get(1);
        assertEquals(2, router2.getRoutes().size());
        endpoint = (ImmutableEndpoint) router2.getRoutes().get(0);
        assertEquals("udp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("udp://localhost:56731", endpoint.getEndpointURI().getAddress());
        assertTrue(endpoint instanceof OutboundEndpoint);
View Full Code Here


    public void testComponent4RouterEndpoints() throws Exception
    {
        // test inbound
        Service service = muleContext.getRegistry().lookupService("TestComponent4");
        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(1, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router.getRoutes().get(0);
        assertEquals("udp", endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("udp://localhost:56731", endpoint.getEndpointURI().getAddress());
        // cannot get this to work and get axis tests to work
View Full Code Here

    public void testComponent5RouterEndpoints() throws Exception
    {
        // test inbound
        Service service = muleContext.getRegistry().lookupService("TestComponent5");
        assertNotNull(service);
        OutboundRouterCollection outboundRouter = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(outboundRouter);
        assertEquals(1, outboundRouter.getRoutes().size());
        // first Router
        OutboundRouter router = (OutboundRouter)outboundRouter.getRoutes().get(0);
        assertEquals(1, router.getRoutes().size());
        ImmutableEndpoint endpoint = (ImmutableEndpoint) router.getRoutes().get(0);
        assertEquals(TcpConnector.TCP, endpoint.getConnector().getProtocol().toLowerCase());
        assertEquals("tcp://localhost:45431", endpoint.getEndpointURI().getAddress());
        // cannot get this to work and get axis tests to work
View Full Code Here

    }

    protected MessageProcessor lookupOutboundRouterFromService(String serviceName) throws Exception
    {
        Service service = lookupService(serviceName);
        OutboundRouterCollection routerCollection =
            (OutboundRouterCollection) service.getOutboundMessageProcessor();
        return routerCollection.getRoutes().get(0);
    }
View Full Code Here

    public void testOutboundRouterConfig()
    {
        // test outbound message router
        Service service = muleContext.getRegistry().lookupService("orangeComponent");
        assertNotNull(service.getOutboundMessageProcessor());
        OutboundRouterCollection router = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNull(router.getCatchAllStrategy());
        assertEquals(1, router.getRoutes().size());
        // check first Router
        OutboundRouter route1 = (OutboundRouter) router.getRoutes().get(0);
        assertTrue(route1 instanceof OutboundPassThroughRouter);
        assertEquals(1, route1.getRoutes().size());
    }
View Full Code Here

    public void testOutboundRouterConfig2()
    {
        // test outbound message router
        Service service = muleContext.getRegistry().lookupService("appleComponent");
        assertNotNull(service.getOutboundMessageProcessor());
        OutboundRouterCollection router = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(router.getCatchAllStrategy());
        assertEquals(2, router.getRoutes().size());
        // check first Router
        OutboundRouter route1 = (OutboundRouter) router.getRoutes().get(0);
        assertTrue(route1 instanceof FilteringOutboundRouter);
        assertEquals(1, route1.getRoutes().size());
        ImmutableEndpoint ep = (ImmutableEndpoint) route1.getRoutes().get(0);
       
        assertNotNull(ep.getTransformers());
        assertTrue(TransformerUtils.firstOrNull(ep.getTransformers()) instanceof TestCompressionTransformer);

        Filter filter = ((FilteringOutboundRouter) route1).getFilter();
        assertNotNull(filter);
        assertTrue(filter instanceof PayloadTypeFilter);
        assertEquals(String.class, ((PayloadTypeFilter) filter).getExpectedType());

        // check second Router
        OutboundRouter route2 = (OutboundRouter) router.getRoutes().get(1);
        assertTrue(route2 instanceof FilteringOutboundRouter);

        Filter filter2 = ((FilteringOutboundRouter) route2).getFilter();
        assertNotNull(filter2);
        assertTrue(filter2 instanceof AndFilter);
        assertEquals(2((AndFilter) filter2).getFilters().size());
        Filter left = ((AndFilter) filter2).getFilters().get(0);
        Filter right = ((AndFilter) filter2).getFilters().get(1);
        assertNotNull(left);
        assertTrue(left instanceof RegExFilter);
        assertEquals("the quick brown (.*)", ((RegExFilter) left).getPattern());
        assertNotNull(right);
        assertTrue(right instanceof RegExFilter);
        assertEquals("(.*) brown (.*)", ((RegExFilter) right).getPattern());

        assertTrue(router.getCatchAllStrategy() instanceof TestCatchAllStrategy);
    }
View Full Code Here

    public void testOutboundRouterConfig2()
    {
        // test outbound message router
        Service service = muleContext.getRegistry().lookupService("appleComponent");
        assertNotNull(service.getOutboundMessageProcessor());
        OutboundRouterCollection router = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNotNull(router.getCatchAllStrategy());
        assertEquals(2, router.getRoutes().size());
        // check first Router
        OutboundRouter route1 = (OutboundRouter) router.getRoutes().get(0);
        assertTrue(route1 instanceof FilteringOutboundRouter);
        assertEquals(1, route1.getRoutes().size());
        ImmutableEndpoint ep = (ImmutableEndpoint) route1.getRoutes().get(0);
       
        assertNotNull(ep.getTransformers());
        assertTrue(TransformerUtils.firstOrNull(ep.getTransformers()) instanceof TestCompressionTransformer);

        Filter filter = ((FilteringOutboundRouter) route1).getFilter();
        assertNotNull(filter);
        assertTrue(filter instanceof PayloadTypeFilter);
        assertEquals(String.class, ((PayloadTypeFilter) filter).getExpectedType());

        // check second Router
        OutboundRouter route2 = (OutboundRouter) router.getRoutes().get(1);
        assertTrue(route2 instanceof FilteringOutboundRouter);

        Filter filter2 = ((FilteringOutboundRouter) route2).getFilter();
        assertNotNull(filter2);
        assertTrue(filter2 instanceof AndFilter);
        assertEquals(2((AndFilter) filter2).getFilters().size());
        Filter left = ((AndFilter) filter2).getFilters().get(0);
        Filter right = ((AndFilter) filter2).getFilters().get(1);
        assertNotNull(left);
        assertTrue(left instanceof RegExFilter);
        assertEquals("the quick brown (.*)", ((RegExFilter) left).getPattern());
        assertNotNull(right);
        assertTrue(right instanceof RegExFilter);
        assertEquals("(.*) brown (.*)", ((RegExFilter) right).getPattern());

        assertTrue(router.getCatchAllStrategy() instanceof TestCatchAllStrategy);
    }
View Full Code Here

    public void testOutboundRouterConfig()
    {
        // test outbound message router
        Service service = muleContext.getRegistry().lookupService("orangeComponent");
        assertNotNull(service.getOutboundMessageProcessor());
        OutboundRouterCollection router = (OutboundRouterCollection) service.getOutboundMessageProcessor();
        assertNull(router.getCatchAllStrategy());
        assertEquals(1, router.getRoutes().size());
        // check first Router
        OutboundRouter route1 = (OutboundRouter) router.getRoutes().get(0);
        assertTrue(route1 instanceof OutboundPassThroughRouter);
        assertEquals(1, route1.getRoutes().size());
    }
View Full Code Here

    }

    protected MessageProcessor lookupOutboundRouterFromService(String serviceName) throws Exception
    {
        Service service = lookupService(serviceName);
        OutboundRouterCollection routerCollection =
            (OutboundRouterCollection) service.getOutboundMessageProcessor();
        return routerCollection.getRoutes().get(0);
    }
View Full Code Here

        Object serviceFlow = muleContext.getRegistry().lookupObject("TestComponent3");

        if (serviceFlow instanceof Service)
        {
            assertNotNull(serviceFlow);
            OutboundRouterCollection outboundRouter = (OutboundRouterCollection) ((Service) serviceFlow).getOutboundMessageProcessor();
            assertNotNull(outboundRouter);
            assertEquals(2, outboundRouter.getRoutes().size());
            // first Router
            OutboundRouter router1 = (OutboundRouter) outboundRouter.getRoutes().get(0);
            assertEquals(1, router1.getRoutes().size());
            ImmutableEndpoint endpoint = (ImmutableEndpoint) router1.getRoutes().get(0);
            assertEquals("tcp", endpoint.getConnector().getProtocol().toLowerCase());
            assertEquals("tcp://localhost:60201", endpoint.getEndpointURI().getAddress());
            assertTrue(endpoint instanceof OutboundEndpoint);

            // second Router
            OutboundRouter router2 = (OutboundRouter) outboundRouter.getRoutes().get(1);
            assertEquals(2, router2.getRoutes().size());
            endpoint = (ImmutableEndpoint) router2.getRoutes().get(0);
            assertEquals("udp", endpoint.getConnector().getProtocol().toLowerCase());
            assertEquals("udp://localhost:56731", endpoint.getEndpointURI().getAddress());
            assertTrue(endpoint instanceof OutboundEndpoint);
View Full Code Here

TOP

Related Classes of org.mule.api.routing.OutboundRouterCollection

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.