Package jfun.yan

Examples of jfun.yan.Container.verify()


      }
     
      yan.registerComponent("use_badtype",
          Components.useType(char.class));
      try{
        yan.verify();
        fail("should have failed with UnresolvedComponentException");
      }
      catch(UnresolvedComponentException e){
        assertEquals(char.class, e.getComponentKey());
        yan.unregisterComponent("use_badtype");
View Full Code Here


    public void testUseAll(){
      final Container yan = createYanContainer();
      yan.registerComponent("target", Components.useAll(String.class));
      yan.registerValue("abc");
      yan.registerValue("yet another", "cde");
      yan.verify();
      final java.util.List strs = (java.util.List)yan.getInstance("target");
      assertEquals(2, strs.size());
      assertEquals("abc", strs.get(0));
      assertEquals("cde", strs.get(1));
    }
View Full Code Here

      final Container yan = createYanContainer();
      yan.registerComponent(
          Components.returnState(Components.useKey("xxx").withState("hello")
          )
      );
      yan.verify();
      assertEquals("hello", yan.getInstance(Object.class));
    }
    public void testReturnType(){
      final Container yan = createYanContainer();
      yan.registerComponent(Class.class,
View Full Code Here

    public void testReturnType(){
      final Container yan = createYanContainer();
      yan.registerComponent(Class.class,
          Components.returnType(Components.useKey("xxx").cast(String.class))
      );
      yan.verify();
      assertEquals(String.class, yan.getInstance(Class.class));
    }
    public void testReturnVerification(){
      final Container yan = createYanContainer();
      yan.registerComponent(Class.class,
View Full Code Here

      final Container yan = createYanContainer();
      yan.registerComponent(Class.class,
          Components.returnVerification(Components.useKey("xxx").cast(String.class))
      );
      try{
        yan.verify();
        fail("should have failed with UnresolvedComponentException");
      }
      catch(UnresolvedComponentException e){
        //e.printResolutionTrace(System.err);
        assertTraceSize(e, 4);
View Full Code Here

        assertEntry(e, 3, "getInstance <class java.lang.Class>");
        assertEquals("xxx", e.getComponentKey());
      }
      yan.registerValue("xxx",
          Components.useKey("bad").subsume(int.class).incomplete());
      yan.verify();
      assertEquals(String.class, yan.getInstance(Class.class));
    }


    private void run_testBadUseContainerForProperties(Container yan1, Container yan2){
View Full Code Here

          .optionalProperties()
          .withDefaultProperty("cat", Components.value("Chopin"))
          ));
     
      yan.registerComponent("civilian2", Beans.byName(Components.useKey("civilian")));
      yan.verify();
      Civilian civ = (Civilian)yan.getInstance("civilian");
      assertEquals("Bach", civ.getDog());
      assertEquals("Chopin", civ.getCat());
      assertEquals("do not need", civ.getWife());
      assertEquals(-1, civ.getId());
View Full Code Here

            .bean()
            .optionalProperties()
            ));
       
        yan.registerComponent("civilian2", Beans.byQualifiedName(Components.useKey("civilian")));
        yan.verify();
        Civilian civ = (Civilian)yan.getInstance("civilian");
        assertEquals("Bach", civ.getDog());
        assertEquals("Chopin", civ.getCat());
        assertEquals("do not need", civ.getWife());
        assertEquals(-1, civ.getId());
View Full Code Here

    }
    public void testMonadPlus(){
      final Container yan = createYanContainer();
      yan.registerComponent("a", Monad.mzero());
      try{
        yan.verify();
        fail("should have failed with ComponentResolutionException");
      }
      catch(ComponentResolutionException e){
        assertTraceSize(e, 2);
        assertEntry(e, 0, "fail <mzero>");
View Full Code Here

      final Component use1 = Components.useProperty(String.class, "prop1", String.class)
        .withProperty("prop1", Components.value("hello"));
      final Container yan = createYanContainer();
      yan.registerComponent("target", use1);
      try{
        yan.verify();
      }
      catch(YanException e){
        assertTraceSize(e, 2);
        //e.printResolutionTrace();
        assertEquals("useProperty can only be used for parameter or property",
View Full Code Here

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.