axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/test/utils TestJavaUtils.java
Date Tue, 22 Oct 2002 16:02:16 GMT
tomj        2002/10/22 09:02:16

  Modified:    java/test/utils TestJavaUtils.java
  Log:
  Here is the test case for this JavaUtils fix.
  
  Fix a problem in convert() when dealing with ArrayLists and add a test case.
  
  The ArrayDeserializer produces an array of ArrayLists when deserializing a 2D
  Object array.  This is probably not the best, but that is some hairy code.
  This fix just fixes convert() to deal with it correctly.
  
  Note: It appears that we do some slow things in the Array stuff,
  like converting things multiple times.  This might be a good place for
  performance work.
  
  Revision  Changes    Path
  1.14      +25 -0     xml-axis/java/test/utils/TestJavaUtils.java
  
  Index: TestJavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/utils/TestJavaUtils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestJavaUtils.java	12 Sep 2002 20:29:00 -0000	1.13
  +++ TestJavaUtils.java	22 Oct 2002 16:02:16 -0000	1.14
  @@ -15,6 +15,7 @@
   import java.util.Set;
   import java.util.HashSet;
   import java.util.Vector;
  +import java.lang.reflect.Array;
   
   public class TestJavaUtils extends TestCase
   {
  @@ -109,6 +110,30 @@
           ret = JavaUtils.convert(holder2, Object.class);
           assertTrue(ret != null);
           assertTrue(Byte.class.isInstance(ret));
  +        
  +        // Make sure we convert ArrayList to array in 2D cases
  +        Object[] arrayin = new Object[1];
  +        ArrayList data = new ArrayList(5);
  +        data.add("one"); data.add(new Integer(2)); data.add(new Float(4.0));
  +        data.add(new Double(5.0)); data.add("five");
  +        arrayin[0] = data;
  +        ret = JavaUtils.convert(arrayin, Object[][].class);
  +        assertTrue("Converted 2D array/ArrayList wrong", ret.getClass().equals(Object[][].class));
  +        Object[][] outer = (Object[][]) ret;
  +        assertEquals("Outer array of 2D array/ArrayList is wrong length", 1, outer.length);
  +        Object[] inner = ((Object[][])ret)[0];
  +        assertEquals("Inner array of 2D array/ArrayLis is wrong length", 5, inner.length);
  +        
  +        // check 2D ArrayList of ArrayList
  +        ArrayList data2D = new ArrayList(2);
  +        data2D.add(data); data2D.add(data);
  +        ret = JavaUtils.convert(data2D, Object[][].class);
  +        assertTrue("Converted 2D ArrayList wrong", ret.getClass().equals(Object[][].class));
  +        Object[][] outer2 = (Object[][]) ret;
  +        assertEquals("Outer array of 2D ArrayList is wrong length", 2, outer2.length);
  +        Object[] inner2 = ((Object[][]) ret)[0];
  +        assertEquals("Inner array of 2D ArrayList is wrong length", 5, inner2.length);
  +        
       }
   
       /**
  
  
  

Mime
View raw message