package org.simpleframework.xml.convert;

import org.simpleframework.xml.Default;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.ValidationTestCase;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.stream.InputNode;
import org.simpleframework.xml.stream.OutputNode;

public class RegistryConverterTest extends ValidationTestCase {

   public static class EnvelopeConverter implements Converter<Envelope> {
      private final Serializer serializer;
      public EnvelopeConverter(Serializer serializer) {
         this.serializer = serializer;
      }
      public Envelope read(InputNode node) throws Exception {
         return serializer.read(Envelope.class, node);
      }
      public void write(OutputNode node, Envelope value) throws Exception {
         serializer.write(value.getValue(), node);
      }
   }
   
   @Root
   private static class OrderItem {
      @Element
      private Envelope envelope;
      public OrderItem() {
         super();
      }
      public OrderItem(String name, String address) {
         this.envelope = new Envelope(new Customer(name, address));
      }
   }
   
   @Root
   @Default
   private static class Customer {
      private String name;
      private String address;
      public Customer() {
         super();
      }
      public Customer(String name, String address) {
         this.name = name;
         this.address = address;
      }
   }
  
   private static class Envelope {
      private final Object value;
      public Envelope(Object value) {
         this.value = value;  
      }
      public Object getValue() {
         return value;
      }
   }
   
   public void testConverter() throws Exception {
      Registry registry = new Registry();
      RegistryStrategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
      Converter converter = new EnvelopeConverter(serializer);
      
      registry.bind(Envelope.class, converter);
      
      OrderItem order = new OrderItem("Niall", "Gallagher");
      serializer.write(order, System.out);
   }
}

@@ -297,24 +297,126 @@
 Persister;%0D%0A
+import org.simpleframework.xml.stream.CamelCaseStyle;%0D%0Aimport org.simpleframework.xml.stream.Format;%0D%0A
 import org.s
@@ -503,16 +503,62 @@
 utNode;%0D
+%0Aimport org.simpleframework.xml.stream.Style;%0D
 %0A%0D%0Apubli
@@ -1301,35 +1301,25 @@
 tem(
-String name, String address
+Envelope envelope
 ) %7B%0D
@@ -1348,49 +1348,16 @@
 e = 
-new E
+e
 nvelope
-(new Customer(name, address))
 ;%0D%0A 
@@ -1973,41 +1973,241 @@
     
-Registry registry = new Registry(
+Style style = new CamelCaseStyle();%0D%0A      Format format = new Format(style);%0D%0A      Registry registry = new Registry();%0D%0A      Customer customer = new Customer(%22Niall%22, %22Some Place%22);%0D%0A      Envelope envelope = new Envelope(customer
 );%0D%0A
@@ -2325,16 +2325,24 @@
 strategy
+, format
 );%0D%0A    
@@ -2508,28 +2508,16 @@
 tem(
-%22Niall%22, %22Gallagher%22
+envelope
 );%0D%0A

Update test