1 package tests.jfun.yan.xml; 2 3 import java.io.IOException ; 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import tests.jfun.yan.xml.nuts.Listener; 8 9 import jfun.yan.Container; 10 import jfun.yan.lifecycle.DefaultLifecycleManager; 11 import jfun.yan.xml.NutsProcessor; 12 import junit.framework.TestCase; 13 14 public class DeclarativenessPluginTestCase extends TestCase { 15 private DefaultLifecycleManager manager; 16 private Container yan; 17 private NutsProcessor interpreter; 18 protected void setUp() throws Exception { 19 super.setUp(); 20 interpreter = new NutsProcessor(); 21 interpreter.registerService("echo_msg", "there ya go:"); 22 yan = interpreter.getContainer(); 23 manager = interpreter.getLifecycleManager(); 24 } 25 26 protected void tearDown() throws Exception { 27 super.tearDown(); 29 } 30 31 public void test1() 32 throws IOException { 33 final ArrayList cache = new ArrayList (); 34 final Listener l = new Listener(){ 35 public void onInstance(Object obj){ 36 cache.add(obj); 37 } 38 }; 39 final NutsProcessor meta = interpreter.createMetaInterpreter(); 40 meta.getContainer().registerValue(l); 41 meta.processResource("tests/jfun/yan/xml/nuts/listeners.xml"); 42 interpreter.loadNutsFromContainer(meta.getContainer()); 43 interpreter.processFile("test/yan/test_pluggable_declarativeness.xml"); 44 final List instances = yan.getInstances(); 45 assertEquals(1, cache.size()); 46 assertSame(cache.get(0), instances.get(0)); 47 assertSame(cache.get(0), instances.get(2)); 48 } 49 } 50 | Popular Tags |