View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 org.kuali.rice.ksb.messaging;
17  
18  import javax.xml.namespace.QName;
19  
20  import org.junit.Test;
21  import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
22  import org.kuali.rice.ksb.messaging.remotedservices.EchoService;
23  import org.kuali.rice.ksb.test.KSBTestCase;
24  
25  
26  public class RemoteFailureTest extends KSBTestCase {
27  
28  	public boolean startClient1() {
29  		return true;
30  	}
31  
32  	@Test public void testEchoService() throws Exception {
33  		EchoService echoService = (EchoService)GlobalResourceLoader.getService(new QName("TestCl1", "echoService"));
34  		assertNotNull(echoService);
35  		String echoValue = "echoValue";
36  		String result = echoService.echo(echoValue);
37  		assertEquals(echoValue, result);
38  
39  		// now shut down the test client and try to access the echo service
40  		getTestClient1().stop();
41  		try {
42  			result = echoService.echo(echoValue);
43  			fail("Exception should have been thrown");
44  		} catch (Exception e) {
45  			e.printStackTrace();
46  		}
47  		
48  		// start it back up and make sure we can use our service again
49  		getTestClient1().start();
50  		result = echoService.echo(echoValue);
51  		assertEquals(echoValue, result);
52  	}
53  	
54  	@Test public void testSOAPEchoService() throws Exception {
55  		EchoService echoService = (EchoService)GlobalResourceLoader.getService(new QName("TestCl1", "soap-echoService"));
56  		assertNotNull(echoService);
57  		String echoValue = "echoValue";
58  		String result = echoService.echo(echoValue);
59  		assertEquals(echoValue, result);
60  		// now shut down the test client and try to access the echo service
61  		getTestClient1().stop();
62  		try {
63  			result = echoService.echo(echoValue);
64  			fail("Exception should have been thrown");
65  		} catch (Exception e) {
66  			e.printStackTrace();
67  		}
68  		// start it back up and make sure we can use our service again
69  		getTestClient1().start();
70  		result = echoService.echo(echoValue);
71  		assertEquals(echoValue, result);
72  	}
73  	
74  }