Search in sources :

Example 1 with TradePriceData

use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.

the class DOCBareClientServerTest method testAnnotation.

@Test
public void testAnnotation() throws Exception {
    Class<PutLastTradedPricePortType> claz = PutLastTradedPricePortType.class;
    TradePriceData priceData = new TradePriceData();
    Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData);
    Method method = claz.getMethod("sayHi", holder.getClass());
    assertNotNull("Can not find SayHi method in generated class ", method);
    Annotation ann = method.getAnnotation(WebMethod.class);
    WebMethod webMethod = (WebMethod) ann;
    assertEquals(webMethod.operationName(), "SayHi");
    Annotation[][] paraAnns = method.getParameterAnnotations();
    for (Annotation[] paraType : paraAnns) {
        for (Annotation an : paraType) {
            if (an.annotationType() == WebParam.class) {
                WebParam webParam = (WebParam) an;
                assertNotSame("", webParam.targetNamespace());
            }
        }
    }
}
Also used : WebMethod(javax.jws.WebMethod) WebParam(javax.jws.WebParam) Holder(javax.xml.ws.Holder) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) WebMethod(javax.jws.WebMethod) Method(java.lang.reflect.Method) PutLastTradedPricePortType(org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 2 with TradePriceData

use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.

the class XMLStreamDataReaderTest method testReadBare.

@Test
public void testReadBare() throws Exception {
    JAXBDataBinding db = getDataBinding(TradePriceData.class);
    reader = getTestReader("../resources/sayHiDocLitBareReq.xml");
    assertNotNull(reader);
    DataReader<XMLStreamReader> dr = db.createReader(XMLStreamReader.class);
    assertNotNull(dr);
    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);
    part.setTypeClass(TradePriceData.class);
    Object val = dr.read(part, reader);
    assertNotNull(val);
    assertTrue(val instanceof TradePriceData);
    assertEquals("CXF", ((TradePriceData) val).getTickerSymbol());
    assertEquals(new Float(1.0f), new Float(((TradePriceData) val).getTickerPrice()));
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) QName(javax.xml.namespace.QName) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 3 with TradePriceData

use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.

the class XMLStreamDataWriterTest method testSetProperty.

@Test
public void testSetProperty() throws Exception {
    MyCustomHandler handler = new MyCustomHandler();
    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);
    dw.write(val, part, streamWriter);
    streamWriter.flush();
    // Test MyCustomHandler
    assertTrue(handler.getUsed());
}
Also used : XMLStreamWriter(javax.xml.stream.XMLStreamWriter) QName(javax.xml.namespace.QName) TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Example 4 with TradePriceData

use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.

the class OOBHeaderTest 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);
    TradePriceData priceData = new TradePriceData();
    priceData.setTickerPrice(1.0f);
    priceData.setTickerSymbol("CELTIX");
    assertFalse(check(0, putLastTradedPrice, false, true, priceData));
    assertFalse(check(1, putLastTradedPrice, false, true, priceData));
    assertTrue(check(2, putLastTradedPrice, false, true, priceData));
    assertTrue(check(3, putLastTradedPrice, false, true, priceData));
    assertFalse(check(0, putLastTradedPrice, true, true, priceData));
    assertFalse(check(1, putLastTradedPrice, true, true, priceData));
    assertFalse(check(2, putLastTradedPrice, true, true, priceData));
    assertFalse(check(3, putLastTradedPrice, true, true, priceData));
    assertTrue(check(0, putLastTradedPrice, false, false, priceData));
    assertTrue(check(1, putLastTradedPrice, false, false, priceData));
    assertTrue(check(2, putLastTradedPrice, false, false, priceData));
    assertTrue(check(4, putLastTradedPrice, false, false, priceData));
    assertTrue(check(0, putLastTradedPrice, true, false, priceData));
    assertTrue(check(1, putLastTradedPrice, true, false, priceData));
    assertTrue(check(2, putLastTradedPrice, true, false, priceData));
    assertTrue(check(4, putLastTradedPrice, true, false, priceData));
}
Also used : SOAPService(org.apache.hello_world_doc_lit_bare.SOAPService) 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)

Example 5 with TradePriceData

use of org.apache.hello_world_doc_lit_bare.types.TradePriceData in project cxf by apache.

the class BareInInterceptorTest method testInterceptorInbound1.

@Test
public void testInterceptorInbound1() throws Exception {
    setUpUsingDocLit();
    BareInInterceptor interceptor = new BareInInterceptor();
    message.setContent(XMLStreamReader.class, XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(), "resources/sayHiDocLitBareReq.xml")));
    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 : TradePriceData(org.apache.hello_world_doc_lit_bare.types.TradePriceData) BareInInterceptor(org.apache.cxf.wsdl.interceptors.BareInInterceptor) 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