package org.simpleframework.xml.load;

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.Text;
import org.simpleframework.xml.ValidationTestCase;

public class MixTest extends ValidationTestCase {
   
   @Root
   private static class MixExample {
      
      @ElementList
      private List<Object> list;
      
      @ElementMap
      private Map<Object, Object> map;
      
      @Element
      private Calendar calendar;
      
      public MixExample() {
         this.list = new ArrayList();
         this.map = new HashMap();
      }
      
      private void setTime(Date date) {
         calendar = new GregorianCalendar();
         calendar.setTime(date);
      }
      
      public void put(Object key, Object value) {
         map.put(key, value);
      }
      
      public Object get(int index) {
         return list.get(index);
      }
      
      public void add(Object object) {
         list.add(object);
      }
   }
   
   @Root
   private static class Entry {
      
      @Attribute
      private String id;
      
      @Text
      private String text;
      
      public Entry() {
         super();
      }
      
      public Entry(String id, String text) {
         this.id = id;
         this.text = text;
      }
   }
   
   public void testMix() throws Exception {
      Serializer serializer = new Persister();
      MixExample example = new MixExample();
      StringWriter source = new StringWriter();
      
      example.setTime(new Date());
      example.add("text");
      example.add(1);
      example.add(true);
      example.add(new Entry("1", "example 1"));
      example.add(new Entry("2", "example 2"));
      example.put(new Entry("1", "key 1"), new Entry("1", "value 1"));
      example.put("key 2", "value 2");
      example.put("key 3", 3);
      example.put("key 4", new Entry("4", "value 4"));
      
      serializer.write(example, System.out);
      serializer.write(example, source);   
      serializer.validate(MixExample.class, source.toString());
      
      MixExample other = serializer.read(MixExample.class, source.toString());
      
      serializer.write(other, System.out);
      
      assertEquals(example.get(0), "text");
      assertEquals(example.get(1), 1);      
      assertEquals(example.get(2), true);
      
      validate(example, serializer);
   }

}

@@ -635,16 +635,976 @@
 tCase %7B%0A
+   %0A   @Root%0A   public static class PersonProfile %7B%0A%0A      @Attribute%0A      private String firstName;%0A%0A      @Attribute%0A      private String lastName;%0A%0A      @Element%0A      private PersonAddress personAddress;%0A%0A      @Element%0A      private Date DOB;%0A%0A      public Date getDateOfBirth() %7B%0A         return DOB;%0A      %7D%0A%0A      public String getFirstName() %7B%0A         return firstName;%0A      %7D%0A%0A      public String getLastName() %7B%0A         return lastName;%0A      %7D%0A%0A      public PersonAddress getAddress() %7B%0A         return personAddress;%0A      %7D%0A   %7D%0A%0A   @Root%0A   public static class PersonAddress %7B%0A%0A      @Element%0A      private String houseNumber;%0A%0A      @Element%0A      private String streetName;%0A%0A      @Element%0A      private String city;%0A%0A      public String getHouseNumber() %7B%0A         return houseNumber;%0A      %7D%0A%0A      public String getStreetName() %7B%0A         return streetName;%0A      %7D%0A%0A      public String getCity() %7B%0A         return city;%0A      %7D%0A   %7D%0A%0A
    %0A   @

Update the mix test