001: package org.objectweb.celtix.jaxb;
002:
003: import java.util.ArrayList;
004: import java.util.List;
005: import junit.framework.TestCase;
006: import org.objectweb.handler_test.types.PingResponse;
007: import org.objectweb.hello_world_soap_http.types.AddNumbers;
008: import org.objectweb.hello_world_soap_http.types.AddNumbersResponse;
009: import org.objectweb.type_test.doc.TestBoolean;
010: import org.objectweb.type_test.doc.TestByte;
011: import org.objectweb.type_test.doc.TestByteResponse;
012:
013: public class WrapperHelperTest extends TestCase {
014:
015: public WrapperHelperTest(String arg0) {
016: super (arg0);
017: }
018:
019: public static void main(String[] args) {
020: junit.textui.TestRunner.run(WrapperHelperTest.class);
021: }
022:
023: public void testSetWrappedPart() throws Exception {
024: AddNumbers wrapper = new AddNumbers();
025: int arg0 = 10;
026: int arg1 = 20;
027:
028: WrapperHelper.setWrappedPart("arg0", wrapper, arg0);
029: WrapperHelper.setWrappedPart("arg1", wrapper, arg1);
030: assertEquals(arg0, wrapper.getArg0());
031: assertEquals(arg1, wrapper.getArg1());
032:
033: AddNumbersResponse wrapper1 = new AddNumbersResponse();
034: int arg2 = 30;
035: WrapperHelper.setWrappedPart("return", wrapper1, arg2);
036: assertEquals(arg2, wrapper1.getReturn());
037:
038: TestBoolean wrapper2 = new TestBoolean();
039: WrapperHelper.setWrappedPart("x", wrapper2, true);
040: assertEquals(true, wrapper2.isX());
041:
042: TestByte wrapper3 = new TestByte();
043: byte arg3 = 1;
044: WrapperHelper.setWrappedPart("x", wrapper3, arg3);
045: assertEquals(arg3, wrapper3.getX());
046:
047: try {
048: WrapperHelper.setWrappedPart("x", wrapper3, null);
049: } catch (IllegalArgumentException ex) {
050: //Expected Exception
051: }
052: }
053:
054: public void testSetWrappedPartList() throws Exception {
055: List<String> list = new ArrayList<String>();
056: list.add("arg0");
057: list.add("arg1");
058:
059: PingResponse wrapper = new PingResponse();
060: assertNotNull(wrapper.getHandlersInfo());
061: assertEquals(0, wrapper.getHandlersInfo().size());
062: WrapperHelper.setWrappedPart("handlersInfo", wrapper, list);
063: assertEquals(2, wrapper.getHandlersInfo().size());
064: assertEquals(list, wrapper.getHandlersInfo());
065: }
066:
067: public void testGetWrappedPart() throws Exception {
068: AddNumbers wrapper = new AddNumbers();
069: int arg0 = 10;
070: int arg1 = 20;
071: wrapper.setArg0(arg0);
072: wrapper.setArg1(arg1);
073:
074: Object x = WrapperHelper.getWrappedPart("arg0", wrapper,
075: int.class);
076: Object y = WrapperHelper.getWrappedPart("arg1", wrapper,
077: int.class);
078: assertEquals(arg0, x);
079: assertEquals(arg1, y);
080:
081: TestBoolean wrapper1 = new TestBoolean();
082: boolean arg2 = true;
083: wrapper1.setX(arg2);
084: WrapperHelper.getWrappedPart("x", wrapper1, boolean.class);
085: assertEquals(arg2, wrapper1.isX());
086:
087: TestByte wrapper3 = new TestByte();
088: byte arg3 = 1;
089: wrapper3.setX(arg3);
090: WrapperHelper.getWrappedPart("x", wrapper3, Byte.class);
091: assertEquals(arg3, wrapper3.getX());
092:
093: TestByteResponse wrapper4 = new TestByteResponse();
094: byte arg4 = 1;
095: wrapper4.setReturn(arg4);
096: WrapperHelper.getWrappedPart("return", wrapper4, Byte.class);
097: assertEquals(arg4, wrapper4.getReturn());
098: }
099:
100: }
|