Search in sources :

Example 1 with EndpointInfo

use of org.apache.cxf.service.model.EndpointInfo in project camel by apache.

the class CamelDestinationTest method testRoundTripDestinationWithFault.

@Test
public void testRoundTripDestinationWithFault() throws Exception {
    inMessage = null;
    EndpointInfo conduitEpInfo = new EndpointInfo();
    conduitEpInfo.setAddress("camel://direct:Producer");
    // set up the conduit send to be true
    CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
    final Message outMessage = new MessageImpl();
    endpointInfo.setAddress("camel://direct:EndpointA");
    final CamelDestination destination = setupCamelDestination(endpointInfo, true);
    destination.setCheckException(true);
    // set up MessageObserver for handling the conduit message
    MessageObserver observer = new MessageObserver() {

        public void onMessage(Message m) {
            try {
                Exchange exchange = new ExchangeImpl();
                exchange.setInMessage(m);
                m.setExchange(exchange);
                verifyReceivedMessage(m, "HelloWorld");
                //verifyHeaders(m, outMessage);
                // setup the message for
                Conduit backConduit;
                backConduit = getBackChannel(destination, m);
                // wait for the message to be got from the conduit
                Message replyMessage = new MessageImpl();
                replyMessage.setContent(Exception.class, new RuntimeCamelException());
                sendoutMessage(backConduit, replyMessage, true, "HelloWorld Fault");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
    error.expectedMessageCount(1);
    //this call will active the camelDestination
    destination.setMessageObserver(observer);
    // set is one way false for get response from destination
    // need to use another thread to send the request message
    sendoutMessage(conduit, outMessage, false, "HelloWorld");
    // wait for the message to be got from the destination,
    // create the thread to handler the Destination incoming message
    verifyReceivedMessage(inMessage, "HelloWorld Fault");
    error.assertIsSatisfied();
    destination.shutdown();
}
Also used : MessageObserver(org.apache.cxf.transport.MessageObserver) Message(org.apache.cxf.message.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Conduit(org.apache.cxf.transport.Conduit) RuntimeCamelException(org.apache.camel.RuntimeCamelException) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 2 with EndpointInfo

use of org.apache.cxf.service.model.EndpointInfo in project camel by apache.

the class CamelTransportTestSupport method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    BusFactory bf = BusFactory.newInstance();
    //setup the camel transport for the bus
    bus = bf.createBus();
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    CamelTransportFactory camelTransportFactory = new CamelTransportFactory();
    //set the context here to the transport factory;
    camelTransportFactory.setCamelContext(context);
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    dfm.registerDestinationFactory(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);
    cim.registerConduitInitiator(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);
    BusFactory.setDefaultBus(bus);
    endpointInfo = new EndpointInfo();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) BusFactory(org.apache.cxf.BusFactory) Before(org.junit.Before)

Example 3 with EndpointInfo

use of org.apache.cxf.service.model.EndpointInfo in project camel by apache.

the class CamelDestinationTest method testRoundTripDestination.

@Test
public void testRoundTripDestination() throws Exception {
    inMessage = null;
    EndpointInfo conduitEpInfo = new EndpointInfo();
    conduitEpInfo.setAddress("camel://direct:Producer");
    // set up the conduit send to be true
    CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
    final Message outMessage = new MessageImpl();
    endpointInfo.setAddress("camel://direct:EndpointA");
    final CamelDestination destination = setupCamelDestination(endpointInfo, true);
    // set up MessageObserver for handling the conduit message
    MessageObserver observer = new MessageObserver() {

        public void onMessage(Message m) {
            try {
                Exchange exchange = new ExchangeImpl();
                exchange.setInMessage(m);
                m.setExchange(exchange);
                verifyReceivedMessage(m, "HelloWorld");
                //verifyHeaders(m, outMessage);
                // setup the message for
                Conduit backConduit;
                backConduit = getBackChannel(destination, m);
                // wait for the message to be got from the conduit
                Message replyMessage = new MessageImpl();
                sendoutMessage(backConduit, replyMessage, true, "HelloWorld Response");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
    error.expectedMessageCount(0);
    //this call will active the camelDestination
    destination.setMessageObserver(observer);
    // set is one way false for get response from destination
    // need to use another thread to send the request message
    sendoutMessage(conduit, outMessage, false, "HelloWorld");
    // wait for the message to be got from the destination,
    // create the thread to handler the Destination incoming message
    verifyReceivedMessage(inMessage, "HelloWorld Response");
    error.assertIsSatisfied();
    destination.shutdown();
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) MessageObserver(org.apache.cxf.transport.MessageObserver) Message(org.apache.cxf.message.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Conduit(org.apache.cxf.transport.Conduit) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) Test(org.junit.Test)

Example 4 with EndpointInfo

use of org.apache.cxf.service.model.EndpointInfo in project camel by apache.

the class CamelDestinationTest method testOneWayDestination.

@Test
public void testOneWayDestination() throws Exception {
    destMessage = null;
    inMessage = null;
    EndpointInfo conduitEpInfo = new EndpointInfo();
    conduitEpInfo.setAddress("camel://direct:Producer");
    CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
    Message outMessage = new MessageImpl();
    CamelDestination destination = null;
    try {
        endpointInfo.setAddress("camel://direct:EndpointA");
        destination = setupCamelDestination(endpointInfo, true);
    // destination.activate();
    } catch (IOException e) {
        assertFalse("The CamelDestination activate should not through exception ", false);
        e.printStackTrace();
    }
    sendoutMessage(conduit, outMessage, true, "HelloWorld");
    // just verify the Destination inMessage
    assertTrue("The destiantion should have got the message ", destMessage != null);
    verifyReceivedMessage(destMessage, "HelloWorld");
    destination.shutdown();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(org.apache.cxf.message.Message) IOException(java.io.IOException) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 5 with EndpointInfo

use of org.apache.cxf.service.model.EndpointInfo in project Activiti by Activiti.

the class CxfWSDLImporter method importService.

protected WSService importService(ServiceInfo service) {
    String name = service.getName().getLocalPart();
    String location = "";
    for (EndpointInfo endpoint : service.getEndpoints()) {
        location = endpoint.getAddress();
    }
    WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
    for (OperationInfo operation : service.getInterface().getOperations()) {
        WSOperation wsOperation = this.importOperation(operation, wsService);
        wsService.addOperation(wsOperation);
        this.wsOperations.put(this.namespace + operation.getName().getLocalPart(), wsOperation);
    }
    return wsService;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo)

Aggregations

EndpointInfo (org.apache.cxf.service.model.EndpointInfo)5 IOException (java.io.IOException)3 Message (org.apache.cxf.message.Message)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 Test (org.junit.Test)3 WebServiceException (javax.xml.ws.WebServiceException)2 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 Exchange (org.apache.cxf.message.Exchange)2 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)2 Conduit (org.apache.cxf.transport.Conduit)2 MessageObserver (org.apache.cxf.transport.MessageObserver)2 BusFactory (org.apache.cxf.BusFactory)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)1 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)1 Before (org.junit.Before)1