1 package org.sapia.soto; 2 3 import junit.framework.TestCase; 4 5 6 15 public class SotoContainerTest extends TestCase { 16 public SotoContainerTest(String arg0) { 17 super(arg0); 18 } 19 20 public void testInit() throws Exception { 21 SotoContainer cont = new SotoContainer(); 22 cont.load("org/sapia/soto/singleService.xml"); 23 24 TestService svc = (TestService) cont.lookup("some/service"); 25 super.assertTrue("Service was not initialized", svc.init); 26 super.assertTrue("Service should not be in started mode", !svc.started); 27 } 28 29 public void testStart() throws Exception { 30 SotoContainer cont = new SotoContainer(); 31 cont.load("org/sapia/soto/singleService.xml"); 32 cont.start(); 33 34 TestService svc = (TestService) cont.lookup("some/service"); 35 super.assertTrue("Service was not started", svc.started); 36 } 37 38 public void testDispose() throws Exception { 39 SotoContainer cont = new SotoContainer(); 40 cont.load("org/sapia/soto/singleService.xml"); 41 cont.start(); 42 43 TestService svc = (TestService) cont.lookup("some/service"); 44 cont.dispose(); 45 super.assertTrue("Service was not stopped", svc.disposed); 46 } 47 48 public void testBind() throws Exception { 49 SotoContainer cont = new SotoContainer(); 50 51 try { 52 cont.load("org/sapia/soto/duplicateService.xml"); 53 throw new Exception ("Two services with same ID should not be allowed"); 54 } catch (Exception e) { 55 } 57 } 58 59 public void testAssociation() throws Exception { 60 SotoContainer cont = new SotoContainer(); 61 cont.load("org/sapia/soto/association.xml"); 62 cont.start(); 63 64 TestService svc = (TestService) cont.lookup("some/service"); 65 super.assertTrue("Associated service is null", svc.child != null); 66 svc = (TestService) cont.lookup("some/other/service"); 67 super.assertTrue("Associated service is null", svc.child != null); 68 } 69 70 public void testLayer() throws Exception { 71 SotoContainer cont = new SotoContainer(); 72 cont.load("org/sapia/soto/layer.xml"); 73 super.assertTrue("Layer not initialized", TestLayer.init); 74 cont.start(); 75 super.assertTrue("Layer not started", TestLayer.started); 76 } 77 } 78 | Popular Tags |