Search in sources :

Example 81 with Holder

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

the class HeaderClientServerTest method testReturnHeader.

@Test
public void testReturnHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);
    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    try {
        Holder<TestHeader5ResponseBody> out = new Holder<TestHeader5ResponseBody>();
        Holder<TestHeader5> outHeader = new Holder<TestHeader5>();
        TestHeader5 in = new TestHeader5();
        String val = new String(TestHeader5.class.getSimpleName());
        for (int idx = 0; idx < 2; idx++) {
            val += idx;
            in.setRequestType(val);
            proxy.testHeader5(out, outHeader, in);
            assertEquals(1000, out.value.getResponseType());
            assertEquals(val, outHeader.value.getRequestType());
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : TestHeader(org.apache.header_test.TestHeader) Holder(javax.xml.ws.Holder) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) TestHeader5(org.apache.header_test.types.TestHeader5) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) TestHeader5ResponseBody(org.apache.header_test.types.TestHeader5ResponseBody) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 82 with Holder

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

the class JAXRS20ClientServerBookTest method testPostCollectionGenericEntityGenericCallback.

@Test
public void testPostCollectionGenericEntityGenericCallback() throws Exception {
    String endpointAddress = "http://localhost:" + PORT + "/bookstore/collections3";
    WebClient wc = WebClient.create(endpointAddress);
    wc.accept("application/xml").type("application/xml");
    GenericEntity<List<Book>> collectionEntity = createGenericEntity();
    final Holder<Book> holder = new Holder<Book>();
    InvocationCallback<Book> callback = new GenericInvocationCallback<Book>(holder) {
    };
    Future<Book> future = wc.post(collectionEntity, callback);
    Book book = future.get();
    assertEquals(200, wc.getResponse().getStatus());
    assertSame(book, holder.value);
    assertNotSame(collectionEntity.getEntity().get(0), book);
    assertEquals(collectionEntity.getEntity().get(0).getName(), book.getName());
}
Also used : Holder(javax.xml.ws.Holder) List(java.util.List) ArrayList(java.util.ArrayList) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 83 with Holder

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

the class JAXRS20ClientServerBookTest method doTestGetBookAsync.

private void doTestGetBookAsync(String address, boolean asyncInvoker) throws InterruptedException, ExecutionException {
    WebClient wc = createWebClient(address);
    final Holder<Book> holder = new Holder<Book>();
    InvocationCallback<Book> callback = createCallback(holder);
    Future<Book> future = asyncInvoker ? wc.async().get(callback) : wc.get(callback);
    Book book = future.get();
    assertSame(book, holder.value);
    assertEquals(124L, book.getId());
    validateResponse(wc);
}
Also used : Holder(javax.xml.ws.Holder) WebClient(org.apache.cxf.jaxrs.client.WebClient)

Example 84 with Holder

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

the class JAXRSAsyncClientTest method testGetBookAsync404Callback.

@Test
public void testGetBookAsync404Callback() throws Exception {
    String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
    WebClient wc = createWebClient(address);
    final Holder<Object> holder = new Holder<Object>();
    InvocationCallback<Object> callback = createCallback(holder);
    try {
        wc.async().get(callback).get();
        fail("Exception expected");
    } catch (ExecutionException ex) {
        assertTrue(ex.getCause() instanceof NotFoundException);
        assertTrue(ex.getCause() == holder.value);
    }
    wc.close();
}
Also used : Holder(javax.xml.ws.Holder) NotFoundException(javax.ws.rs.NotFoundException) ExecutionException(java.util.concurrent.ExecutionException) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 85 with Holder

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

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("Please specify the WSDL file.");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    System.out.println(wsdlURL);
    TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);
    TestMtomPortType port = (TestMtomPortType) tms.getPort(PORT_NAME, TestMtomPortType.class);
    Binding binding = ((BindingProvider) port).getBinding();
    ((SOAPBinding) binding).setMTOMEnabled(true);
    URL fileURL = Client.class.getResource("/me.bmp");
    File aFile = new File(new URI(fileURL.toString()));
    long fileSize = aFile.length();
    System.out.println("Filesize of me.bmp image is: " + fileSize);
    System.out.println("\nStarting MTOM Test using basic byte array:");
    Holder<String> name = new Holder<String>("Sam");
    Holder<byte[]> param = new Holder<byte[]>();
    param.value = new byte[(int) fileSize];
    InputStream in = fileURL.openStream();
    int len = in.read(param.value);
    while (len < fileSize) {
        len += in.read(param.value, len, (int) (fileSize - len));
    }
    System.out.println("--Sending the me.bmp image to server");
    System.out.println("--Sending a name value of " + name.value);
    port.testByteArray(name, param);
    System.out.println("--Received byte[] back from server, returned size is " + param.value.length);
    System.out.println("--Returned string value is " + name.value);
    Image image = ImageIO.read(new ByteArrayInputStream(param.value));
    System.out.println("--Loaded image from byte[] successfully, hashCode=" + image.hashCode());
    System.out.println("Successfully ran MTOM/byte array demo");
    System.out.println("\nStarting MTOM test with DataHandler:");
    name.value = "Bob";
    Holder<DataHandler> handler = new Holder<DataHandler>();
    handler.value = new DataHandler(fileURL);
    System.out.println("--Sending the me.bmp image to server");
    System.out.println("--Sending a name value of " + name.value);
    port.testDataHandler(name, handler);
    InputStream mtomIn = handler.value.getInputStream();
    fileSize = 0;
    for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
        fileSize++;
    }
    System.out.println("--Received DataHandler back from server, " + "returned size is " + fileSize);
    System.out.println("--Returned string value is " + name.value);
    System.out.println("Successfully ran MTOM/DataHandler demo");
    System.exit(0);
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) TestMtomPortType(org.apache.cxf.mime.TestMtomPortType) Image(java.awt.Image) TestMtomService(org.apache.cxf.mime.TestMtomService) URI(java.net.URI) URL(java.net.URL) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File)

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