Package tests.jfun.yan.xml

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

package tests.jfun.yan.xml;

import java.util.HashMap;

import tests.jfun.models.BankAccount;
import jfun.yan.Component;
import jfun.yan.Components;
import jfun.yan.util.resource.ResourceLoader;
public class SimpleTestCase extends BaseConfigurationTest {
  public void test1()
  throws Throwable{

    runTest("test/yan/test.xml");
    final Component c = yan.getComponent("service_maker");
    assertNotNull(c);
    final BankAccount acc = new BankAccount("test", 1000000);
    final Component service =
      c.withArguments(new Component[]{Components.value(acc), Components.value("getBalance")});
    final Integer bal = (Integer)yan.instantiateComponent(service);
    assertEquals(1000000, bal.intValue());
   
    final Component acct_request = yan.getComponent("bankaccount_request");
    final HashMap props = new HashMap();
    props.put("balance", new Integer(6666));
    final Integer result = (Integer)yan.instantiateComponent(
        acct_request.withArgument(0, Components.value(props)));
    assertEquals(6666, result.intValue());
   
    final Component acct_request2 = yan.getComponent("bankaccount_request2");
    final HashMap props2 = new HashMap();
    props.put("balance", new Integer(7777));
    final String result2 = (String)yan.instantiateComponent(
        acct_request2.withArgument(0, Components.value(props2)));
    assertEquals("this is my test", result2);
   
   
  }
  public void test2()
  throws Throwable{
    runTest("test/yan/test2.xml");
    final Object this_container = this.yan.getInstance("this container");
    assertSame(yan, this_container);
    final Object resource_loader = this.yan.getInstance("resource loader");
    assertTrue(resource_loader instanceof ResourceLoader);
  }
  public void testAutowire()
  throws Throwable{
    runTest("test/yan/test_autowire.xml");
  }
  /*
  public void testChinese()
  throws Throwable{
    runTest("test/yan/�Զ�.xml");
  }*/
  public void testWireByname()
  throws Throwable{
    runTest("test/yan/test_wire_by_name.xml");
  }
  public void testOverride()
  throws Throwable{
    runTest("test/yan/test_override.xml");
  }
  public void testAutodetect()
  throws Throwable{
    runTest("test/yan/test_autodetect.xml");
  }
  public void testLookupWiring()
  throws Throwable{
    runTest("test/yan/test_custom_autowiring.xml");
  }
  public void testOrdering()throws Throwable{
    runTest("test/yan/ordering/c.xml");
  }
  public void testEditor()throws Throwable{
    runTest("test/yan/deserializer/test1.xml");
  }
  public void testDeserializer()throws Throwable{
    runTest("test/yan/deserializer/test2.xml");
  }
}
TOP

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

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.