package simple.xml.load;

import java.io.StringReader;

import junit.framework.TestCase;
import simple.xml.ElementArray;
import simple.xml.Attribute;
import simple.xml.Root;

public class ArrayTest extends TestCase {

   private static final String SOURCE =
   "<?xml version=\"1.0\"?>\n"+
   "<root>\n"+
   "   <array>\n\r"+
   "      <text value='entry one'/>  \n\r"+
   "      <text value='entry two'/>  \n\r"+
   "      <text value='entry three'/>  \n\r"+
   "      <text value='entry four'/>  \n\r"+
   "      <text value='entry five'/>  \n\r"+
   "   </array>\n\r"+
   "</root>";

   @Root(name="root")
   private static class Example {

      @ElementArray(name="array")           
      public Text[] array;
   }

   @Root(name="text") 
   private static class Text {

      @Attribute(name="value")
      public String value;
   }

   private Persister serializer;

   public void setUp() {
      serializer = new Persister();
   }
	
   public void testFirst() throws Exception {    
      Example example = serializer.read(Example.class, SOURCE);
      
      assertEquals(example.array.length, 5);
      assertEquals(example.array[0].value, "entry one");
      assertEquals(example.array[1].value, "entry two");
      assertEquals(example.array[2].value, "entry three");
      assertEquals(example.array[3].value, "entry four");
      assertEquals(example.array[4].value, "entry five");
   }
 }

@@ -715,16 +715,145 @@
 ;%0A   %7D%0A%0A
+   @Root(name=%22root%22)%0A   private static class BadExample %7B%0A %0A      @ElementArray(name=%22array%22)%0A      public Text array;%0A   %7D   %0A%0A
    @Root
@@ -867,16 +867,16 @@
 text%22) %0A
-
    priva
@@ -1088,13 +1088,15 @@
 test
-First
+Example
 () t
@@ -1527,11 +1527,291 @@
 );%0A   %7D%0A
- 
+%0A   public void testBadExample() throws Exception %7B    %0A      boolean success = false;%0A%0A      try %7B%0A         BadExample example = serializer.read(BadExample.class, SOURCE);%0A      %7D catch(InstantiationException e) %7B%0A         success = true;%0A      %7D%0A      assertTrue(success);%0A   %7D%0A%0A
 %7D%0A

Update the array test