Search in sources :

Example 86 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServerSwaTest method testSwa.

@Test
public void testSwa() throws Exception {
    SwAService service = new SwAService();
    SwAServiceInterface port = service.getSwAServiceHttpPort();
    setAddress(port, "http://localhost:" + serverPort + "/swa");
    Holder<String> textHolder = new Holder<String>();
    Holder<DataHandler> data = new Holder<DataHandler>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    data.value = handler;
    textHolder.value = "Hi";
    port.echoData(textHolder, data);
    InputStream bis = null;
    bis = data.value.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    assertEquals("Hi", textHolder.value);
}
Also used : SwAService(org.apache.cxf.swa.SwAService) SwAServiceInterface(org.apache.cxf.swa.SwAServiceInterface) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) DataHandler(javax.activation.DataHandler) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 87 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServerSwaTest method testSwaDataStruct.

@Test
public void testSwaDataStruct() throws Exception {
    SwAService service = new SwAService();
    SwAServiceInterface port = service.getSwAServiceHttpPort();
    setAddress(port, "http://localhost:" + serverPort + "/swa");
    Holder<DataStruct> structHolder = new Holder<DataStruct>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    DataStruct struct = new DataStruct();
    struct.setDataRef(handler);
    structHolder.value = struct;
    port.echoDataRef(structHolder);
    handler = structHolder.value.getDataRef();
    InputStream bis = handler.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    bis.close();
}
Also used : SwAService(org.apache.cxf.swa.SwAService) DataStruct(org.apache.cxf.swa.types.DataStruct) SwAServiceInterface(org.apache.cxf.swa.SwAServiceInterface) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) DataHandler(javax.activation.DataHandler) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 88 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServerSwaTest method testSwaTypes.

@Test
public void testSwaTypes() throws Exception {
    SwAService service = new SwAService();
    SwAServiceInterface port = service.getSwAServiceHttpPort();
    setAddress(port, "http://localhost:" + serverPort + "/swa");
    URL url1 = this.getClass().getResource("resources/attach.text");
    URL url2 = this.getClass().getResource("resources/attach.html");
    URL url3 = this.getClass().getResource("resources/attach.xml");
    URL url4 = this.getClass().getResource("resources/attach.jpeg1");
    URL url5 = this.getClass().getResource("resources/attach.gif");
    DataHandler dh1 = new DataHandler(url1);
    DataHandler dh2 = new DataHandler(url2);
    DataHandler dh3 = new DataHandler(url3);
    // DataHandler dh4 = new DataHandler(url4);
    // DataHandler dh5 = new DataHandler(url5);
    Holder<DataHandler> attach1 = new Holder<DataHandler>();
    attach1.value = dh1;
    Holder<DataHandler> attach2 = new Holder<DataHandler>();
    attach2.value = dh2;
    Holder<Source> attach3 = new Holder<Source>();
    attach3.value = new StreamSource(dh3.getInputStream());
    Holder<Image> attach4 = new Holder<Image>();
    Holder<Image> attach5 = new Holder<Image>();
    attach4.value = ImageIO.read(url4);
    attach5.value = ImageIO.read(url5);
    VoidRequest request = new VoidRequest();
    OutputResponseAll response = port.echoAllAttachmentTypes(request, attach1, attach2, attach3, attach4, attach5);
    assertNotNull(response);
    Map<?, ?> map = CastUtils.cast((Map<?, ?>) ((BindingProvider) port).getResponseContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
    assertNotNull(map);
    assertEquals(5, map.size());
}
Also used : VoidRequest(org.apache.cxf.swa.types.VoidRequest) SwAServiceInterface(org.apache.cxf.swa.SwAServiceInterface) Holder(javax.xml.ws.Holder) StreamSource(javax.xml.transform.stream.StreamSource) DataHandler(javax.activation.DataHandler) Image(java.awt.Image) OutputResponseAll(org.apache.cxf.swa.types.OutputResponseAll) URL(java.net.URL) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) SwAService(org.apache.cxf.swa.SwAService) Test(org.junit.Test)

Example 89 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServerSwaTest method testSwaWithHeaders.

@Test
public void testSwaWithHeaders() throws Exception {
    SwAService service = new SwAService();
    SwAServiceInterface port = service.getSwAServiceHttpPort();
    setAddress(port, "http://localhost:" + serverPort + "/swa");
    Holder<String> textHolder = new Holder<String>();
    Holder<String> headerHolder = new Holder<String>();
    Holder<DataHandler> data = new Holder<DataHandler>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    data.value = handler;
    textHolder.value = "Hi";
    headerHolder.value = "Header";
    port.echoDataWithHeader(textHolder, data, headerHolder);
    InputStream bis = null;
    bis = data.value.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    assertEquals("Hi", textHolder.value);
    assertEquals("Header", headerHolder.value);
}
Also used : SwAService(org.apache.cxf.swa.SwAService) SwAServiceInterface(org.apache.cxf.swa.SwAServiceInterface) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) DataHandler(javax.activation.DataHandler) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 90 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServerSwaTest method testSwa.

@Test
public void testSwa() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl");
    factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
    factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort"));
    factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    SwAService port = factory.create(SwAService.class);
    Holder<String> textHolder = new Holder<String>();
    Holder<DataHandler> data = new Holder<DataHandler>();
    ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
    DataHandler handler = new DataHandler(source);
    data.value = handler;
    textHolder.value = "Hi";
    port.echoData(textHolder, data);
    InputStream bis = null;
    bis = data.value.getDataSource().getInputStream();
    byte[] b = new byte[10];
    bis.read(b, 0, 10);
    String string = IOUtils.newStringFromBytes(b);
    assertEquals("testfoobar", string);
    assertEquals("Hi", textHolder.value);
    if (port instanceof Closeable) {
        ((Closeable) port).close();
    }
}
Also used : QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) Closeable(java.io.Closeable) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) DataHandler(javax.activation.DataHandler) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Aggregations

Holder (javax.xml.ws.Holder)328 Test (org.junit.Test)204 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 BigInteger (java.math.BigInteger)44 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 QName (javax.xml.namespace.QName)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 URL (java.net.URL)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15