use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.
the class RESTLoggingTest method testEvents.
@Test
public void testEvents() throws MalformedURLException {
LoggingFeature loggingFeature = new LoggingFeature();
loggingFeature.setLogBinary(true);
TestEventSender sender = new TestEventSender();
loggingFeature.setSender(sender);
Server server = createService(SERVICE_URI, new TestServiceRest(), loggingFeature);
server.start();
WebClient client = createClient(SERVICE_URI, loggingFeature);
String result = client.get(String.class);
Assert.assertEquals("test1", result);
server.destroy();
List<LogEvent> events = sender.getEvents();
Assert.assertEquals(4, events.size());
checkRequestOut(events.get(0));
checkRequestIn(events.get(1));
checkResponseOut(events.get(2));
checkResponseIn(events.get(3));
}
use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.
the class JMSClientServerTest method testQueueDecoupledOneWaysConnection.
@Test
public void testQueueDecoupledOneWaysConnection() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
String wsdl2 = "testutils/jms_test.wsdl".intern();
wsdlStrings.add(wsdl2);
broker.updateWsdl(getBus(), wsdl2);
HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
Endpoint requestEndpoint = null;
Endpoint replyEndpoint = null;
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
try {
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
requestEndpoint = Endpoint.publish(null, requestServant, new LoggingFeature());
GreeterImplQueueDecoupledOneWaysDeferredReply replyServant = new GreeterImplQueueDecoupledOneWaysDeferredReply();
replyEndpoint = Endpoint.publish(null, replyServant, new LoggingFeature());
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
String expectedRequest = "JMS:Queue:Request";
greeter.greetMeOneWay(expectedRequest);
String request = requestServant.ackRequestReceived(5000);
if (request == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The oneway call didn't reach its intended endpoint");
}
}
assertEquals(expectedRequest, request);
requestServant.proceedWithReply();
String expectedReply = requestServant.ackReplySent(5000);
if (expectedReply == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The decoupled one-way reply was not sent");
}
}
String reply = replyServant.ackRequest(5000);
if (reply == null) {
if (replyServant.getException() != null) {
fail(replyServant.getException().getMessage());
} else {
fail("The decoupled one-way reply didn't reach its intended endpoint");
}
}
assertEquals(expectedReply, reply);
} catch (Exception ex) {
throw ex;
} finally {
if (requestEndpoint != null) {
requestEndpoint.stop();
}
if (replyEndpoint != null) {
replyEndpoint.stop();
}
((java.io.Closeable) greeter).close();
}
}
use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.
the class ClientServerTest method testDynamicClientFactory.
@Test
public void testDynamicClientFactory() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
String wsdlUrl = null;
wsdlUrl = wsdl.toURI().toString();
DynamicClientFactory dcf = DynamicClientFactory.newInstance();
Client client = dcf.createClient(wsdlUrl, serviceName, portName);
updateAddressPort(client, PORT);
client.invoke("greetMe", "test");
Object[] result = client.invoke("sayHi");
assertNotNull("no response received from service", result);
assertEquals("Bonjour", result[0]);
client = dcf.createClient(wsdlUrl, serviceName, portName);
new LoggingFeature().initialize(client, client.getBus());
updateAddressPort(client, PORT);
client.invoke("greetMe", "test");
result = client.invoke("sayHi");
assertNotNull("no response received from service", result);
assertEquals("Bonjour", result[0]);
}
use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.
the class ControlImpl method startGreeter.
@Override
public boolean startGreeter(String cfgResource) {
SpringBusFactory bf = new SpringBusFactory();
System.setProperty("db.name", dbName);
if (StringUtils.isEmpty(cfgResource)) {
greeterBus = bf.createBus();
} else {
greeterBus = bf.createBus(cfgResource);
}
System.clearProperty("db.name");
BusFactory.setDefaultBus(greeterBus);
LOG.info("Initialised bus " + greeterBus + " with cfg file resource: " + cfgResource);
LOG.fine("greeterBus inInterceptors: " + greeterBus.getInInterceptors());
LoggingFeature lf = new LoggingFeature();
lf.setPrettyLogging(true);
lf.initialize(greeterBus);
if (cfgResource.indexOf("provider") == -1) {
endpoint = Endpoint.publish(address, implementor);
LOG.info("Published greeter endpoint.");
} else {
endpoint = Endpoint.publish(address, new GreeterProvider());
LOG.info("Published greeter provider.");
}
return true;
}
use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.
the class WSRM12ServerCycleTest method runTest.
public void runTest(String cfg, boolean faultOnRestart) throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus();
BusFactory.setDefaultBus(bus);
ControlService cs = new ControlService();
Control control = cs.getControlPort();
ConnectionHelper.setKeepAliveConnection(control, false, true);
updateAddressPort(control, PORT);
Assert.assertTrue("Failed to start greeter", control.startGreeter(cfg));
System.setProperty("db.name", getPrefix() + "-recovery");
Bus greeterBus = new SpringBusFactory().createBus();
System.clearProperty("db.name");
BusFactory.setDefaultBus(greeterBus);
// avoid early client resends
greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort(new LoggingFeature(), new AddressingFeature(), wsrm());
updateAddressPort(greeter, PORT);
greeter.greetMe("one");
greeter.greetMe("two");
greeter.greetMe("three");
control.stopGreeter(cfg);
// make sure greeter is down
Thread.sleep(1000);
control.startGreeter(cfg);
// CXF-7392
if (faultOnRestart) {
try {
greeter.greetMe("four");
} catch (SOAPFaultException ex) {
assertTrue(ex.getMessage().contains("wsrm:Identifier"));
// expected, sequence identifier doesn't exist on other side
}
} else {
// this should work as the sequence should be recovered on the server side
greeter.greetMe("four");
}
((Closeable) greeter).close();
greeterBus.shutdown(true);
control.stopGreeter(cfg);
bus.shutdown(true);
}
Aggregations