Debian Codegraph @

test/httpunit/JwsTest.java

raw
1 /*
2 * Copyright 2002-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 package test.httpunit;
19
20 import com.meterware.httpunit.WebRequest;
21 import com.meterware.httpunit.GetMethodWebRequest;
22 import com.meterware.httpunit.WebResponse;
23
24 /**
25 * test for JWS pages being processed
26 * @author Steve Loughran
27 * @created Jul 10, 2002 12:09:20 AM
28 */
29
30 public class JwsTest extends HttpUnitTestBase {
31
32 public JwsTest(String name) {
33 super(name);
34 }
35
36 public void testStockQuote() throws Exception {
37 WebRequest request = new GetMethodWebRequest(url+"/StockQuoteService.jws?wsdl");
38 assertStringInBody(request,"<wsdl:definitions");
39 }
40
41 public void testEchoHeadersWsdl() throws Exception {
42 WebRequest request = new GetMethodWebRequest(url + "/EchoHeaders.jws?wsdl");
43 assertStringInBody(request, "<wsdl:definitions");
44 }
45
46
47 public void testEchoHeaders() throws Exception {
48 WebRequest request = new GetMethodWebRequest(url + "/EchoHeaders.jws");
49 assertStringInBody(request, "Web Service");
50 }
51
52 /**
53 * see that we get a hello back
54 * @throws Exception
55 */
56 public void testEchoHeadersWhoami() throws Exception {
57 WebRequest request = new GetMethodWebRequest(url
58 + "/EchoHeaders.jws");
59 request.setParameter("method", "whoami");
60 assertStringInBody(request, "Hello");
61 }
62
63 /**
64 * do we get a list of headers back?
65 * @throws Exception
66 */
67 public void testEchoHeadersList() throws Exception {
68 WebRequest request = new GetMethodWebRequest(url
69 + "/EchoHeaders.jws");
70 request.setHeaderField("x-header","echo-header-test");
71 request.setParameter("method", "list");
72 assertStringInBody(request, "echo-header-test");
73 }
74
75 /**
76 * send an echo with a space down
77 * @throws Exception
78 */
79 public void testEchoHeadersEcho() throws Exception {
80 WebRequest request = new GetMethodWebRequest(url
81 + "/EchoHeaders.jws");
82 request.setParameter("method","echo");
83 request.setParameter("param", "foo bar");
84 assertStringInBody(request, "foo bar");
85 }
86
87 /**
88 * we throw an error on missing JWS pages
89 * @throws Exception
90 */
91 public void testMissingJWSRaisesException() throws Exception {
92 WebRequest request = new GetMethodWebRequest(url
93 + "/EchoHeaders-not-really-there.jws");
94 expectErrorCode(request,404, "No service");
95 }
96
97 /**
98 * axis faults.
99 * @throws Exception
100 */
101 public void testAxisFaultIsXML() throws Exception {
102 WebRequest request = new GetMethodWebRequest(url
103 + "/EchoHeaders.jws");
104 request.setParameter("method", "throwAxisFault");
105 request.setParameter("param", "oops!");
106 expectErrorCode(request, 500,
107 "<faultcode>soapenv:Server.generalException</faultcode>");
108 }
109
110 /**
111 * exceptions are user faults
112 * @throws Exception
113 */
114 public void testExceptionIsXML() throws Exception {
115 WebRequest request = new GetMethodWebRequest(url
116 + "/EchoHeaders.jws");
117 request.setParameter("method", "throwAxisFault");
118 request.setParameter("param", "oops!");
119 expectErrorCode(request, 500,
120 "<faultcode>soapenv:Server.userException</faultcode>");
121 }
122
123 /**
124 *
125 */
126
127 /**
128 * send a complex unicode round the loop and see what happens
129 * @throws Exception
130 */
131 /* this is failing but it may be in the test code
132 public void testEchoHeadersEchoUnicode() throws Exception {
133 WebRequest request = new GetMethodWebRequest(url
134 + "/EchoHeaders.jws");
135 request.setParameter("method", "echo");
136 request.setParameter("param", "\u221a");
137 assertStringInBody(request, "\u221a");
138 }
139 */
140
141 }