src/test/java/org/jboss/test/util/test/propertyeditor/PropertyEditorsUnitTestCase.java
/** The mechanism for mapping java.lang.* variants of the primative types
    misses editors for java.lang.Boolean and java.lang.Integer. Here we test
    the java.lang.* variants we expect editors for.
    * @throws Exception 
    **/
The mechanism for mapping java.lang.* variants of the primative types
misses editors for java.lang.Boolean and java.lang.Integer. Here we test
the java.lang.* variants we expect editors for.
@throws Exception
The mechanism for mapping java . lang . * variants of the primative types misses editors for java . lang . Boolean and java . lang . Integer . Here we test the java . lang . * variants we expect editors for . @throws Exception
public void testJavaLangEditors()
      throws Exception
   {
      log.debug("+++ testJavaLangEditors");
      Class[] types = {
         Boolean.class,
         Byte.class,
         Short.class,
         Integer.class,
         Long.class,
         Float.class,
         Double.class,
         Byte.class,
         Character.class,
      };
      String[][] inputData = {
         {"true", "false", "TRUE", "FALSE", "tRuE", "FaLsE", null},
         {"1", "-1", "0", "0x1A"},
         {"1", "-1", "0", "0xA0"},
         {"1", "-1", "0", "0xA0"},
         {"1", "-1", "0", "1000"},
         {"1", "-1", "0", "1000.1"},
         {"1", "-1", "0", "1000.1"},
         {"0x1", "-#1", "0"},
         {"A", "a", "Z", "z"},
      };
      Object[][] expectedData = {
         {Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, null},
         {Byte.valueOf("1"), Byte.valueOf("-1"), Byte.valueOf("0"), Byte.decode("0x1A")},
         {Short.valueOf("1"), Short.valueOf("-1"), Short.valueOf("0"), Short.decode("0xA0")},
         {Integer.valueOf("1"), Integer.valueOf("-1"), Integer.valueOf("0"), Integer.decode("0xA0")},
         {Long.valueOf("1"), Long.valueOf("-1"), Long.valueOf("0"), Long.valueOf("1000")},
         {Float.valueOf("1"), Float.valueOf("-1"), Float.valueOf("0"), Float.valueOf("1000.1")},
         {Double.valueOf("1"), Double.valueOf("-1"), Double.valueOf("0"), Double.valueOf("1000.1")},
         {Byte.valueOf("1"), Byte.valueOf("-1"), Byte.valueOf("0")},
         {new Character('A'), new Character('a'), new Character('Z'), new Character('z')},
      };
      String[][] expectedStringData = {
         {"true", "false", "true", "false", "true", "false", hasJDK7() ? null : "null"},
         {"1", "-1", "0", "26"},
         {"1", "-1", "0", "160"},
         {"1", "-1", "0", "160"},
         {"1", "-1", "0", "1000"},
         {"1.0", "-1.0", "0.0", "1000.1"},
         {"1.0", "-1.0", "0.0", "1000.1"},
         {"1", "-1", "0"},
         {"A", "a", "Z", "z"},            
      };
      Comparator[] comparators = new Comparator[types.length];
      doTests(types, inputData, expectedData, expectedStringData, comparators);
   }
public void testJavaLangEditors ( ) throws Exception { log . debug ( "+++ testJavaLangEditors" ) ; Class [ ] types = { Boolean . class , Byte . class , Short . class , Integer . class , Long . class , Float . class , Double . class , Byte . class , Character . class , } ; String [ ] [ ] inputData = { { "true" , "false" , "TRUE" , "FALSE" , "tRuE" , "FaLsE" , null } , { "1" , "-1" , "0" , "0x1A" } , { "1" , "-1" , "0" , "0xA0" } , { "1" , "-1" , "0" , "0xA0" } , { "1" , "-1" , "0" , "1000" } , { "1" , "-1" , "0" , "1000.1" } , { "1" , "-1" , "0" , "1000.1" } , { "0x1" , "-#1" , "0" } , { "A" , "a" , "Z" , "z" } , } ; Object [ ] [ ] expectedData = { { Boolean . TRUE , Boolean . FALSE , Boolean . TRUE , Boolean . FALSE , Boolean . TRUE , Boolean . FALSE , null } , { Byte . valueOf ( "1" ) , Byte . valueOf ( "-1" ) , Byte . valueOf ( "0" ) , Byte . decode ( "0x1A" ) } , { Short . valueOf ( "1" ) , Short . valueOf ( "-1" ) , Short . valueOf ( "0" ) , Short . decode ( "0xA0" ) } , { Integer . valueOf ( "1" ) , Integer . valueOf ( "-1" ) , Integer . valueOf ( "0" ) , Integer . decode ( "0xA0" ) } , { Long . valueOf ( "1" ) , Long . valueOf ( "-1" ) , Long . valueOf ( "0" ) , Long . valueOf ( "1000" ) } , { Float . valueOf ( "1" ) , Float . valueOf ( "-1" ) , Float . valueOf ( "0" ) , Float . valueOf ( "1000.1" ) } , { Double . valueOf ( "1" ) , Double . valueOf ( "-1" ) , Double . valueOf ( "0" ) , Double . valueOf ( "1000.1" ) } , { Byte . valueOf ( "1" ) , Byte . valueOf ( "-1" ) , Byte . valueOf ( "0" ) } , { new Character ( 'A' ) , new Character ( 'a' ) , new Character ( 'Z' ) , new Character ( 'z' ) } , } ; String [ ] [ ] expectedStringData = { { "true" , "false" , "true" , "false" , "true" , "false" , hasJDK7 ( ) ? null : "null" } , { "1" , "-1" , "0" , "26" } , { "1" , "-1" , "0" , "160" } , { "1" , "-1" , "0" , "160" } , { "1" , "-1" , "0" , "1000" } , { "1.0" , "-1.0" , "0.0" , "1000.1" } , { "1.0" , "-1.0" , "0.0" , "1000.1" } , { "1" , "-1" , "0" } , { "A" , "a" , "Z" , "z" } , } ; Comparator [ ] comparators = new Comparator [ types . length ] ; doTests ( types , inputData , expectedData , expectedStringData , comparators ) ; }
The mechanism for mapping java.lang.
The mechanism for mapping java . lang .
// The supported java.lang.* types // The input string data for each type // The expected java.lang.* instance for each inputData value // The expected string output from getAsText()