KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > jbws64 > JBWS64TestCase


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.jbws64;
23
24 import junit.framework.Test;
25 import org.jboss.test.JBossTestCase;
26
27 import javax.xml.soap.MessageFactory JavaDoc;
28 import javax.xml.soap.SOAPBody JavaDoc;
29 import javax.xml.soap.SOAPConnection JavaDoc;
30 import javax.xml.soap.SOAPConnectionFactory JavaDoc;
31 import javax.xml.soap.SOAPElement JavaDoc;
32 import javax.xml.soap.SOAPMessage JavaDoc;
33 import java.io.ByteArrayInputStream JavaDoc;
34
35 /**
36  * Axis-1.2RC2 client may send messages like this
37  *
38  * <soapenv:Envelope>
39  * <soapenv:Body>
40  * <publish xmlns="http://webservices.est.useme.etish.com">
41  * <in0 xmlns="">joel</in0>
42  * <in1 xmlns="">secret</in1>
43  * <in2 xmlns="">1</in2>
44  * <in3 xmlns="">6</in3>
45  * <in4 xmlns="">2</in4>
46  * </publish>
47  * </soapenv:Body>
48  * </soapenv:Envelope>
49  *
50  * http://jira.jboss.com/jira/browse/JBWS-64
51  *
52  * @author Thomas.Diesler@jboss.org
53  * @since 08-Feb-2005
54  */

55 public class JBWS64TestCase extends JBossTestCase
56 {
57    /** Construct the test case with a given name
58     */

59    public JBWS64TestCase(String JavaDoc name)
60    {
61       super(name);
62    }
63
64    /** Deploy the test */
65    public static Test suite() throws Exception JavaDoc
66    {
67       return getDeploySetup(JBWS64TestCase.class, "ws4ee-jbws64.war");
68    }
69
70    /**
71     * Test JSE endpoint
72     */

73    public void testEndpoint() throws Exception JavaDoc
74    {
75       String JavaDoc reqMsgStr =
76               "<soapenv:Envelope" +
77               " xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'" +
78               " xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
79               " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
80               " <soapenv:Body>" +
81               " <publish xmlns='http://org.jboss.test.webservice/jbws64'>" +
82               " <String_1 xmlns=''>joel</String_1>" +
83               " <String_2 xmlns=''>secret</String_2>" +
84               " <String_3 xmlns=''>1</String_3>" +
85               " <String_4 xmlns=''>6</String_4>" +
86               " <String_5 xmlns=''>2</String_5>" +
87               " </publish>" +
88               " </soapenv:Body>" +
89               "</soapenv:Envelope>";
90
91       MessageFactory JavaDoc msgFactory = MessageFactory.newInstance();
92       SOAPMessage JavaDoc reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream JavaDoc(reqMsgStr.getBytes()));
93
94       SOAPConnectionFactory JavaDoc factory = SOAPConnectionFactory.newInstance();
95       SOAPConnection JavaDoc con = factory.createConnection();
96       SOAPMessage JavaDoc resMsg = con.call(reqMsg, "http://" + getServerHost() + ":8080/ws4ee-jbws64");
97
98       SOAPBody JavaDoc soapBody = resMsg.getSOAPBody();
99       SOAPElement JavaDoc soapBodyElement = (SOAPElement JavaDoc)soapBody.getChildElements().next();
100       SOAPElement JavaDoc soapElement = (SOAPElement JavaDoc)soapBodyElement.getChildElements().next();
101       assertEquals("joel,secret,1,6,2", soapElement.getValue());
102    }
103 }
104
Popular Tags