1 22 package org.objectweb.petals.kernel.registry; 23 24 import java.lang.reflect.Method ; 25 import java.util.HashMap ; 26 import java.util.Map ; 27 28 import junit.framework.TestCase; 29 30 import org.easymock.classextension.EasyMock; 31 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 32 import org.objectweb.petals.kernel.registry.msg.response.ExceptionResponse; 33 import org.objectweb.petals.util.LoggingUtil; 34 35 40 public class RegistryServerTest extends TestCase { 41 42 public void testProcessResponseException() { 43 RegistryServer server = new RegistryServer(); 44 ExceptionResponse exceptionResponse = new ExceptionResponse( 45 new RuntimeException (), 0, 0); 46 assertNull(server.processResponse(exceptionResponse)); 47 } 48 49 public void testSetData() { 50 RegistryServer server = new RegistryServer(); 51 Map <String , Map <String , Object >> map = new HashMap <String , Map <String , Object >>(); 52 server.setData(map); 53 assertEquals(server.getData(), map); 54 } 55 56 public void testStart() throws SecurityException , NoSuchMethodException , 57 IllegalLifeCycleException { 58 RegistryServer server = EasyMock.createMock(RegistryServer.class, 59 new Method [] {RegistryServer.class.getDeclaredMethod("startServer", 60 new Class [0])}); 61 LoggingUtil loggingUtil = EasyMock.createMock(LoggingUtil.class); 62 63 loggingUtil.call(); 64 server.startServer(); 65 66 EasyMock.replay(loggingUtil); 67 EasyMock.replay(server); 68 69 server.log = loggingUtil; 70 71 server.start(); 72 } 73 74 public void testStop() throws SecurityException , NoSuchMethodException , 75 IllegalLifeCycleException { 76 RegistryServer server = EasyMock.createMock(RegistryServer.class, 77 new Method [] {RegistryServer.class.getDeclaredMethod("stopServer", 78 new Class [0])}); 79 LoggingUtil loggingUtil = EasyMock.createMock(LoggingUtil.class); 80 81 loggingUtil.start(); 82 server.stopServer(); 83 loggingUtil.end(); 84 85 EasyMock.replay(loggingUtil); 86 EasyMock.replay(server); 87 88 server.log = loggingUtil; 89 90 server.stop(); 91 } 92 93 } 94 | Popular Tags |