use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.
the class DocLiteralInInterceptorTest method testInterceptorInboundBare.
@Test
public void testInterceptorInboundBare() throws Exception {
setUpUsingDocLit();
DocLiteralInInterceptor interceptor = new DocLiteralInInterceptor();
message.setContent(XMLStreamReader.class, XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(), "resources/sayHiDocLitBareReq.xml")));
XMLStreamReader reader = message.getContent(XMLStreamReader.class);
// skip the start element of soap body
StaxUtils.skipToStartOfElement(reader);
message.put(Message.INBOUND_MESSAGE, Message.INBOUND_MESSAGE);
interceptor.handleMessage(message);
assertNull(message.getContent(Exception.class));
List<?> parameters = message.getContent(List.class);
assertEquals(1, parameters.size());
Object obj = parameters.get(0);
assertTrue(obj instanceof TradePriceData);
TradePriceData greet = (TradePriceData) obj;
assertTrue(1.0 == greet.getTickerPrice());
assertEquals("CXF", greet.getTickerSymbol());
}
use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.
the class XMLStreamDataWriterTest method testSetPropertyWithCustomExceptionHandling.
@Test
public void testSetPropertyWithCustomExceptionHandling() throws Exception {
MyCustomMarshallerHandler handler = new MyCustomMarshallerHandler();
DataWriterImpl<XMLStreamWriter> dw = newDataWriter(handler);
// Write Stuff
TradePriceData val = new TradePriceData();
val.setTickerSymbol("This is a symbol");
val.setTickerPrice(1.0f);
QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
try {
dw.write(val, part, streamWriter);
streamWriter.flush();
fail("Expected exception");
} catch (Fault f) {
assertTrue(f.getMessage().contains("My marshalling exception"));
}
// Test MyCustomHandler
assertTrue(handler.getUsed());
assertTrue(handler.isOnMarshalComplete());
assertFalse(handler.isOnUnmarshalComplete());
}
use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteBare.
@Test
public void testWriteBare() throws Exception {
JAXBDataBinding db = getTestWriterFactory(TradePriceData.class);
DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
assertNotNull(dw);
TradePriceData val = new TradePriceData();
val.setTickerSymbol("This is a symbol");
val.setTickerPrice(1.0f);
QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
dw.write(val, part, streamWriter);
streamWriter.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types", "tickerSymbol"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextText(reader);
assertEquals("This is a symbol", reader.getText());
}
use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.
the class DOCBareClientServerTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
URL wsdl = getClass().getResource("/wsdl/doc_lit_bare.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
PutLastTradedPricePortType putLastTradedPrice = service.getPort(portName, PutLastTradedPricePortType.class);
updateAddressPort(putLastTradedPrice, PORT);
String response = putLastTradedPrice.bareNoParam();
assertEquals("testResponse", response);
TradePriceData priceData = new TradePriceData();
priceData.setTickerPrice(1.0f);
priceData.setTickerSymbol("CELTIX");
Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData);
for (int i = 0; i < 5; i++) {
putLastTradedPrice.sayHi(holder);
assertEquals(4.5f, holder.value.getTickerPrice(), 0.01);
assertEquals("APACHE", holder.value.getTickerSymbol());
putLastTradedPrice.putLastTradedPrice(priceData);
}
}
Aggregations