Package org.mule.api.service

Examples of org.mule.api.service.Service


                assertTrue(e instanceof DispatchException);
                assertTrue(e.getCause() instanceof NoReceiverForEndpointException);
            }
        }
       
        Service c = muleContext.getRegistry().lookupService(component);
        c.start();

        MuleMessage message = client.send(endpoint, "Test Client Send message", null);
        assertNotNull(message);
        assertEquals("Received: Test Client Send message", message.getPayloadAsString());

        // The SpringRegistry is read-only so we can't unregister the service!
        //muleContext.getRegistry().unregisterComponent("vmComponent");
        c.stop();

        try
        {
            client.send(endpoint, "Test Client Send message", null);
        }
View Full Code Here


        super.doTearDown();
    }

    public void testInFlightMessagesWhenServiceStopped() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("TestService");
        populateSedaQueue(service, NUM_MESSAGES);

        stopService(service);

        assertNoLostMessages(NUM_MESSAGES, service);
View Full Code Here

        assertSedaQueueEmpty(service);
    }

    public void testInFlightMessagesPausedServiceWhenServiceStopped() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("PausedTestService");
        populateSedaQueue(service, NUM_MESSAGES);

        stopService(service);

        // The service is paused so no message get processed. Because the service is
View Full Code Here

        assertOutboundEmpty();
    }

    public void testInFlightMessagesPersistentQueueServiceWhenServiceStopped() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("TestPersistentQueueService");

        populateSedaQueue(service, NUM_MESSAGES);

        stopService(service);
View Full Code Here

        assertSedaQueueEmpty(service);
    }

    public void testInFlightMessagesPausedPersistentQueueServiceWhenServiceStopped() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("PausedTestPersistentQueueService");
        populateSedaQueue(service, NUM_MESSAGES);

        stopService(service);

        // Paused service does not process messages before or during stop().
        assertOutboundEmpty();
        assertNoLostMessages(NUM_MESSAGES, service);

        // Start, process some messages, stop and make sure no messages get lost.
        startService(service);
        service.resume();
        Thread.sleep(WAIT_TIME_MILLIS * 2);
        stopService(service);

        assertNoLostMessages(NUM_MESSAGES, service);

        // Let mule finish up with the rest of the messages until seda queue is empty
        startService(service);
        service.resume();
        Thread.sleep(WAIT_TIME_MILLIS * 20);
        stopService(service);

        assertNoLostMessages(NUM_MESSAGES, service);
        assertSedaQueueEmpty(service);
View Full Code Here

        assertSedaQueueEmpty(service);
    }

    public void testInFlightMessagesPersistentQueueServiceWhenMuleDisposed() throws Exception
    {
        Service service = muleContext.getRegistry().lookupService("TestPersistentQueueService");
        populateSedaQueue(service, NUM_MESSAGES);

        muleContext.dispose();

        assertNoLostMessages(NUM_MESSAGES, service);
View Full Code Here

        assertTrue(transformers.get(1) instanceof TestResponseTransformer);
    }

    public void testGlobalEndpoints() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("globalEndpoints");

        ImmutableEndpoint endpoint = ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints()
            .get(0);

        List<MessageProcessor> processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof TestInboundTransformer);
        // For backwards-compatibility only
        List<Transformer> transformers = endpoint.getTransformers();
        assertNotNull(transformers);
        assertEquals(1, transformers.size());
        assertTrue(transformers.get(0) instanceof TestInboundTransformer);

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof TestResponseTransformer);
        // For backwards-compatibility only
        transformers = endpoint.getResponseTransformers();
        assertNotNull(transformers);
        assertEquals(1, transformers.size());
        assertTrue(transformers.get(0) instanceof TestResponseTransformer);

        endpoint = (ImmutableEndpoint) ((OutboundPassThroughRouter) ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes()
            .get(0)).getRoutes().get(0);

        processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(2, processors.size());
