use of org.apache.cxf.ext.logging.event.PrintWriterEventSender in project cxf by apache.
the class OldLoggingFactoryBeanListener method createEventSender.
private LogEventSender createEventSender(String location) {
if (StringUtils.isEmpty(location)) {
return null;
}
if ("<stdout>".equals(location)) {
return new PrintWriterEventSender(System.out);
} else if ("<stderr>".equals(location)) {
return new PrintWriterEventSender(System.err);
} else if (location.startsWith("file:")) {
try {
URI uri = new URI(location);
File file = new File(uri);
PrintWriter writer = new PrintWriter(new FileWriter(file, true), true);
return new PrintWriterEventSender(writer);
} catch (Exception ex) {
// stick with default
}
}
return null;
}
use of org.apache.cxf.ext.logging.event.PrintWriterEventSender in project cxf by apache.
the class InterceptorFaultTest method testRobustFailWithoutAddressingInUserLogicalPhase.
@Test
public void testRobustFailWithoutAddressingInUserLogicalPhase() throws Exception {
setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false);
control.setRobustInOnlyMode(true);
// behaviour is identicial for all phases
FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
location.setPhase("user-logical");
control.setFaultLocation(location);
try {
// writer to grab the content of soap fault.
// robust is not yet used at client's side, but I think it should
StringWriter writer = new StringWriter();
((Client) greeter).getInInterceptors().add(new LoggingInInterceptor(new PrintWriterEventSender(new PrintWriter(writer))));
// it should tell CXF to convert one-way robust out faults into real SoapFaultException
((Client) greeter).getEndpoint().put(Message.ROBUST_ONEWAY, true);
greeter.greetMeOneWay("oneway");
fail("Oneway operation unexpectedly succeded for phase " + location.getPhase());
} catch (SOAPFaultException ex) {
// expected
}
}
use of org.apache.cxf.ext.logging.event.PrintWriterEventSender in project cxf by apache.
the class MtomFeatureClientServerTest method setupOutLogging.
private ByteArrayOutputStream setupOutLogging() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(bos, true);
LoggingOutInterceptor out = new LoggingOutInterceptor(new PrintWriterEventSender(writer));
this.bus.getOutInterceptors().add(out);
return bos;
}
use of org.apache.cxf.ext.logging.event.PrintWriterEventSender in project cxf by apache.
the class StringArrayTest method testStringArrayList.
@Test
public void testStringArrayList() throws Exception {
SpringBusFactory factory = new SpringBusFactory();
Bus bus = factory.createBus();
BusFactory.setDefaultBus(bus);
setBus(bus);
StringWriter swin = new java.io.StringWriter();
java.io.PrintWriter pwin = new java.io.PrintWriter(swin);
LoggingInInterceptor logIn = new LoggingInInterceptor(new PrintWriterEventSender(pwin));
StringWriter swout = new java.io.StringWriter();
java.io.PrintWriter pwout = new java.io.PrintWriter(swout);
LoggingOutInterceptor logOut = new LoggingOutInterceptor(new PrintWriterEventSender(pwout));
getBus().getInInterceptors().add(logIn);
getBus().getOutInterceptors().add(logOut);
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
StringListTest port = service.getSoapPortRPCLit();
updateAddressPort(port, PORT);
String[] strs = new String[] { "org", "apache", "cxf" };
String[] res = port.stringListTest(strs);
assertArrayEquals(strs, res);
assertTrue("Request message is not marshalled correctly and @XmlList does not take effect:\n" + swout.toString(), swout.toString().indexOf("<in>org apache cxf</in>") > -1);
assertTrue("Response message is not marshalled correctly and @XmlList does not take effect\n" + swin.toString(), swin.toString().indexOf("<out>org apache cxf</out>") > -1);
}
Aggregations