Package org.nutz.ioc

Examples of org.nutz.ioc.IocLoader


public class AopJsonIocTest {

  @Test
  public void test_simple() {
    IocLoader il = new JsonLoader("org/nutz/ioc/json/aop.js");
    Ioc ioc = new NutIoc(il);
    StringBuilder sb = ioc.get(StringBuilder.class, "sb");
    Mammal fox = ioc.get(Mammal.class, "fox");

    assertEquals("Fox", fox.getName());
View Full Code Here


    assertTrue(f == f.getAnother());
  }

  @Test
  public void test_null_json_file() {
    IocLoader loader = new JsonLoader("org/nutz/ioc/json/empty.js");
    Ioc ioc = new NutIoc(loader);
    assertEquals(0, ioc.getNames().length);
  }
View Full Code Here

    ioc.get(Animal.class, "f3");
  }

  @Test
  public void test_load_from_dir() throws ObjectLoadException {
    IocLoader loader = new JsonLoader("org/nutz/ioc/json/");
    assertTrue(loader.getName().length > 0);
  }
View Full Code Here

    assertTrue(loader.getName().length > 0);
  }

  @Test
  public void test_load_from_reader() throws ObjectLoadException {
    IocLoader loader = new JsonLoader(Streams.fileInr("org/nutz/ioc/json/main.js"));
    assertTrue(loader.getName().length > 0);
  }
View Full Code Here

    return new XmlIocLoader(fileName);
  }

  @Test
  public void testXmlIocLoader() throws ObjectLoadException {
    IocLoader iocLoader = getNew("org/nutz/ioc/loader/xml/conf/zzh-offered.xml");
    assertTrue(iocLoader.getName() != null);
    assertTrue(iocLoader.getName().length > 0);

    for (String name : iocLoader.getName()) {
      assertNotNull(name);
      assertNotNull(iocLoader.load(null, name));
      IocObject iocObject = iocLoader.load(null, name);
      if (iocObject.hasArgs()) {
        for (IocValue iocValue : iocObject.getArgs()) {
          iocValue.getType();
          iocValue.getValue();
          checkValue(iocValue);
        }
      }
      if (iocObject.getFields() != null) {
        for (IocField iocField : iocObject.getFields()) {
          assertNotNull(iocField.getName());
          if (iocField.getValue() != null) {
            IocValue iocValue = iocField.getValue();
            checkValue(iocValue);
          }
        }
      }
    }
    iocLoader.load(null, "obj").getFields()[0].getValue().getValue();
  }
View Full Code Here

public class AopJsonIocTest {

    @Test
    public void test_simple() {
        IocLoader il = new JsonLoader("org/nutz/ioc/json/aop.js");
        Ioc ioc = new NutIoc(il);
        StringBuilder sb = ioc.get(StringBuilder.class, "sb");
        Mammal fox = ioc.get(Mammal.class, "fox");

        assertEquals("Fox", fox.getName());
View Full Code Here

import org.nutz.lang.Lang;

public class PojoTest {

  public static void main(String[] args) {
    IocLoader loader = new JsonLoader("ioc.js");
    Ioc ioc = new NutIoc(loader);
    Pet pet = ioc.get(Pet.class, "pet");
    System.out.println(pet.getName());
  }
View Full Code Here

public class AopJsonIocTest {

    @Test
    public void test_simple() {
      DefaultClassDefiner.reset();
        IocLoader il = new JsonLoader("org/nutz/ioc/json/aop.js");
        Ioc ioc = new NutIoc(il);
        StringBuilder sb = ioc.get(StringBuilder.class, "sb");
        Mammal fox = ioc.get(Mammal.class, "fox");

        assertEquals("Fox", fox.getName());
View Full Code Here

        return new XmlIocLoader(fileName);
    }

    @Test
    public void testXmlIocLoader() throws ObjectLoadException {
        IocLoader iocLoader = getNew("org/nutz/ioc/loader/xml/conf/zzh-offered.xml");
        assertTrue(iocLoader.getName() != null);
        assertTrue(iocLoader.getName().length > 0);

        for (String name : iocLoader.getName()) {
            assertNotNull(name);
            assertNotNull(iocLoader.load(null, name));
            IocObject iocObject = iocLoader.load(null, name);
            if (iocObject.hasArgs()) {
                for (IocValue iocValue : iocObject.getArgs()) {
                    iocValue.getType();
                    iocValue.getValue();
                    checkValue(iocValue);
                }
            }
            if (iocObject.getFields() != null) {
                for (IocField iocField : iocObject.getFields()) {
                    assertNotNull(iocField.getName());
                    if (iocField.getValue() != null) {
                        IocValue iocValue = iocField.getValue();
                        checkValue(iocValue);
                    }
                }
            }
        }
        iocLoader.load(null, "obj").getFields()[0].getValue().getValue();
    }
View Full Code Here

        assertTrue(f == f.getAnother());
    }

    @Test
    public void test_null_json_file() {
        IocLoader loader = new JsonLoader("org/nutz/ioc/json/empty.js");
        Ioc ioc = new NutIoc(loader);
        assertEquals(0, ioc.getNames().length);
    }
View Full Code Here

TOP

Related Classes of org.nutz.ioc.IocLoader

Copyright © 2018 www.massapicom. 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.