Package org.mule.api.transport

Examples of org.mule.api.transport.Connector


    }

    @Override
    public Connector createConnector() throws Exception
    {
        Connector cnn = new PromptStdioConnector(muleContext);
        cnn.setName("TestStdio");
        return cnn;
    }
View Full Code Here


     * If the connector is configured not to do streaming it converts to byte[] so the original
     * input payload is not the same as the payload in the MuleMessage
     */
    public void testConnectorMessageFactoryNonStreaming() throws Exception
    {
        Connector connector = getConnectorAndAssert();
        ((FileConnector) connector).setStreaming(false);

        Object payload = getValidMessage();
        MuleMessage message = connector.createMuleMessageFactory().create(payload, encoding);
        assertNotNull(message);
       
        byte[] messagePayload = (byte[]) message.getPayload();
        assertTrue(Arrays.equals(VALID_MESSAGE.getBytes(), messagePayload));
    }
View Full Code Here

    }

    public void testUndeploy() throws Exception
    {
        final Connector connector = new TestConnector(muleContext);
        connector.setName("TEST_CONNECTOR");
        muleContext.getRegistry().registerConnector(connector);
        muleContext.start();

        domainName = jmxSupport.getDomainName(muleContext);
        final String query = domainName + ":*";
 
View Full Code Here

    protected String encoding;

    @Override
    protected void doSetUp() throws Exception
    {
        Connector connector = createConnector();
        if (connector.getName() == null)
        {
            connector.setName("test");
        }
        connectorName = connector.getName();
        muleContext.getRegistry().registerConnector(connector);
        encoding = muleContext.getConfiguration().getDefaultEncoding();
    }
View Full Code Here

    }

    @Override
    protected void doTearDown() throws Exception
    {
        Connector connector = getConnector();
        if (connector.isDisposed())
        {
            fail("Connector has been disposed prematurely - lifecycle problem? Instance: " + connector);
        }
    }
View Full Code Here

        return muleContext.getRegistry().lookupConnector(connectorName);
    }
   
    protected Connector getConnectorAndAssert()
    {
        Connector connector = getConnector();
        assertNotNull(connector);
        return connector;
    }
View Full Code Here

        return connector;
    }

    public void testConnectorExceptionHandling() throws Exception
    {
        Connector connector = getConnectorAndAssert();

        // Text exception handler
        Mock ehandlerMock = new Mock(SystemExceptionHandler.class, "exceptionHandler");

        ehandlerMock.expect("handleException", C.isA(Exception.class));
View Full Code Here

    public void testConnectorLifecycle() throws Exception
    {
        // this test used to use the connector created for this test, but since we need to
        // simulate disposal as well we have to create an extra instance here.

        Connector localConnector = createConnector();
        localConnector.setName(connectorName+"-temp");
        // the connector did not come from the registry, so we need to initialise manually
        localConnector.initialise();
        localConnector.start();

        assertNotNull(localConnector);
        assertTrue(localConnector.isStarted());
        assertTrue(!localConnector.isDisposed());
        localConnector.stop();
        assertTrue(!localConnector.isStarted());
        assertTrue(!localConnector.isDisposed());
        localConnector.dispose();
        assertTrue(!localConnector.isStarted());
        assertTrue(localConnector.isDisposed());

        try
        {
            localConnector.start();
            fail("Connector cannot be restarted after being disposing");
        }
        catch (Exception e)
        {
            // expected
View Full Code Here

        }
    }

    public void testConnectorListenerSupport() throws Exception
    {
        Connector connector = getConnectorAndAssert();

        Service service = getTestService("anApple", Apple.class);

        InboundEndpoint endpoint =
            muleContext.getEndpointFactory().getInboundEndpoint(getTestEndpointURI());

        try
        {
            connector.registerListener(null, null, service);
            fail("cannot register null");
        }
        catch (Exception e)
        {
            // expected
        }

        try
        {
            connector.registerListener(endpoint, null, service);
            fail("cannot register null");
        }
        catch (Exception e)
        {
            // expected
        }

        try
        {
            connector.registerListener(null, getSensingNullMessageProcessor(), service);
            fail("cannot register null");
        }
        catch (Exception e)
        {
            // expected
        }

        connector.registerListener(endpoint, getSensingNullMessageProcessor(), service);

        // this should work
        connector.unregisterListener(endpoint, service);
        // so should this
        try
        {
            connector.unregisterListener(null, service);
            fail("cannot unregister null");
        }
        catch (Exception e)
        {
            // expected
        }
        try
        {
            connector.unregisterListener(null, service);
            fail("cannot unregister null");
        }
        catch (Exception e)
        {
            // expected
        }

        try
        {
            connector.unregisterListener(null, service);
            fail("cannot unregister null");
        }
        catch (Exception e)
        {
            // expected
        }
        connector.unregisterListener(endpoint, service);
        muleContext.getRegistry().unregisterService(service.getName());
    }
View Full Code Here

        muleContext.getRegistry().unregisterService(service.getName());
    }

    public void testConnectorBeanProps() throws Exception
    {
        Connector connector = getConnectorAndAssert();

        try
        {
            connector.setName(null);
            fail("Should throw IllegalArgumentException if name set to null");
        }
        catch (IllegalArgumentException e)
        {
            // expected
        }

        connector.setName("Test");
        assertEquals("Test", connector.getName());

        assertNotNull("Protocol must be set as a constant", connector.getProtocol());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transport.Connector

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.