Package tests.jfun.yan.xml

Source Code of tests.jfun.yan.xml.DeclarativenessPluginTestCase

package tests.jfun.yan.xml;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import tests.jfun.yan.xml.nuts.Listener;

import jfun.yan.Container;
import jfun.yan.lifecycle.DefaultLifecycleManager;
import jfun.yan.xml.NutsProcessor;
import junit.framework.TestCase;

public class DeclarativenessPluginTestCase extends TestCase {
  private DefaultLifecycleManager manager;
  private Container yan;
  private NutsProcessor interpreter;
  protected void setUp() throws Exception {
    super.setUp();
    interpreter = new NutsProcessor();
    interpreter.registerService("echo_msg", "there ya go:");
    yan = interpreter.getContainer();
    manager = interpreter.getLifecycleManager();
  }

  protected void tearDown() throws Exception {
    // TODO Auto-generated method stub
    super.tearDown();
  }
 
  public void test1()
  throws IOException{
    final ArrayList cache = new ArrayList();
    final Listener l = new Listener(){
      public void onInstance(Object obj){
        cache.add(obj);
      }
    };
    final NutsProcessor meta = interpreter.createMetaInterpreter();
    meta.getContainer().registerValue(l);
    meta.processResource("tests/jfun/yan/xml/nuts/listeners.xml");
    interpreter.loadNutsFromContainer(meta.getContainer());
    interpreter.processFile("test/yan/test_pluggable_declarativeness.xml");
    final List instances = yan.getInstances();
    assertEquals(1, cache.size());
    assertSame(cache.get(0), instances.get(0));
    assertSame(cache.get(0), instances.get(2));
  }
}
TOP

Related Classes of tests.jfun.yan.xml.DeclarativenessPluginTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.