View Javadoc

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