1 29 30 package nextapp.echo2.webrender.test; 31 32 import nextapp.echo2.webrender.ServiceRegistry; 33 import junit.framework.TestCase; 34 35 38 public class ServiceRegistryTest extends TestCase { 39 40 43 public void testBasic() { 44 ServiceRegistry services = new ServiceRegistry(); 45 NullService alpha = new NullService("alpha"); 46 services.add(alpha); 47 NullService bravo = new NullService("bravo"); 48 services.add(bravo); 49 assertEquals(alpha, services.get("alpha")); 50 assertEquals(bravo, services.get("bravo")); 51 assertNull(services.get("charlie")); 52 services.remove(bravo); 53 assertNull(services.get("bravo")); 54 } 55 56 59 public void testConflict() { 60 ServiceRegistry services = new ServiceRegistry(); 61 NullService alpha = new NullService("alpha"); 62 services.add(alpha); 63 NullService anotherAlpha = new NullService("alpha"); 64 try { 65 services.add(anotherAlpha); 66 fail(); 67 } catch (IllegalArgumentException ex) { 68 } 70 } 71 72 75 public void testReAdd() { 76 ServiceRegistry services = new ServiceRegistry(); 77 NullService alpha = new NullService("alpha"); 78 services.add(alpha); 79 services.add(alpha); 80 } 81 } 82 | Popular Tags |