Package org.mule.api.service

Examples of org.mule.api.service.Service


        return routers.get(0);
    }

    protected Service lookupService(String serviceName)
    {
        Service service = muleContext.getRegistry().lookupService(serviceName);
        assertNotNull(service);
        return service;
    }
View Full Code Here


        InboundEndpoint inboundEndpoint = (InboundEndpoint) mockEndpoint.proxy();

        Mock mockService = new Mock(Service.class);
        mockService.expectAndReturn("getResponseRouter", null);
        mockService.expectAndReturn("getInboundRouter", new ServiceCompositeMessageSource());
        Service service = (Service) mockService.proxy();

        MockHttpsMessageReceiver messageReceiver = new MockHttpsMessageReceiver(httpsConnector, service, inboundEndpoint);
        return messageReceiver;
    }
View Full Code Here

    /**
     * IsXmlFilter doesn't have any properties to test, so just check it is created
     */
    public void testIsXmlFilter()
    {
        Service service = muleContext.getRegistry().lookupService("test for xml");
        List routers = ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes();
        assertEquals(2, routers.size());
        assertTrue(routers.get(0).getClass().getName(), routers.get(0) instanceof FilteringOutboundRouter);
        assertTrue(((FilteringOutboundRouter) routers.get(0)).getFilter() instanceof IsXmlFilter);
        assertTrue(routers.get(1).getClass().getName(), routers.get(1) instanceof FilteringOutboundRouter);
        assertTrue(((FilteringOutboundRouter) routers.get(1)).getFilter() instanceof NotFilter);
View Full Code Here

        assertTrue(((NotFilter) ((FilteringOutboundRouter) routers.get(1)).getFilter()).getFilter() instanceof IsXmlFilter);
    }

    public void testJXPathFilter()
    {
        Service service = muleContext.getRegistry().lookupService("filter xml for content");
        List routers = ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes();
        assertEquals(1, routers.size());
        assertTrue(routers.get(0).getClass().getName(), routers.get(0) instanceof FilteringOutboundRouter);
        assertTrue(((FilteringOutboundRouter) routers.get(0)).getFilter() instanceof JXPathFilter);
        JXPathFilter filter = (JXPathFilter) ((FilteringOutboundRouter) routers.get(0)).getFilter();
        assertEquals("filter xml for content", filter.getExpectedValue());
View Full Code Here

        JcaModel jcaModel = resourceAdapter.getJcaModel("jca");
        MuleActivationSpec activationSpec = new MuleActivationSpec();
        activationSpec.setEndpoint("test://testEndpoint");
        InboundEndpoint endpoint = resourceAdapter.createMessageInflowEndpoint(activationSpec);

        Service service = resourceAdapter.createJcaService(endpointFactory, jcaModel, endpoint);

        // Check service
        assertNotNull(service);
        assertEquals("JcaService#" + endpointFactory.hashCode(), service.getName());
        assertNotNull(service);
        assertTrue(service instanceof JcaService);
        assertNotNull(service.getComponent());
        assertTrue(service.getComponent() instanceof JcaComponent);
        assertNotNull(((JcaComponent) service.getComponent()).workManager);
        testJcaService(service);

        testEndpoint(service);

        // Check endpoint
        ImmutableEndpoint endpoint2 = ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0);
        assertEquals(endpoint, endpoint2);

        // Check service implementation
        assertEquals(endpointFactory, ((JcaComponent) service.getComponent()).messageEndpointFactory);
    }
View Full Code Here

        resourceAdapter.endpointActivation(endpointFactory, activationSpec);
        assertEquals(1, resourceAdapter.endpoints.size());

        MuleEndpointKey key = new MuleEndpointKey(endpointFactory, activationSpec);
        Service service = resourceAdapter.endpoints.get(key);

        assertEquals("JcaService#" + endpointFactory.hashCode(), service.getName());
        testJcaService(service);
        testEndpoint(service);
       
        assertTrue(service.getComponent() instanceof JcaComponent);
       
        assertEquals(endpointFactory, ((JcaComponent) service.getComponent()).messageEndpointFactory);

        // Additional activation with same endpointFactory does not increase size of
        // endpoint cache.
        resourceAdapter.endpointActivation(endpointFactory, activationSpec);
        assertEquals(1, resourceAdapter.endpoints.size());
View Full Code Here

    // Another option would be to put it in the default-axis-config.xml (MULE-2102) with lazy-init="true"
    // but that makes us depend on Spring.
    // Another consideration is how/when this implicit component gets disposed.
    protected Service getOrCreateAxisComponent() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService(AXIS_SERVICE_PROPERTY + getName());

        if (service == null)
        {
            // TODO MULE-2228 Simplify this API
            service = new SedaService(muleContext);
            service.setName(AXIS_SERVICE_PROPERTY + getName());
            service.setModel(muleContext.getRegistry().lookupSystemModel());

            Map props = new HashMap();
            props.put(AXIS, axis);
            SingletonObjectFactory of = new SingletonObjectFactory(AxisServiceComponent.class, props);
            final DefaultJavaComponent component = new DefaultJavaComponent(of);
            component.setMuleContext(muleContext);
            service.setComponent(component);
        }
        return service;
    }
View Full Code Here

        List<Service> services = new ArrayList<Service>();
        for (String serviceName : serviceNames)
        {
            try
            {
                Service service = muleContext.getRegistry().lookupService(serviceName);
                service.stop();
                services.add(service);
            }
            catch (Exception e)
            {
                logger.error("Error '" + e.getMessage() + "' occured while stopping the service "
                             + serviceName + ". Perhaps the service did not exist in the config?");
                throw e;
            }
        }

        // Now init the directory for each named endpoint, one by one
        for (String endpointName : endpointNames)
        {
            initEndpointDirectory(endpointName);
        }

        // We are done, startup the services again so that the test can begin...
        for (Service service : services)
        {
            service.start();
        }
    }
View Full Code Here

    {
        FileConnector connector = (FileConnector) getConnector();
        connector.setPollingFrequency(POLLING_FREQUENCY);

        InboundEndpoint endpoint = getTestInboundEndpoint("simple");
        Service service = getTestService();
        MessageReceiver receiver = connector.createReceiver(service, endpoint);
        assertEquals("Connector's polling frequency must not be ignored.", POLLING_FREQUENCY,
                ((FileMessageReceiver) receiver).getFrequency());
    }
View Full Code Here

        InboundEndpoint endpoint = getTestInboundEndpoint("simple");

        // Endpoint wants String-typed properties
        endpoint.getProperties().put(FileConnector.PROPERTY_POLLING_FREQUENCY, String.valueOf(POLLING_FREQUENCY_OVERRIDE));

        Service service = getTestService();
        MessageReceiver receiver = connector.createReceiver(service, endpoint);
        assertEquals("Polling frequency endpoint override must not be ignored.", POLLING_FREQUENCY_OVERRIDE,
                ((FileMessageReceiver) receiver).getFrequency());
    }
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.