Beispiel #1
0
 private UMOConnector buildConnector(String urlStr) throws UMOException {
   HttpConnector connector =
       (HttpConnector) ConnectorFactory.createConnector(new MuleEndpointURI(urlStr));
   connector.getDispatcherThreadingProfile().setDoThreading(false);
   MuleManager.getInstance().registerConnector(connector);
   return connector;
 }
Beispiel #2
0
  public void testSendComplex() throws Throwable {
    UMOConnector c = ConnectorFactory.getConnectorByProtocol(getProtocol());
    assertNotNull(c);
    UMOMessageDispatcher dispatcher = c.getDispatcher("ANY");
    UMOEndpoint endpoint =
        new MuleEndpoint(
            "test",
            new MuleEndpointURI(getSendReceiveComplexEndpoint1()),
            c,
            null,
            UMOEndpoint.ENDPOINT_TYPE_SENDER,
            0,
            null);
    UMOEvent event = getTestEvent(new Person("Ross", "Mason"), endpoint);

    UMOMessage result = dispatcher.send(event);
    assertNull(result);

    // lets get our newly added person
    result = dispatcher.receive(new MuleEndpointURI(getSendReceiveComplexEndpoint2()), 0);
    assertNotNull(result);
    assertTrue(result.getPayload() instanceof Person);
    assertEquals("Ross", ((Person) result.getPayload()).getFirstName());
    assertEquals("Mason", ((Person) result.getPayload()).getLastName());
  }
Beispiel #3
0
  protected synchronized void initFromServiceDescriptor() throws InitialisationException {
    try {
      serviceDescriptor =
          ConnectorFactory.getServiceDescriptor(getProtocol().toLowerCase(), serviceOverrides);

      if (serviceDescriptor.getDispatcherFactory() != null) {
        logger.info("Loading DispatcherFactory: " + serviceDescriptor.getDispatcherFactory());
        dispatcherFactory = serviceDescriptor.createDispatcherFactory();
      }

      defaultInboundTransformer = serviceDescriptor.createInboundTransformer();
      defaultOutboundTransformer = serviceDescriptor.createOutboundTransformer();
      defaultResponseTransformer = serviceDescriptor.createResponseTransformer();

      sessionHandler = serviceDescriptor.createSessionHandler();
      // set any manager default properties for the connector
      // these are set on the Manager with a protocol i.e.
      // jms.specification=1.1
      // This provides a really convenient way to set properties on object form unit
      // tests
      Map props = new HashMap();
      PropertiesHelper.getPropertiesWithPrefix(
          MuleManager.getInstance().getProperties(), getProtocol().toLowerCase(), props);
      if (props.size() > 0) {
        props = PropertiesHelper.removeNamspaces(props);
        org.mule.util.BeanUtils.populateWithoutFail(this, props, true);
      }
    } catch (Exception e) {
      throw new InitialisationException(e, this);
    }
  }
Beispiel #4
0
 public void testReceive() throws Throwable {
   UMOConnector c = ConnectorFactory.getConnectorByProtocol(getProtocol());
   assertNotNull(c);
   UMOMessageDispatcher dispatcher = c.getDispatcher("ANY");
   UMOMessage result = dispatcher.receive(new MuleEndpointURI(getReceiveEndpoint()), 0);
   assertNotNull(result);
   assertNotNull(result.getPayload());
   assertTrue(result.getPayload().toString().length() > 0);
 }
Beispiel #5
0
 public void testReceiveComplex() throws Throwable {
   UMOConnector c = ConnectorFactory.getConnectorByProtocol(getProtocol());
   assertNotNull(c);
   UMOMessageDispatcher dispatcher = c.getDispatcher("ANY");
   UMOMessage result = dispatcher.receive(new MuleEndpointURI(getReceiveComplexEndpoint()), 0);
   assertNotNull(result);
   assertTrue(result.getPayload() instanceof Person);
   assertEquals("Fred", ((Person) result.getPayload()).getFirstName());
   assertEquals("Flintstone", ((Person) result.getPayload()).getLastName());
 }
Beispiel #6
0
 public void testReceiveComplexCollection() throws Throwable {
   UMOConnector c = ConnectorFactory.getConnectorByProtocol(getProtocol());
   assertNotNull(c);
   UMOMessageDispatcher dispatcher = c.getDispatcher("ANY");
   UMOMessage result =
       dispatcher.receive(new MuleEndpointURI(getReceiveComplexCollectionEndpoint()), 0);
   assertNotNull(result);
   assertTrue(result.getPayload() instanceof Person[]);
   assertEquals(3, ((Person[]) result.getPayload()).length);
 }
Beispiel #7
0
 public void testException() throws Throwable {
   UMOConnector c = ConnectorFactory.getConnectorByProtocol(getProtocol());
   assertNotNull(c);
   UMOMessageDispatcher dispatcher = c.getDispatcher("ANY");
   UMOEndpoint endpoint =
       new MuleEndpoint(
           "test",
           new MuleEndpointURI(getTestExceptionEndpoint()),
           c,
           null,
           UMOEndpoint.ENDPOINT_TYPE_SENDER,
           0,
           null);
   UMOEvent event = getTestEvent(new Person("Nodet", "Guillaume"), endpoint);
   try {
     dispatcher.send(event);
     fail("An Fault should have been raised");
   } catch (Exception f) {
     // This is ok
   }
 }
Beispiel #8
0
  public ConnectorServiceDescriptor findService(String service, ConnectorServiceDescriptor csd)
      throws ConnectorFactoryException {
    Map finders = new TreeMap();
    PropertiesUtils.getPropertiesWithPrefix(csd.getProperties(), "finder.class", finders);

    StringBuffer buf = new StringBuffer();
    for (Iterator iterator = finders.entrySet().iterator(); iterator.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iterator.next();
      try {
        ClassUtils.loadClass(entry.getValue().toString(), getClass());
        String protocol = getProtocolFromKey(entry.getKey().toString());
        return ConnectorFactory.getServiceDescriptor(protocol);
      } catch (ClassNotFoundException e1) {
        buf.append(entry.getValue().toString())
            .append("(")
            .append(entry.getKey().toString())
            .append(")")
            .append(", ");
      }
    }
    throw new ConnectorServiceException(
        new Message(Messages.COULD_NOT_FIND_SOAP_PROVIDER_X, buf.toString()));
  }