KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > jbws163 > JBWS163TestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.webservice.jbws163;
23
24 import junit.framework.Test;
25 import org.jboss.test.webservice.WebserviceTestBase;
26
27 import javax.naming.InitialContext JavaDoc;
28 import javax.xml.rpc.Service JavaDoc;
29 import javax.xml.rpc.holders.BigIntegerHolder JavaDoc;
30 import javax.xml.rpc.holders.IntHolder JavaDoc;
31 import javax.xml.rpc.holders.LongHolder JavaDoc;
32 import javax.xml.rpc.holders.ShortHolder JavaDoc;
33 import java.math.BigInteger JavaDoc;
34
35 /** Test IN, INOUT, OUT of unsignedLong, etc.
36  *
37  * http://jira.jboss.com/jira/browse/JBWS-163
38  *
39  * @author Thomas.Diesler@jboss.org
40  * @since 09-Jun-2005
41  */

42 public class JBWS163TestCase extends WebserviceTestBase
43 {
44    private static Hello hello;
45
46    /** Construct the test case with a given name
47     */

48    public JBWS163TestCase(String JavaDoc name)
49    {
50       super(name);
51    }
52
53    /** Deploy the test */
54    public static Test suite() throws Exception JavaDoc
55    {
56       return getDeploySetup(JBWS163TestCase.class, "ws4ee-jbws163.war, ws4ee-jbws163-client.jar");
57    }
58
59    protected void setUp() throws Exception JavaDoc
60    {
61       super.setUp();
62
63       if (hello == null)
64       {
65          InitialContext JavaDoc iniCtx = getClientContext();
66          Service JavaDoc service = (Service JavaDoc)iniCtx.lookup("java:comp/env/service/HelloService");
67          hello = (Hello)service.getPort(Hello.class);
68       }
69    }
70
71    public void testNonPositiveInteger() throws Exception JavaDoc
72    {
73       BigInteger JavaDoc argIN = new BigInteger JavaDoc("-100");
74       BigIntegerHolder JavaDoc argINOUT = new BigIntegerHolder JavaDoc(new BigInteger JavaDoc("-200"));
75       BigIntegerHolder JavaDoc argOUT = new BigIntegerHolder JavaDoc();
76       hello.nonPositiveInteger(argIN, argINOUT, argOUT);
77       assertEquals(argINOUT.value, argIN);
78       assertEquals(argOUT.value, argIN);
79    }
80
81    public void testNegativeInteger() throws Exception JavaDoc
82    {
83       BigInteger JavaDoc argIN = new BigInteger JavaDoc("-100");
84       BigIntegerHolder JavaDoc argINOUT = new BigIntegerHolder JavaDoc(new BigInteger JavaDoc("-200"));
85       BigIntegerHolder JavaDoc argOUT = new BigIntegerHolder JavaDoc();
86       hello.negativeInteger(argIN, argINOUT, argOUT);
87       assertEquals(argINOUT.value, argIN);
88       assertEquals(argOUT.value, argIN);
89    }
90
91    public void testNonNegativeInteger() throws Exception JavaDoc
92    {
93       BigInteger JavaDoc argIN = new BigInteger JavaDoc("100");
94       BigIntegerHolder JavaDoc argINOUT = new BigIntegerHolder JavaDoc(new BigInteger JavaDoc("200"));
95       BigIntegerHolder JavaDoc argOUT = new BigIntegerHolder JavaDoc();
96       hello.nonNegativeInteger(argIN, argINOUT, argOUT);
97       assertEquals(argINOUT.value, argIN);
98       assertEquals(argOUT.value, argIN);
99    }
100
101    public void testUnsignedLong() throws Exception JavaDoc
102    {
103       BigInteger JavaDoc argIN = new BigInteger JavaDoc("100");
104       BigIntegerHolder JavaDoc argINOUT = new BigIntegerHolder JavaDoc(new BigInteger JavaDoc("200"));
105       BigIntegerHolder JavaDoc argOUT = new BigIntegerHolder JavaDoc();
106       hello.unsignedLong(argIN, argINOUT, argOUT);
107       assertEquals(argINOUT.value, argIN);
108       assertEquals(argOUT.value, argIN);
109    }
110
111    public void testPositiveInteger() throws Exception JavaDoc
112    {
113       BigInteger JavaDoc argIN = new BigInteger JavaDoc("100");
114       BigIntegerHolder JavaDoc argINOUT = new BigIntegerHolder JavaDoc(new BigInteger JavaDoc("200"));
115       BigIntegerHolder JavaDoc argOUT = new BigIntegerHolder JavaDoc();
116       hello.positiveInteger(argIN, argINOUT, argOUT);
117       assertEquals(argINOUT.value, argIN);
118       assertEquals(argOUT.value, argIN);
119    }
120
121    public void testUnsignedInt() throws Exception JavaDoc
122    {
123       long argIN = 100;
124       LongHolder JavaDoc argINOUT = new LongHolder JavaDoc(200);
125       LongHolder JavaDoc argOUT = new LongHolder JavaDoc();
126       hello.unsignedInt(argIN, argINOUT, argOUT);
127       assertEquals(argINOUT.value, argIN);
128       assertEquals(argOUT.value, argIN);
129    }
130
131    public void testUnsignedShort() throws Exception JavaDoc
132    {
133       int argIN = 100;
134       IntHolder JavaDoc argINOUT = new IntHolder JavaDoc(200);
135       IntHolder JavaDoc argOUT = new IntHolder JavaDoc();
136       hello.unsignedShort(argIN, argINOUT, argOUT);
137       assertEquals(argINOUT.value, argIN);
138       assertEquals(argOUT.value, argIN);
139    }
140
141    public void testUnsignedByte() throws Exception JavaDoc
142    {
143       short argIN = 100;
144       ShortHolder JavaDoc argINOUT = new ShortHolder JavaDoc((short)200);
145       ShortHolder JavaDoc argOUT = new ShortHolder JavaDoc();
146       hello.unsignedByte(argIN, argINOUT, argOUT);
147       assertEquals(argINOUT.value, argIN);
148       assertEquals(argOUT.value, argIN);
149    }
150 }
151
Popular Tags