Examples of ConnectorService


Examples of org.mokai.ConnectorService

  @Test
  public void testSaveOneConnectorNoAdditionals() throws Exception {
    String path = "src/test/resources/temp-connectors/connectors.xml";

    ConnectorService processorService = mockConnectorService("test", 1000,
        new MockConnector(), new ArrayList<Acceptor>(), new ArrayList<Action>(),
        new ArrayList<Action>(), new ArrayList<Action>());

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
View Full Code Here

Examples of org.mokai.ConnectorService

    List<Action> actions = new ArrayList<Action>();
    actions.add(new MockAction());
    actions.add(new MockAction());

    ConnectorService connectorService = mockConnectorService("test", 1000,
        new MockConnector(), acceptors, actions, actions, actions);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
      .thenReturn(Collections.singletonList(connectorService));
View Full Code Here

Examples of org.mokai.ConnectorService

    acceptors.add(new MockConfigurableAcceptor("test1", 1));

    List<Action> actions = new ArrayList<Action>();
    actions.add(new MockConfigurableAction("test1", 1));

    ConnectorService connectorService = mockConnectorService("test", 1000, new MockConfigurableConnector("test", 0),
        acceptors, actions, actions, actions);

    ConfigDelegator delegator = mock(ConfigDelegator.class);
    when(delegator.getConnectors())
      .thenReturn(Collections.singletonList(connectorService));
View Full Code Here

Examples of org.mokai.ConnectorService

  private ConnectorService mockConnectorService(String id, int priority, Processor processor,
      List<Acceptor> acceptors, List<Action> preProcessingActions,
      List<Action> postProcessingActions, List<Action> postReceivingActions) {

    ConnectorService processorService = mock(ConnectorService.class);

    when(processorService.getId()).thenReturn(id);
    when(processorService.getPriority()).thenReturn(priority);

    when(processorService.getConnector()).thenReturn(processor);

    when(processorService.getAcceptors()).thenReturn(acceptors);

    when(processorService.getPreProcessingActions()).thenReturn(preProcessingActions);

    when(processorService.getPostProcessingActions()).thenReturn(postProcessingActions);

    when(processorService.getPostReceivingActions()).thenReturn(postReceivingActions);

    return processorService;
  }
View Full Code Here

Examples of org.mokai.ConnectorService

    Assert.assertEquals(postReceivingActions.get(0), action2);
  }

  @Test
  public void testAddRemoveConfigurableAcceptor() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Acceptor configurableAcceptor = Mockito.mock(Acceptor.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addAcceptor(configurableAcceptor);
    processorService.removeAcceptor(configurableAcceptor);

    Mockito.verify((Configurable) configurableAcceptor).configure();
    Mockito.verify((Configurable) configurableAcceptor).destroy();
  }
View Full Code Here

Examples of org.mokai.ConnectorService

    Mockito.verify((Configurable) configurableAcceptor).destroy();
  }

  @Test
  public void testAddRemoveConfigurablePreProcessingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Action configurableAction = Mockito.mock(Action.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addPreProcessingAction(configurableAction);
    processorService.removePreProcessingAction(configurableAction);

    Mockito.verify((Configurable) configurableAction).configure();
    Mockito.verify((Configurable) configurableAction).destroy();
  }
View Full Code Here

Examples of org.mokai.ConnectorService

    Mockito.verify((Configurable) configurableAction).destroy();
  }

  @Test
  public void testAddRemoveConfigurablePostProcessingAction() throws Exception {
    ConnectorService processorService = new MockConnectorService("test", Mockito.mock(Processor.class), resourceRegistry);

    Action configurableAction = Mockito.mock(Action.class,
        Mockito.withSettings().extraInterfaces(Configurable.class));

    processorService.addPostProcessingAction(configurableAction);
    processorService.removePostProcessingAction(configurableAction);

    Mockito.verify((Configurable) configurableAction).configure();
    Mockito.verify((Configurable) configurableAction).destroy();
  }
View Full Code Here

Examples of org.mule.module.management.mbean.ConnectorService

    protected void registerConnectorServices() throws MalformedObjectNameException,
        NotCompliantMBeanException, MBeanRegistrationException, InstanceAlreadyExistsException
    {
        for (Connector connector : muleContext.getRegistry().lookupObjects(Connector.class))
        {
            ConnectorServiceMBean service = new ConnectorService(connector);
            final String rawName = service.getName();
            final String name = jmxSupport.escape(rawName);
            final String jmxName = String.format("%s:%s%s", jmxSupport.getDomainName(muleContext, !containerMode), ConnectorServiceMBean.DEFAULT_JMX_NAME_PREFIX, name);
            if (logger.isDebugEnabled())
            {
                logger.debug("Attempting to register service with name: " + jmxName);
View Full Code Here

Examples of org.mule.module.management.mbean.ConnectorService

    protected void registerConnectorServices() throws MalformedObjectNameException,
        NotCompliantMBeanException, MBeanRegistrationException, InstanceAlreadyExistsException
    {
        for (Connector connector : muleContext.getRegistry().lookupLocalObjects(Connector.class))
        {
            ConnectorServiceMBean service = new ConnectorService(connector);
            final String rawName = service.getName();
            final String name = jmxSupport.escape(rawName);
            final String jmxName = String.format("%s:%s%s", jmxSupport.getDomainName(muleContext, !containerMode), ConnectorServiceMBean.DEFAULT_JMX_NAME_PREFIX, name);
            if (logger.isDebugEnabled())
            {
                logger.debug("Attempting to register service with name: " + jmxName);
View Full Code Here

Examples of org.osgi.service.io.ConnectorService

    {
        ConnectionFactoryMock connFactory = new ConnectionFactoryMock();
        Dictionary props = new Hashtable();
        props.put(ConnectionFactory.IO_SCHEME, "file");
        ServiceRegistration registration = registerConnectionFactory(connFactory, props);
        ConnectorService service = getConnectorService();

        Connection connection = service.open("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ_WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);

        connection = service.open("file://test.txt", ConnectorService.READ);
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);

        connection = service.open("file://test.txt", ConnectorService.WRITE);
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);

        connection = service.open("file://test.txt", ConnectorService.READ, true);
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ, connFactory.getMode());
        assertEquals(true, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);

        try
        {
            connection = service.open("http://test.txt", ConnectorService.READ);
            fail("Connection shouldn't be created");
        } catch (ConnectionNotFoundException e)
        {
            // "expected"
        }

        try
        {
            service.open("file.txt");
            fail("Illegal format of uri");
        } catch (IllegalArgumentException e)
        {
            // expected
        }

        DataInputStream dataInStream = service.openDataInputStream("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned DataInputStream", dataInStream);

        DataOutputStream dataOutStream = service.openDataOutputStream("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned DataOutputStream", dataOutStream);

        InputStream inStream = service.openInputStream("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned InputStream", inStream);

        OutputStream outStream = service.openOutputStream("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned OutputStream", outStream);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.