Package tests.jfun.yan.testmodel

Examples of tests.jfun.yan.testmodel.ICacheFactory


          new Class[]{String.class, int.class});
   
    final Component factory =
      mycache.factory(ICacheFactory.class);
    yan.registerComponent("target", factory);
    final ICacheFactory ifactory =
      (ICacheFactory)yan.getInstance("target");
    final tests.jfun.yan.testmodel.ICache icache = ifactory.createCache("tom", 10);
    assertEquals(MyCache.class, icache.getClass());
    assertEquals("tom", icache.getName());
    assertEquals(10, icache.getCapacity());
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      assertTraceSize(e, 3);
      assertEntry(e, 1, "tests.jfun.yan.testmodel.ICacheFactory");
      assertEquals(0, e.getOrdinalPosition());
      assertEquals(String.class, e.getParameterType());
    }
    yan.registerValue("someone");
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      assertTraceSize(e, 3);
      assertEntry(e, 1, "tests.jfun.yan.testmodel.ICacheFactory");
      assertEquals(1, e.getOrdinalPosition());
      assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue(new Integer(0));
    yan.verify();
   
    final tests.jfun.yan.testmodel.ICache icache2 = ifactory.createCache("jack", 11);
    assertEquals(MyCache.class, icache2.getClass());
    assertEquals("jack", icache2.getName());
    assertEquals(11, icache2.getCapacity());
   
    final tests.jfun.yan.testmodel.ICache icache3 = ifactory.createCache();
    assertEquals(MyCache.class, icache3.getClass());
    assertEquals("someone", icache3.getName());
    assertEquals(0, icache3.getCapacity());     
  }
View Full Code Here


      .withArgument(1, Components.value(100));
   
    final Component factory =
      mycache.factory(ICacheFactory.class);
    yan.registerComponent("target", factory);
    final ICacheFactory ifactory =
      (ICacheFactory)yan.getInstance("target");
    final tests.jfun.yan.testmodel.ICache icache = ifactory.createCache("tom", 10);
    assertEquals(MyCache.class, icache.getClass());
    assertEquals("tom", icache.getName());
    assertEquals(100, icache.getCapacity());
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      //e.printResolutionTrace();
      assertTraceSize(e, 4);
      assertEntry(e, 2, "tests.jfun.yan.testmodel.ICacheFactory");
      assertEquals(0, e.getOrdinalPosition());
      assertEquals(String.class, e.getParameterType());
    }
    yan.registerValue("someone");
    yan.verify();
    yan.registerValue(new Integer(0));
    yan.verify();
   
    final tests.jfun.yan.testmodel.ICache icache2 = ifactory.createCache("jack", 11);
    assertEquals(MyCache.class, icache2.getClass());
    assertEquals("jack", icache2.getName());
    assertEquals(100, icache2.getCapacity());
   
    final tests.jfun.yan.testmodel.ICache icache3 = ifactory.createCache();
    assertEquals(MyCache.class, icache3.getClass());
    assertEquals("someone", icache3.getName());
    assertEquals(100, icache3.getCapacity());     
  }
View Full Code Here

   
    final Component factory =
      Components.fromArguments(mycache, new String[]{"name","capacity"})
      .factory(ICacheFactory.class);
    yan.registerComponent("target", factory);
    final ICacheFactory ifactory =
      (ICacheFactory)yan.getInstance("target");
    final tests.jfun.yan.testmodel.ICache icache = ifactory.createCache("tom", 10);
    assertEquals(MyCache.class, icache.getClass());
    assertEquals("10", icache.getName());
    assertEquals(10, icache.getCapacity());
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
     //e.printResolutionTrace();
      assertTraceSize(e, 7);
      assertEntry(e, 5, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue("someone");
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      assertTraceSize(e, 7);
      assertEntry(e, 5, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue(new Integer(0));
    yan.verify();
   
    final tests.jfun.yan.testmodel.ICache icache2 = ifactory.createCache("jack", 11);
    assertEquals(MyCache.class, icache2.getClass());
    assertEquals("11", icache2.getName());
    assertEquals(11, icache2.getCapacity());
   
    final tests.jfun.yan.testmodel.ICache icache3 = ifactory.createCache();
    assertEquals(MyCache.class, icache3.getClass());
    assertEquals("0", icache3.getName());
    assertEquals(0, icache3.getCapacity());     
  }
View Full Code Here

   
    final Component factory =
      Components.fromArguments(mycache, new String[]{"name","capacity"})
      .factory(ICacheFactory.class);
    yan.registerComponent("target", factory);
    final ICacheFactory ifactory =
      (ICacheFactory)yan.getInstance("target");
    final tests.jfun.yan.testmodel.ICache icache = ifactory.createCache("tom", 10);
    assertEquals(MyCache.class, icache.getClass());
    assertEquals("tom", icache.getName());
    assertEquals(10, icache.getCapacity());
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
     //e.printResolutionTrace();
      assertTraceSize(e, 5);
      assertEntry(e, 3, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue("someone");
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      assertTraceSize(e, 5);
      assertEntry(e, 3, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue(new Integer(0));
    yan.verify();
   
    final tests.jfun.yan.testmodel.ICache icache2 = ifactory.createCache("jack", 11);
    assertEquals(MyCache.class, icache2.getClass());
    assertEquals("jack", icache2.getName());
    assertEquals(11, icache2.getCapacity());
   
    final tests.jfun.yan.testmodel.ICache icache3 = ifactory.createCache();
    assertEquals(MyCache.class, icache3.getClass());
    assertEquals("someone", icache3.getName());
    assertEquals(0, icache3.getCapacity());     
  }
View Full Code Here

   
    final Component factory =
      mycache.fromArguments(new String[]{"name","capacity"})
      .factory(ICacheFactory.class);
    yan.registerComponent("target", factory);
    final ICacheFactory ifactory =
      (ICacheFactory)yan.getInstance("target");
    final tests.jfun.yan.testmodel.ICache icache = ifactory.createCache("tom", 10);
    assertEquals(MyCache.class, icache.getClass());
    assertEquals("tom", icache.getName());
    assertEquals(10, icache.getCapacity());
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      //e.printResolutionTrace();
      assertTraceSize(e, 5);
      assertEntry(e, 3, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue("someone");
    try{
      yan.verify();
      fail("should have failed with IrresolveableArgumentException");
    }
    catch(IrresolveableArgumentException e){
      assertTraceSize(e, 5);
      assertEntry(e, 3, "tests.jfun.yan.testmodel.ICacheFactory");
      final int pos = e.getOrdinalPosition();
      if(pos==0)
        assertEquals(String.class, e.getParameterType());
      else
        assertEquals(int.class, e.getParameterType());
    }
    yan.registerValue(new Integer(0));
    yan.verify();
   
    final tests.jfun.yan.testmodel.ICache icache2 = ifactory.createCache("jack", 11);
    assertEquals(MyCache.class, icache2.getClass());
    assertEquals("jack", icache2.getName());
    assertEquals(11, icache2.getCapacity());
   
    final tests.jfun.yan.testmodel.ICache icache3 = ifactory.createCache();
    assertEquals(MyCache.class, icache3.getClass());
    assertEquals("someone", icache3.getName());
    assertEquals(0, icache3.getCapacity());     
  }
View Full Code Here

TOP

Related Classes of tests.jfun.yan.testmodel.ICacheFactory

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.