FileDocCategorySizeDatePackage
TestBook.javaAPI DocApache Axis 1.45547Sat Apr 22 18:57:28 BST 2006test.holders

TestBook

public class TestBook extends test.GenericLocalTest
Confirm that faults using beans work

Fields Summary
private QName
TYPE_ARRAY_OF_BOOK
private QName
TYPE_BOOK
Constructors Summary
public TestBook()


      
        super("service");
    
public TestBook(String s)

        super(s);
    
Methods Summary
public voidechoInOutBook(test.holders.holders.BookHolder varBook)

        Book b = varBook.value;
        b.setAuthor("author2");
        b.setTitle("title2");
        b.setIsbn(2);
        varBook.value = b;
    
public voidechoInOutBookArray(test.holders.holders.ArrayOfBookHolder varBook)

        ArrayOfBook v = varBook.value;
        Book[] b = v.getArrayOfBook();
        if (b.length != 2) throw new RemoteException("array size not 2");
        String author = b[0].getAuthor();
        String title = b[0].getTitle();
        int isbn = b[0].getIsbn();
        b[0].setAuthor(b[1].getAuthor());
        b[0].setTitle(b[1].getTitle());
        b[0].setIsbn(b[1].getIsbn());
        b[1].setAuthor(author);
        b[1].setTitle(title);
        b[1].setIsbn(isbn);
        v.setArrayOfBook(b);
        varBook.value = v;
    
protected voidsetUp()

        super.setUp(false); // don't deploy here
        TypeMapping tm = (TypeMapping)config.getTypeMappingRegistry().
                        getDefaultTypeMapping();
        tm.register(Book.class, TYPE_BOOK,
                new BeanSerializerFactory(Book.class, TYPE_BOOK),
                new BeanDeserializerFactory(Book.class, TYPE_BOOK));
        tm.register(ArrayOfBook.class, TYPE_ARRAY_OF_BOOK,
                new BeanSerializerFactory(ArrayOfBook.class,
                        TYPE_ARRAY_OF_BOOK),
                new BeanDeserializerFactory(ArrayOfBook.class,
                        TYPE_ARRAY_OF_BOOK));
        deploy("service", this.getClass(), Style.RPC, Use.LITERAL);
    
public voidtestInOutBook()

        Call call = getCall();
        call.setOperationStyle("rpc");
        call.setOperationUse("literal");
        call.setEncodingStyle("");
        call.registerTypeMapping(Book.class, TYPE_BOOK,
                new BeanSerializerFactory(Book.class, TYPE_BOOK),
                new BeanDeserializerFactory(Book.class, TYPE_BOOK));
        call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
        call.addParameter("varBook", TYPE_BOOK, ParameterMode.INOUT);
        Book data = new Book();
        data.setAuthor("author1");
        data.setTitle("title1");
        data.setIsbn(1);
        call.invoke("echoInOutBook", new Object []{data});
        List l = call.getOutputValues();
        assertEquals(1, l.size());
        assertEquals("author2", ((Book)l.get(0)).getAuthor());
        assertEquals("title2", ((Book)l.get(0)).getTitle());
        assertEquals(2, ((Book)l.get(0)).getIsbn());
    
public voidtestInOutBookArray()

        Call call = getCall();
        call.setOperationStyle("rpc");
        call.setOperationUse("literal");
        call.setEncodingStyle("");
        call.registerTypeMapping(ArrayOfBook.class, TYPE_ARRAY_OF_BOOK,
                new BeanSerializerFactory(ArrayOfBook.class,
                        TYPE_ARRAY_OF_BOOK),
                new BeanDeserializerFactory(ArrayOfBook.class,
                        TYPE_ARRAY_OF_BOOK));
        call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
        call.addParameter("varBook", TYPE_ARRAY_OF_BOOK, ParameterMode.INOUT);
        Book b0 = new Book();
        b0.setAuthor("author0");
        b0.setTitle("title0");
        b0.setIsbn(0);
        Book b1 = new Book();
        b1.setAuthor("author1");
        b1.setTitle("title1");
        b1.setIsbn(1);
        Book b[] = new Book[2];
        b[0] = b0;
        b[1] = b1;
        ArrayOfBook aob = new ArrayOfBook();
        aob.setArrayOfBook(b);
        call.invoke("echoInOutBookArray", new Object []{aob});
        List l = call.getOutputValues();
        assertEquals(1, l.size());
        ArrayOfBook aob2 = (ArrayOfBook)l.get(0);
        Book b2[] = aob2.getArrayOfBook();
        assertEquals(2, b2.length);
        assertEquals(b2[0].getAuthor(), b[1].getAuthor());
        assertEquals(b2[1].getTitle(), b[0].getTitle());