Package ch.inftec.ju.util.persistable.GenericMementoUtils

Examples of ch.inftec.ju.util.persistable.GenericMementoUtils.TypeHandlerBuilder


  /**
   * Test the building of a type handler.
   */
  @Test
  public void typeHandler() {
    TypeHandlerBuilder builder = GenericMementoUtils.newTypeHandler();
   
    TypeHandler1 th1 = new TypeHandler1();
    TypeHandler2 th2 = new TypeHandler2();
   
    // Check default type names
    Assert.assertEquals(TypeHandler1.class.getName(), builder.getHandler().getTypeName(th1));
    Assert.assertEquals(TypeHandler2.class.getName(), builder.getHandler().getTypeName(th2));
   
    // Check default instantiation
    Assert.assertEquals(TypeHandler1.class, builder.getHandler().newInstance(TypeHandler1.class.getName()).getClass());
   
    // Check automatic mapping without field
    builder.addMapping(TypeHandler1.class);
    Assert.assertEquals(TypeHandler1.class.getName(), builder.getHandler().getTypeName(th1));
   
    // Check automatic mapping with field
    builder.addMapping(TypeHandler2.class);
    Assert.assertEquals("H2", builder.getHandler().getTypeName(th2));
    Assert.assertEquals(TypeHandler2.class, builder.getHandler().newInstance("H2").getClass());
   
    // Create instance of private class
    Assert.assertEquals(TypeHandler3.class, builder.getHandler().newInstance(TypeHandler3.class.getName()).getClass());
  }
View Full Code Here

TOP

Related Classes of ch.inftec.ju.util.persistable.GenericMementoUtils.TypeHandlerBuilder

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.