KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > oneway > OnewayTestCase


1 /*
2  * Copyright 2001-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 package test.wsdl.oneway;
17
18 import junit.framework.AssertionFailedError;
19 import junit.framework.TestCase;
20
21 import javax.xml.rpc.ServiceException JavaDoc;
22 import javax.xml.rpc.Stub JavaDoc;
23 import java.rmi.RemoteException JavaDoc;
24
25 /**
26 * This tests various oneway operation features.
27 */

28
29 public class OnewayTestCase extends TestCase {
30     public OnewayTestCase(String JavaDoc name) {
31         super(name);
32     }
33
34     /**
35      * Sessions shouldn't work with oneway operations, so the call to getAddressFromName
36      * should return null.
37      */

38     public void test1NoSessionOnOneway() {
39         Oneway binding;
40         try {
41             binding = new OnewayServiceLocator().getOneway();
42         }
43         catch (ServiceException JavaDoc jre) {
44             throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
45         }
46         assertTrue("binding is null", binding != null);
47
48         try {
49             ((Stub JavaDoc) binding)._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, new Boolean JavaDoc(true));
50             binding.addEntry("hi", new Address());
51             Address address = binding.getAddressFromName("hi");
52             assertTrue("session doesn't work on oneway operations, address should have been null", address == null);
53         }
54         catch (RemoteException JavaDoc re) {
55             throw new AssertionFailedError("Remote Exception caught: " + re);
56         }
57     }
58
59     /**
60      * binding.throwException will cause the server impl to throw an exception,
61      * but since this is a oneway operation, that exception should not propagate
62      * back to the client.
63      */

64     public void test2NoExceptionOnOneway() {
65         Oneway binding;
66         try {
67             binding = new OnewayServiceLocator().getOneway();
68         }
69         catch (ServiceException JavaDoc jre) {
70             throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
71         }
72         assertTrue("binding is null", binding != null);
73
74         try {
75             binding.throwException();
76         }
77         catch (Throwable JavaDoc t) {
78             throw new AssertionFailedError("Throwable: " + t);
79         }
80     }
81
82 }
83
Popular Tags