src/test/java/org/jboss/test/util/test/propertyeditor/PropertyEditorsUnitTestCase.java
/** Test custom JBoss property editors.
    * @throws Exception 
    */
Test custom JBoss property editors.
@throws Exception
Test custom JBoss property editors . @throws Exception
public void testJBossEditors()
      throws Exception
   {
      log.debug("+++ testJBossEditors");
      Class[] types = {
         java.io.File.class,
         java.net.URL.class,
         java.net.URI.class,
         java.lang.String.class,         
         java.lang.Class.class,
         InetAddress.class,
         String[].class,
         Class[].class,
         int[].class,
         Date.class,
         java.util.Properties.class,
         Locale.class,
         AtomicInteger.class,
         AtomicLong.class,
         AtomicBoolean.class,
      };
      String[][] inputData = {
         {"/tmp/test1", "/tmp/subdir/../test2"},
         {"http://www.jboss.org", "file:/path with space/tst.xml"},
         {"http://www.jboss.org", "file:/path with space/tst.xml"},
         {"JBoss, Home of Professional Open Source"},
         {"java.util.Arrays"},
         {"127.0.0.1", "localhost"},
         {"1,2,3", "a,b,c", "", "#,%,\\,,.,_$,\\,v"},
         {"java.lang.Integer,java.lang.Float"},
         {"0,#123,-123"},
         {"Jan 4, 2005", "Tue Jan  4 23:38:21 PST 2005", "Tue, 04 Jan 2005 23:38:48 -0800"},
         {"prop1=value1\nprop2=value2\nprop3=value3\nprop32=${prop3}\nprop4=${user.home}\nprop5=${some.win32.path}"},
         {Locale.getDefault().toString(), "ja_JP"},
         {"-1", "0", "1"},
         {"-1", "0", "1"},
         {"true", "false"},
      };
      calendar.set(2005, 0, 4, 0, 0, 0);
      calendar.set(Calendar.MILLISECOND, 0);
      Date date1 = calendar.getTime();
      calendar.setTimeZone(TimeZone.getTimeZone("PST"));      
      calendar.set(2005, 0, 4, 23, 38, 21);
      Date date2 = calendar.getTime();
      calendar.set(2005, 0, 4, 23, 38, 48);
      Date date3 = calendar.getTime();
      Properties props = new Properties();
      props.setProperty("prop1", "value1");
      props.setProperty("prop2", "value2");
      props.setProperty("prop3", "value3");
      props.setProperty("prop32", "value3");
      props.setProperty("prop4", System.getProperty("user.home"));
      System.setProperty("some.win32.path", "C:\\disk1\\root\\");
      props.setProperty("prop5", "C:\\disk1\\root\\");
      Object[][] expectedData = {
         {new File("/tmp/test1").getCanonicalFile(), new File("/tmp/test2").getCanonicalFile()},
         {new URL("http://www.jboss.org"), new File("/path with space/tst.xml").getCanonicalFile().toURI().toURL()},
         {new URI("http://www.jboss.org"), new File("/path with space/tst.xml").getCanonicalFile().toURI()},
         {new String("JBoss, Home of Professional Open Source")},
         {java.util.Arrays.class},
         {InetAddress.getByName("127.0.0.1"), InetAddress.getByName("localhost")},
         {new String[]{"1", "2", "3"}, new String[] {"a", "b", "c"},
            new String[]{}, new String[]{"#","%",",",".","_$", ",v"}},
         {new Class[]{Integer.class, Float.class}},
         {new int[]{0, 0x123, -123}},
         {date1, date2, date3},
         {props},
         {Locale.getDefault(), Locale.JAPAN},
         {new AtomicInteger(-1), new AtomicInteger(0), new AtomicInteger(1)},
         {new AtomicLong(-1), new AtomicLong(0), new AtomicLong(1)},
         {new AtomicBoolean(true), new AtomicBoolean(false)},
      };
      String[][] expectedStringData = {
         {"/tmp/test1", "/tmp/subdir/../test2"},
         {"http://www.jboss.org", "file:/path with space/tst.xml"},
         {"http://www.jboss.org", "file:/path with space/tst.xml"},
         {"JBoss, Home of Professional Open Source"},
         {"java.util.Arrays"},
         {"127.0.0.1", "localhost"},
         {"1,2,3", "a,b,c", "", "#,%,\\,,.,_$,,v"},
         {"java.lang.Integer,java.lang.Float"},
         {"0,291,-123"},
         {"Jan 4, 2005", "Tue Jan  4 23:38:21 PST 2005", "Tue, 04 Jan 2005 23:38:48 -0800"},
         {props.toString()},
         {Locale.getDefault().toString(), Locale.JAPAN.toString()},
         {"-1", "0", "1"},
         {"-1", "0", "1"},
         {"true", "false"},
      };
      Comparator[] comparators = {
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
         new StringArrayComparator(), []
         new ClassArrayComparator(), []
         new IntArrayComparator(), 
         null, 
         null, 
         null, 
         new NumberComparator(),
         new NumberComparator(),
         new ToStringComparator(),
      };
      doTests(types, inputData, expectedData, expectedStringData, comparators);
   }
