use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class LoggingOutInterceptorTest method testFormatting.
@Test
public void testFormatting() throws Exception {
control.replay();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
// p.setPrettyLogging(true);
CachedOutputStream cos = new CachedOutputStream();
String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> " + "</and></thousand></two></january></of></second></twenty></the></is></today>";
cos.write(s.getBytes());
Message message = new MessageImpl();
message.setExchange(new ExchangeImpl());
message.put(Message.CONTENT_TYPE, "application/xml");
Logger logger = LogUtils.getL7dLogger(this.getClass());
LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
l.onClose(cos);
String str = baos.toString();
// format has changed
assertFalse(str.matches(s));
assertTrue(str.contains("<today>"));
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class CachedOutputStreamTest method testUseSysPropsWithAttachmentDeserializer.
@Test
public void testUseSysPropsWithAttachmentDeserializer() throws Exception {
String old = System.getProperty(CachedConstants.THRESHOLD_SYS_PROP);
try {
System.clearProperty(CachedConstants.THRESHOLD_SYS_PROP);
reloadDefaultProperties();
CachedOutputStream cache = new CachedOutputStream();
Message message = new MessageImpl();
AttachmentUtil.setStreamedAttachmentProperties(message, cache);
File tmpfile = getTmpFile("Hello World!", cache);
assertNull("expects no tmp file", tmpfile);
cache.close();
System.setProperty(CachedConstants.THRESHOLD_SYS_PROP, "4");
reloadDefaultProperties();
cache = new CachedOutputStream();
AttachmentUtil.setStreamedAttachmentProperties(message, cache);
tmpfile = getTmpFile("Hello World!", cache);
assertNotNull("expects a tmp file", tmpfile);
assertTrue("expects a tmp file", tmpfile.exists());
cache.close();
assertFalse("expects no tmp file", tmpfile.exists());
} finally {
System.clearProperty(CachedConstants.THRESHOLD_SYS_PROP);
if (old != null) {
System.setProperty(CachedConstants.THRESHOLD_SYS_PROP, old);
}
}
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class CdiResourceProviderTest method assertSingleton.
private void assertSingleton() {
final ResourceProvider provider = new SingletonResourceProvider(new Lifecycle(beanManager, bean), Object.class);
assertTrue(new JAXRSCdiResourceExtension().isCxfSingleton(beanManager, bean));
assertTrue(provider.isSingleton());
final Object instance = provider.getInstance(new MessageImpl());
assertNotNull(instance);
assertEquals(instance, provider.getInstance(new MessageImpl()));
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class DocLiteralInInterceptorTest method setUpUsingDocLit.
private void setUpUsingDocLit() throws Exception {
String ns = "http://apache.org/hello_world_doc_lit_bare";
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(), new QName(ns, "SOAPService"));
service = factory.create();
endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
endpoint = new EndpointImpl(bus, service, endpointInfo);
JAXBDataBinding db = new JAXBDataBinding();
db.setContext(JAXBContext.newInstance(new Class[] { TradePriceData.class }));
service.setDataBinding(db);
operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi"));
operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class);
operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Service.class, service);
exchange.put(Endpoint.class, endpoint);
exchange.put(Binding.class, endpoint.getBinding());
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class DocLiteralInInterceptorTest method setUpUsingHelloWorld.
private void setUpUsingHelloWorld() throws Exception {
String ns = "http://apache.org/hello_world_soap_http";
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService"));
service = factory.create();
endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
endpoint = new EndpointImpl(bus, service, endpointInfo);
JAXBDataBinding db = new JAXBDataBinding();
db.setContext(JAXBContext.newInstance(new Class[] { GreetMe.class, GreetMeResponse.class }));
service.setDataBinding(db);
operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Service.class, service);
exchange.put(Endpoint.class, endpoint);
exchange.put(Binding.class, endpoint.getBinding());
}
Aggregations