View Full Code Here

        assertNull(obj[0]);
    }

    public Service initialiseService(byte txBeginAction, EventCallback callback) throws Exception
    {
        Service service = new SedaService(muleContext);
        ((AbstractService) service).setExceptionListener(new DefaultMessagingExceptionStrategy(muleContext, true));
        service.setName("testComponent");
        service.setComponent(new DefaultJavaComponent(new PrototypeObjectFactory(JdbcFunctionalTestComponent.class)));

        TransactionFactory tf = getTransactionFactory();
        TransactionConfig txConfig = new MuleTransactionConfig();
        txConfig.setFactory(tf);
        txConfig.setAction(txBeginAction);
       
        EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder(getInDest(), muleContext);
        endpointBuilder.setName("testIn");
        endpointBuilder.setConnector(connector);
        endpointBuilder.setTransactionConfig(txConfig);
        InboundEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint(
            endpointBuilder);

        EndpointBuilder endpointBuilder2 = new EndpointURIEndpointBuilder(getOutDest(), muleContext);
        endpointBuilder2.setName("testOut");
        endpointBuilder2.setConnector(connector);
        OutboundEndpoint outProvider = muleContext.getEndpointFactory().getOutboundEndpoint(
            endpointBuilder2);
       
        service.setOutboundMessageProcessor(new DefaultOutboundRouterCollection());
        OutboundPassThroughRouter router = new OutboundPassThroughRouter();
        router.addRoute(outProvider);
        ((OutboundRouterCollection) service.getOutboundMessageProcessor()).addRoute(router);
        ((CompositeMessageSource) service.getMessageSource()).addSource(endpoint);

        // these tests no longer work - they need replacing with config driven tests
        // furthemore, nothing is read from service properties any more
        // (except for axis and cxf related hacks)
        // so i am removing the code below since it's a pointless call to a deprecated method
//        HashMap props = new HashMap();
//        props.put("eventCallback", callback);
//        service.setProperties(props);
        service.setModel(model);
        muleContext.getRegistry().registerService(service);
        return service;
    }
View Full Code Here

        assertTrue(transformers.get(1) instanceof TestResponseTransformer);
    }

    public void testLocalEndpoints() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("localEndpoints");

        ImmutableEndpoint endpoint = ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints()
            .get(0);

        List<MessageProcessor> processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof TestInboundTransformer);
        // For backwards-compatibility only
        List<Transformer> transformers = endpoint.getTransformers();
        assertNotNull(transformers);
        assertEquals(1, transformers.size());
        assertTrue(transformers.get(0) instanceof TestInboundTransformer);

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
        assertTrue(processors.get(0) instanceof TestResponseTransformer);
        // For backwards-compatibility only
        transformers = endpoint.getResponseTransformers();
        assertNotNull(transformers);
        assertEquals(1, transformers.size());
        assertTrue(transformers.get(0) instanceof TestResponseTransformer);

        endpoint = (ImmutableEndpoint) ((OutboundPassThroughRouter) ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes()
            .get(0)).getRoutes().get(0);

        processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(1, processors.size());
View Full Code Here

        assertTrue(transformers.get(0) instanceof TestResponseTransformer);
    }

    public void testTransformerRefsWithChildProcessors() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("transformerRefsWithChildProcessors");

        ImmutableEndpoint endpoint = ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints()
            .get(0);

        List<MessageProcessor> processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(2, processors.size());
        assertTrue(processors.get(0) instanceof StringAppendTransformer);
        assertTrue(processors.get(1) instanceof TestInboundTransformer);

        processors = endpoint.getResponseMessageProcessors();
        assertNotNull(processors);
        assertEquals(2, processors.size());
        assertTrue(processors.get(0) instanceof MessageProcessorChain);
        assertTrue(((MessageProcessorChain)processors.get(0)).getMessageProcessors().get(0) instanceof StringAppendTransformer);
        assertTrue(processors.get(1) instanceof TestResponseTransformer);

        endpoint = (ImmutableEndpoint) ((OutboundPassThroughRouter) ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes()
            .get(0)).getRoutes().get(0);

        processors = endpoint.getMessageProcessors();
        assertNotNull(processors);
        assertEquals(2, processors.size());
View Full Code Here

TOP

Related Classes of org.mule.api.service.Service

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.