1 10 package org.picocontainer.gems; 11 12 import java.rmi.RemoteException ; 13 import java.rmi.registry.LocateRegistry ; 14 import java.rmi.registry.Registry ; 15 16 import org.picocontainer.ComponentAdapter; 17 import org.picocontainer.defaults.DefaultPicoContainer; 18 19 import junit.framework.TestCase; 20 21 24 public class StaticFactoryComponentAdapterTestCase 25 extends TestCase { 26 27 public void testStaticFactoryInAction() { 28 ComponentAdapter componentAdapter = 29 new StaticFactoryComponentAdapter(Registry .class, 30 new StaticFactory() { 31 public Object get() { 32 try { 33 return LocateRegistry.getRegistry(); 34 } catch (RemoteException e) { 35 return null; 36 } 37 } 38 }); 39 40 DefaultPicoContainer pico = new DefaultPicoContainer(); 41 pico.registerComponent(componentAdapter).verify(pico); 42 Registry registry = (Registry )pico.getComponentInstance(Registry .class); 43 assertNotNull(registry); 44 } 45 } 46 | Popular Tags |