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();
}
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();
}
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();
}
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();
}
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;
}
Aggregations