public void testJBossEditors ( ) throws Exception { log . debug ( "+++ testJBossEditors" ) ; Class [ ] types = { java . io . File . class , java . net . URL . class , java . net . URI . class , java . lang . String . class , java . lang . Class . class , InetAddress . class , String [ ] . class , Class [ ] . class , int [ ] . class , Date . class , java . util . Properties . class , Locale . class , AtomicInteger . class , AtomicLong . class , AtomicBoolean . class , } ; String [ ] [ ] inputData = { { "/tmp/test1" , "/tmp/subdir/../test2" } , { "http://www.jboss.org" , "file:/path with space/tst.xml" } , { "http://www.jboss.org" , "file:/path with space/tst.xml" } , { "JBoss, Home of Professional Open Source" } , { "java.util.Arrays" } , { "127.0.0.1" , "localhost" } , { "1,2,3" , "a,b,c" , "" , "#,%,\\,,.,_$,\\,v" } , { "java.lang.Integer,java.lang.Float" } , { "0,#123,-123" } , { "Jan 4, 2005" , "Tue Jan  4 23:38:21 PST 2005" , "Tue, 04 Jan 2005 23:38:48 -0800" } , { "prop1=value1\nprop2=value2\nprop3=value3\nprop32=${prop3}\nprop4=${user.home}\nprop5=${some.win32.path}" } , { Locale . getDefault ( ) . toString ( ) , "ja_JP" } , { "-1" , "0" , "1" } , { "-1" , "0" , "1" } , { "true" , "false" } , } ; calendar . set ( 2005 , 0 , 4 , 0 , 0 , 0 ) ; calendar . set ( Calendar . MILLISECOND , 0 ) ; Date date1 = calendar . getTime ( ) ; calendar . setTimeZone ( TimeZone . getTimeZone ( "PST" ) ) ; calendar . set ( 2005 , 0 , 4 , 23 , 38 , 21 ) ; Date date2 = calendar . getTime ( ) ; calendar . set ( 2005 , 0 , 4 , 23 , 38 , 48 ) ; Date date3 = calendar . getTime ( ) ; Properties props = new Properties ( ) ; props . setProperty ( "prop1" , "value1" ) ; props . setProperty ( "prop2" , "value2" ) ; props . setProperty ( "prop3" , "value3" ) ; props . setProperty ( "prop32" , "value3" ) ; props . setProperty ( "prop4" , System . getProperty ( "user.home" ) ) ; System . setProperty ( "some.win32.path" , "C:\\disk1\\root\\" ) ; props . setProperty ( "prop5" , "C:\\disk1\\root\\" ) ; Object [ ] [ ] expectedData = { { new File ( "/tmp/test1" ) . getCanonicalFile ( ) , new File ( "/tmp/test2" ) . getCanonicalFile ( ) } , { new URL ( "http://www.jboss.org" ) , new File ( "/path with space/tst.xml" ) . getCanonicalFile ( ) . toURI ( ) . toURL ( ) } , { new URI ( "http://www.jboss.org" ) , new File ( "/path with space/tst.xml" ) . getCanonicalFile ( ) . toURI ( ) } , { new String ( "JBoss, Home of Professional Open Source" ) } , { java . util . Arrays . class } , { InetAddress . getByName ( "127.0.0.1" ) , InetAddress . getByName ( "localhost" ) } , { new String [ ] { "1" , "2" , "3" } , new String [ ] { "a" , "b" , "c" } , new String [ ] { } , new String [ ] { "#" , "%" , "," , "." , "_$" , ",v" } } , { new Class [ ] { Integer . class , Float . class } } , { new int [ ] { 0 , 0x123 , - 123 } } , { date1 , date2 , date3 } , { props } , { Locale . getDefault ( ) , Locale . JAPAN } , { new AtomicInteger ( - 1 ) , new AtomicInteger ( 0 ) , new AtomicInteger ( 1 ) } , { new AtomicLong ( - 1 ) , new AtomicLong ( 0 ) , new AtomicLong ( 1 ) } , { new AtomicBoolean ( true ) , new AtomicBoolean ( false ) } , } ; String [ ] [ ] expectedStringData = { { "/tmp/test1" , "/tmp/subdir/../test2" } , { "http://www.jboss.org" , "file:/path with space/tst.xml" } , { "http://www.jboss.org" , "file:/path with space/tst.xml" } , { "JBoss, Home of Professional Open Source" } , { "java.util.Arrays" } , { "127.0.0.1" , "localhost" } , { "1,2,3" , "a,b,c" , "" , "#,%,\\,,.,_$,,v" } , { "java.lang.Integer,java.lang.Float" } , { "0,291,-123" } , { "Jan 4, 2005" , "Tue Jan  4 23:38:21 PST 2005" , "Tue, 04 Jan 2005 23:38:48 -0800" } , { props . toString ( ) } , { Locale . getDefault ( ) . toString ( ) , Locale . JAPAN . toString ( ) } , { "-1" , "0" , "1" } , { "-1" , "0" , "1" } , { "true" , "false" } , } ; Comparator [ ] comparators = { null , null , null , null , null , null , new StringArrayComparator ( ) , new ClassArrayComparator ( ) , new IntArrayComparator ( ) , null , null , null , new NumberComparator ( ) , new NumberComparator ( ) , new ToStringComparator ( ) , } ; doTests ( types , inputData , expectedData , expectedStringData , comparators ) ; }
Test custom JBoss property editors.
Test custom JBoss property editors .
// The input string data for each type // java.io.File.class // java.net.URL.class // java.net.URI.class // java.lang.String.class // java.lang.Class.class // InetAddress.class, localhost must be defined for this to work // String[].class // Class[].class // int[].class // Date.class // java.util.Properties.class // The expected instance for each inputData value // The expected string output from getAsText() // java.io.File.class // java.net.URL.class // java.net.URI.class // java.lang.String.class // java.lang.Class.class // InetAddress.class, localhost must be defined for this to work // String[].class // Class[].class // int[].class // Date.class // java.util.Properties.class // The Comparator for non-trival types // File // URL // URI // String // Class // InetAddress // String[] // Class[] // int[] // Date // Properties // Locale