1 package org.sapia.soto; 2 3 import junit.framework.TestCase; 4 5 import org.sapia.soto.examples.MasterService; 6 import org.sapia.soto.examples.SecondaryService; 7 8 import java.util.Properties ; 9 10 11 20 public class ChooseTest extends TestCase { 21 public ChooseTest(String arg0) { 22 super(arg0); 23 } 24 25 public void testOtherwise() throws Exception { 26 SotoContainer cont = new SotoContainer(); 27 cont.load("org/sapia/soto/chooseTest.xml"); 28 29 SecondaryService sec = (SecondaryService) cont.lookup("secondary"); 30 super.assertTrue(sec.hasMaster()); 31 super.assertEquals("3", ((MasterService) sec.getSomeService()).getMessage()); 32 } 33 34 public void testIf() throws Exception { 35 SotoContainer cont = new SotoContainer(); 36 Properties props = new Properties (); 37 props.setProperty("set.master.service", "1"); 38 cont.load("org/sapia/soto/chooseTest.xml", props); 39 40 SecondaryService sec = (SecondaryService) cont.lookup("secondary"); 41 super.assertTrue(sec.hasMaster()); 42 super.assertEquals("1", ((MasterService) sec.getSomeService()).getMessage()); 43 } 44 45 public void testElseif() throws Exception { 46 SotoContainer cont = new SotoContainer(); 47 Properties props = new Properties (); 48 props.setProperty("set.master.service", "2"); 49 cont.load("org/sapia/soto/chooseTest.xml", props); 50 51 SecondaryService sec = (SecondaryService) cont.lookup("secondary"); 52 super.assertTrue(sec.hasMaster()); 53 super.assertEquals("2", ((MasterService) sec.getSomeService()).getMessage()); 54 } 55 } 56 | Popular Tags |