KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > jbws720 > JBWS720TestCase


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.jbws720;
23
24 import javax.naming.InitialContext JavaDoc;
25 import javax.xml.rpc.Service JavaDoc;
26 import javax.xml.soap.SOAPElement JavaDoc;
27 import javax.xml.soap.SOAPFactory JavaDoc;
28
29 import junit.framework.Test;
30
31 import org.jboss.test.webservice.WebserviceTestBase;
32
33 /**
34  * Handling of xml:lang and any namespace="##other"
35  * http://jira.jboss.com/jira/browse/JBWS-720
36  *
37  * @author Thomas.Diesler@jboss.org
38  * @since 04-Mar-2006
39  */

40 public class JBWS720TestCase extends WebserviceTestBase
41 {
42    private static TestEndpoint port;
43
44    public JBWS720TestCase(String JavaDoc name)
45    {
46       super(name);
47    }
48
49    /** Deploy the test */
50    public static Test suite() throws Exception JavaDoc
51    {
52       return getDeploySetup(JBWS720TestCase.class, "ws4ee-jbws720.war, ws4ee-jbws720-client.jar");
53    }
54
55    public void setUp() throws Exception JavaDoc
56    {
57       super.setUp();
58       if (port == null)
59       {
60          InitialContext JavaDoc iniCtx = getClientContext();
61          Service JavaDoc service = (Service JavaDoc)iniCtx.lookup("java:comp/env/service/TestService");
62          port = (TestEndpoint)service.getPort(TestEndpoint.class);
63       }
64    }
65
66    public void testLangEmptyAny() throws Exception JavaDoc
67    {
68       GetProperty inObj = new GetProperty();
69       inObj.setStrElement("someElement");
70       inObj.setStrAttr("someAttr");
71       inObj.setLang("en");
72       inObj.set_any(new SOAPElement JavaDoc[] {});
73
74       GetPropertyResponse outObj = port.getProperty(inObj);
75       assertEquals(inObj.toString(), outObj.getResult());
76    }
77
78    public void testEmptyLangEmptyAny() throws Exception JavaDoc
79    {
80       GetProperty inObj = new GetProperty();
81       inObj.setStrElement("someElement");
82       inObj.setStrAttr("someAttr");
83       inObj.set_any(new SOAPElement JavaDoc[] {});
84
85       GetPropertyResponse outObj = port.getProperty(inObj);
86       assertEquals(inObj.toString(), outObj.getResult());
87    }
88
89    public void testLangAnyWithNamespace() throws Exception JavaDoc
90    {
91       SOAPFactory JavaDoc factory = SOAPFactory.newInstance();
92
93       GetProperty inObj = new GetProperty();
94       inObj.setStrElement("someElement");
95       inObj.setStrAttr("someAttr");
96       inObj.setLang("en");
97
98       // test any element with namespace
99
SOAPElement JavaDoc el1 = factory.createElement("el1", "nsany", "http://somens");
100       SOAPElement JavaDoc el2 = factory.createElement("el2", "nsany", "http://somens");
101       inObj.set_any(new SOAPElement JavaDoc[] { el1, el2 });
102
103       GetPropertyResponse outObj = port.getProperty(inObj);
104       assertEquals(inObj.toString(), outObj.getResult());
105    }
106
107    public void testLangAnyWithoutNamespace() throws Exception JavaDoc
108    {
109       SOAPFactory JavaDoc factory = SOAPFactory.newInstance();
110
111       GetProperty inObj = new GetProperty();
112       inObj.setStrElement("someElement");
113       inObj.setStrAttr("someAttr");
114       inObj.setLang("en");
115
116       // test any element without namespace
117
SOAPElement JavaDoc el1 = factory.createElement("el1");
118       SOAPElement JavaDoc el2 = factory.createElement("el2");
119       inObj.set_any(new SOAPElement JavaDoc[] { el1, el2 });
120
121       GetPropertyResponse outObj = port.getProperty(inObj);
122       assertEquals(inObj.toString(), outObj.getResult());
123    }
124
125    public void testAllNull() throws Exception JavaDoc
126    {
127       GetProperty inObj = new GetProperty();
128
129       GetPropertyResponse outObj = port.getProperty(inObj);
130       assertEquals(inObj.toString(), outObj.getResult());
131    }
132 }
133
Popular Tags