コード例 #1
0
 public void testInjectDependency() throws Exception {
   ComponentDefImpl cd = new ComponentDefImpl(HashMap.class);
   InitMethodDef md = new InitMethodDefImpl("put");
   md.addArgDef(new ArgDefImpl("aaa"));
   md.addArgDef(new ArgDefImpl("hoge"));
   cd.addInitMethodDef(md);
   ComponentDeployer deployer = new OuterComponentDeployer(cd);
   HashMap myMap = new HashMap();
   deployer.injectDependency(myMap);
   assertEquals("1", "hoge", myMap.get("aaa"));
 }
コード例 #2
0
 public void testGetComponentForMethodDef() throws Exception {
   S2Container container = new S2ContainerImpl();
   ComponentDefImpl cd = new ComponentDefImpl(HashMap.class, "myMap");
   InitMethodDef md = new InitMethodDefImpl("put");
   md.addArgDef(new ArgDefImpl("aaa"));
   md.addArgDef(new ArgDefImpl("hoge"));
   cd.addInitMethodDef(md);
   container.register(cd);
   HashMap myMap = (HashMap) container.getComponent("myMap");
   assertEquals("1", "hoge", myMap.get("aaa"));
 }
コード例 #3
0
 public void testInjectDependency2() throws Exception {
   ComponentDefImpl cd = new ComponentDefImpl(ArrayMap.class);
   InitMethodDef md = new InitMethodDefImpl("put");
   md.addArgDef(new ArgDefImpl("aaa"));
   md.addArgDef(new ArgDefImpl("hoge"));
   cd.addInitMethodDef(md);
   ComponentDeployer deployer = new OuterComponentDeployer(cd);
   Map myMap = new CaseInsensitiveMap();
   deployer.injectDependency(myMap);
   assertEquals("1", "hoge", myMap.get("aaa"));
   try {
     Map myMap2 = new HashMap();
     deployer.injectDependency(myMap2);
     fail("1");
   } catch (ClassUnmatchRuntimeException ex) {
     System.out.println(ex);
   }
 }