Search in sources :

Example 1 with Foo

use of org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo in project cxf by apache.

the class ClientServerMiscTest method testExceptionCases.

private void testExceptionCases(DocLitWrappedCodeFirstService port) throws Exception {
    /*   CXF-926 test case */
    try {
        port.throwException(10);
        fail("Expected exception not found");
    } catch (ServiceTestFault ex) {
        assertEquals(10L, ex.getFaultInfo().getId());
    }
    // CXF-1131 testcase
    try {
        port.throwException(-1);
        fail("Expected exception not found");
    } catch (ServiceTestFault ex) {
        assertNull(ex.getFaultInfo());
    }
    // CXF-1136 testcase
    try {
        port.throwException(-2);
        fail("Expected exception not found");
    } catch (CustomException ex) {
        assertEquals("CE: -2", ex.getMessage());
        assertEquals("A Value", ex.getA());
        assertEquals("B Value", ex.getB());
    }
    // CXF-1407
    try {
        port.throwException(-3);
        fail("Expected exception not found");
    } catch (ComplexException ex) {
        assertEquals("Throw user fault -3", ex.getMessage());
        assertEquals(3, ex.getInts().length);
    }
    try {
        port.throwException(-3);
        fail("Expected exception not found");
    } catch (ComplexException ex) {
        assertEquals("Throw user fault -3", ex.getMessage());
    }
    try {
        port.throwException(-4);
        fail("Expected exception not found");
    } catch (WebServiceException ex) {
        assertEquals("RuntimeException!!", ex.getMessage());
    }
    try {
        Foo foo = new Foo();
        foo.setNameIgnore("DoNoName");
        port.modifyFoo(foo);
        fail("Expected exception not found");
    } catch (SOAPFaultException ex) {
        assertTrue(ex.getMessage(), ex.getMessage().contains("NoName is not a valid name"));
    }
    try {
        Foo foo = new Foo();
        foo.setNameIgnore("NoName");
        port.modifyFoo(foo);
        fail("Expected exception not found");
    } catch (SOAPFaultException ex) {
        assertTrue(ex.getMessage().contains("NoName is not a valid name"));
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Foo(org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 2 with Foo

use of org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo in project cxf by apache.

the class ClientServerMiscTest method runDocLitTest.

private void runDocLitTest(DocLitWrappedCodeFirstService port) throws Exception {
    assertEquals("snarf", port.doBug2692("snarf"));
    CXF2411Result<CXF2411SubClass> o = port.doCXF2411();
    assertNotNull(o);
    assertNotNull(o.getContent());
    Object[] ar = o.getContent();
    assertTrue(ar[0] instanceof CXF2411SubClass);
    Foo foo = new Foo();
    foo.setName("blah");
    assertEquals("blah", port.modifyFoo(foo).getName());
    assertEquals("hello", port.outOnly(new Holder<String>(), new Holder<String>()));
    long start = System.currentTimeMillis();
    port.doOneWay();
    assertTrue((System.currentTimeMillis() - start) < 500);
    assertEquals("Hello", port.echoStringNotReallyAsync("Hello"));
    Set<Foo> fooSet = port.getFooSet();
    assertEquals(2, fooSet.size());
    assertEquals("size: 2", port.doFooList(new ArrayList<>(fooSet)));
    assertEquals(24, port.echoIntDifferentWrapperName(24));
    String echoMsg = port.echo("Hello");
    assertEquals("Hello", echoMsg);
    List<String> rev = new ArrayList<>(Arrays.asList(DocLitWrappedCodeFirstServiceImpl.DATA));
    Collections.reverse(rev);
    String s;
    String[] arrayOut = port.arrayOutput();
    assertNotNull(arrayOut);
    assertEquals(3, arrayOut.length);
    for (int x = 0; x < 3; x++) {
        assertEquals(DocLitWrappedCodeFirstServiceImpl.DATA[x], arrayOut[x]);
    }
    List<String> listOut = port.listOutput();
    assertNotNull(listOut);
    assertEquals(3, listOut.size());
    for (int x = 0; x < 3; x++) {
        assertEquals(DocLitWrappedCodeFirstServiceImpl.DATA[x], listOut.get(x));
    }
    s = port.arrayInput(DocLitWrappedCodeFirstServiceImpl.DATA);
    assertEquals("string1string2string3", s);
    s = port.listInput(java.util.Arrays.asList(DocLitWrappedCodeFirstServiceImpl.DATA));
    assertEquals("string1string2string3", s);
    s = port.multiListInput(Arrays.asList(DocLitWrappedCodeFirstServiceImpl.DATA), rev, "Hello", 24);
    assertEquals("string1string2string3string3string2string1Hello24", s);
    s = port.listInput(new ArrayList<>());
    assertEquals("", s);
    s = port.listInput(null);
    assertEquals("", s);
    s = port.multiListInput(Arrays.asList(DocLitWrappedCodeFirstServiceImpl.DATA), rev, null, 24);
    assertEquals("string1string2string3string3string2string1<null>24", s);
    Holder<String> a = new Holder<String>();
    Holder<String> b = new Holder<String>("Hello");
    Holder<String> c = new Holder<String>();
    Holder<String> d = new Holder<String>(" ");
    Holder<String> e = new Holder<String>("world!");
    Holder<String> f = new Holder<String>();
    Holder<String> g = new Holder<String>();
    s = port.multiInOut(a, b, c, d, e, f, g);
    assertEquals("Hello world!", s);
    assertEquals("a", a.value);
    assertEquals("b", b.value);
    assertEquals("c", c.value);
    assertEquals("d", d.value);
    assertEquals("e", e.value);
    assertEquals("f", f.value);
    assertEquals("g", g.value);
    List<Foo> foos = port.listObjectOutput();
    assertEquals(2, foos.size());
    assertEquals("a", foos.get(0).getName());
    assertEquals("b", foos.get(1).getName());
    List<Foo[]> foos2 = port.listObjectArrayOutput();
    assertNotNull(foos2);
    assertEquals(2, foos2.size());
    assertEquals(2, foos2.get(0).length);
    assertEquals(2, foos2.get(1).length);
    int[] ints = port.echoIntArray(new int[] { 1, 2, 3 }, null);
    assertEquals(3, ints.length);
    assertEquals(1, ints[0]);
    if (new ASMHelper().createClassWriter() != null) {
        // doing the type adapter things and such really
        // requires the ASM generated helper classes
        assertEquals("Val", port.createBar("Val").getName());
    }
    testExceptionCases(port);
}
Also used : Foo(org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo) OrderedParamHolder(org.apache.cxf.ordered_param_holder.OrderedParamHolder) Holder(javax.xml.ws.Holder) ArrayList(java.util.ArrayList) ASMHelper(org.apache.cxf.common.util.ASMHelper) CXF2411SubClass(org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.CXF2411SubClass)

Aggregations

Foo (org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo)2 ArrayList (java.util.ArrayList)1 Holder (javax.xml.ws.Holder)1 WebServiceException (javax.xml.ws.WebServiceException)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 ASMHelper (org.apache.cxf.common.util.ASMHelper)1 OrderedParamHolder (org.apache.cxf.ordered_param_holder.OrderedParamHolder)1 CXF2411SubClass (org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.CXF2411SubClass)1