| 1 package org.sapia.magnet.test; 2 3 import org.sapia.corus.interop.Param; 4 import org.sapia.corus.interop.Status; 5 import org.sapia.corus.interop.Context; 6 import org.sapia.corus.interop.client.InteropClient; 7 import org.sapia.corus.interop.http.HttpProtocol; 8 9 import junit.framework.TestCase; 10 11 12 24 public class InteropClientTest extends TestCase { 25 26 29 public InteropClientTest(String aName) { 30 super(aName); 31 } 32 33 public void testShutdown() throws Exception { 34 DummyServer aServer = new DummyServer(); 35 InteropClient.getInstance().setProtocol(new HttpProtocol()); 36 assertTrue("The server is already shutdown", !aServer.isShutdown()); 37 38 InteropClient.getInstance().setExitSystemOnShutdown(false); 39 InteropClient.getInstance().shutdown(); 40 assertTrue("The server is not shutdown", aServer.isShutdown()); 41 } 42 43 public void testStatusRequestAndShudown() throws Exception { 44 DummyServer aServer = new DummyServer(); 45 InteropClient.getInstance().setProtocol(new HttpProtocol()); 46 assertTrue("The server is already shudown", !aServer.isShutdown()); 47 48 Status aStatus = new Status(); 49 InteropClient.getInstance().processStatus(aStatus); 50 assertEquals("", 1, aStatus.getContexts().size()); 51 52 Context aContext = (Context) aStatus.getContexts().get(0); 53 assertEquals("", "DummyServer", aContext.getName()); 54 assertEquals("", 1, aContext.getParams().size()); 55 56 Param anParam = (Param) aContext.getParams().get(0); 57 assertEquals("", "isShutdown", anParam.getName()); 58 assertEquals("", "false", anParam.getValue()); 59 60 InteropClient.getInstance().setExitSystemOnShutdown(false); 61 InteropClient.getInstance().shutdown(); 62 assertTrue("The server is not shudown", aServer.isShutdown()); 63 } 64 65 } 66 | Popular Tags |