Search in sources :

Example 6 with TradePriceData

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());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) DocLiteralInInterceptor(org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) Test(org.junit.Test)

Example 7 with TradePriceData

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());
}
Also used : XMLStreamWriter(javax.xml.stream.XMLStreamWriter) QName(javax.xml.namespace.QName) Fault(org.apache.cxf.interceptor.Fault) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 8 with TradePriceData

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());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) QName(javax.xml.namespace.QName) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 9 with TradePriceData

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);
    }
}
Also used : SOAPService(org.apache.hello_world_doc_lit_bare.SOAPService) Holder(javax.xml.ws.Holder) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) PutLastTradedPricePortType(org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType) URL(java.net.URL) Test(org.junit.Test)

Aggregations

TradePriceData (org.apache.hello_world_doc_lit_bare.types.TradePriceData)9 Test (org.junit.Test)9 QName (javax.xml.namespace.QName)4 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 PutLastTradedPricePortType (org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType)3 URL (java.net.URL)2 Holder (javax.xml.ws.Holder)2 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)2 SOAPService (org.apache.hello_world_doc_lit_bare.SOAPService)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 WebMethod (javax.jws.WebMethod)1 WebParam (javax.jws.WebParam)1 Fault (org.apache.cxf.interceptor.Fault)1 DepthXMLStreamReader (org.apache.cxf.staxutils.DepthXMLStreamReader)1 BareInInterceptor (org.apache.cxf.wsdl.interceptors.BareInInterceptor)1 DocLiteralInInterceptor (org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor)1