1 package test.crispy.server; 2 3 import test.crispy.example.service.Echo; 4 import test.crispy.example.service.EchoImpl; 5 import net.sf.crispy.server.SingleServiceContainer; 6 import net.sf.crispy.server.SingleServiceContainerImpl; 7 import junit.framework.TestCase; 8 9 public class SingleServiceContainerTest extends TestCase { 10 11 public void testServiceSize() throws Exception { 12 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 13 assertEquals(0, lvContainer.getServiceSize()); 14 } 15 16 public void testAddService() throws Exception { 17 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 18 lvContainer.addService(Echo.class.getName(), EchoImpl.class.getName()); 19 assertEquals(1, lvContainer.getServiceSize()); 20 } 21 22 public void testAddService_2() throws Exception { 23 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 24 lvContainer.addService(Echo.class.getName(), new EchoImpl()); 25 assertEquals(1, lvContainer.getServiceSize()); 26 } 27 28 public void testAddService_3() throws Exception { 29 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 30 lvContainer.addService(Echo.class.getName(), new EchoImpl()); 31 lvContainer.addService(Echo.class.getName(), new EchoImpl()); 32 assertEquals(1, lvContainer.getServiceSize()); 33 } 34 35 public void testRemoveService() throws Exception { 36 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 37 lvContainer.addService(Echo.class.getName(), new EchoImpl()); 38 lvContainer.removeService(Echo.class.getName()); 39 assertEquals(0, lvContainer.getServiceSize()); 40 } 41 42 public void testGetService() throws Exception { 43 SingleServiceContainer lvContainer = new SingleServiceContainerImpl(); 44 EchoImpl lvEchoImpl = new EchoImpl(); 45 lvContainer.addService(Echo.class.getName(), lvEchoImpl); 46 assertEquals(lvEchoImpl, lvContainer.getService(Echo.class.getName())); 47 } 48 49 50 }