001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ksb.messaging;
017
018 import static org.junit.Assert.assertEquals;
019 import static org.junit.Assert.assertNotNull;
020 import static org.junit.Assert.fail;
021
022 import javax.xml.namespace.QName;
023
024 import org.junit.Test;
025 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
026 import org.kuali.rice.ksb.messaging.remotedservices.EchoService;
027 import org.kuali.rice.ksb.test.KSBTestCase;
028
029
030 public class RemoteFailureTest extends KSBTestCase {
031
032 public boolean startClient1() {
033 return true;
034 }
035
036 @Test public void testEchoService() throws Exception {
037 EchoService echoService = (EchoService)GlobalResourceLoader.getService(new QName("TestCl1", "echoService"));
038 assertNotNull(echoService);
039 String echoValue = "echoValue";
040 String result = echoService.echo(echoValue);
041 assertEquals(echoValue, result);
042
043 // now shut down the test client and try to access the echo service
044 getTestClient1().stop();
045 try {
046 result = echoService.echo(echoValue);
047 fail("Exception should have been thrown");
048 } catch (Exception e) {
049 e.printStackTrace();
050 }
051
052 // start it back up and make sure we can use our service again
053 getTestClient1().start();
054 result = echoService.echo(echoValue);
055 assertEquals(echoValue, result);
056 }
057
058 @Test public void testSOAPEchoService() throws Exception {
059 EchoService echoService = (EchoService) GlobalResourceLoader.getService(new QName("TestCl1", "soap-echoService"));
060 assertNotNull(echoService);
061 String echoValue = "echoValue";
062 String result = echoService.echo(echoValue);
063 assertEquals(echoValue, result);
064 // now shut down the test client and try to access the echo service
065 getTestClient1().stop();
066 try {
067 result = echoService.echo(echoValue);
068 fail("Exception should have been thrown");
069 } catch (Exception e) {
070 e.printStackTrace();
071 }
072 // start it back up and make sure we can use our service again
073 getTestClient1().start();
074 result = echoService.echo(echoValue);
075 assertEquals(echoValue, result);
076 }
077
078 }