[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-40-ge1d2459

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Feb 22 19:50:40 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, encoder has been updated
       via  e1d24597013b73981e1a1b1d3f518af7db808a58 (commit)
      from  576c1625cf8a8f431af78f0a90ba1d8bc7fb21bb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=e1d24597013b73981e1a1b1d3f518af7db808a58
http://github.com/ceki/logback/commit/e1d24597013b73981e1a1b1d3f518af7db808a58

commit e1d24597013b73981e1a1b1d3f518af7db808a58
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Feb 22 19:47:26 2010 +0100

    - minor refactoring of the code, testing encoding with charsets...

diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
index 91b29f6..2473580 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
@@ -30,6 +30,7 @@ import org.junit.runners.Suite.SuiteClasses;
     ch.qos.logback.classic.html.PackageTest.class,
     ch.qos.logback.classic.net.PackageTest.class,
     ch.qos.logback.classic.pattern.PackageTest.class,
+    ch.qos.logback.classic.encoder.PackageTest.class,
     ch.qos.logback.classic.db.PackageTest.class,
     ch.qos.logback.classic.spi.PackageTest.class,
     ch.qos.logback.classic.turbo.PackageTest.class,
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
similarity index 72%
copy from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
index 07c691c..b17a9ff 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
@@ -11,15 +11,13 @@
  * under the terms of the GNU Lesser General Public License version 2.1
  * as published by the Free Software Foundation.
  */
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.classic.encoder;
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
-    PropertySetterTest.class, NoAutoStartUtilTest.class,
-    DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
+ at SuiteClasses(PatternLayoutEncoderTest.class)
 public class PackageTest {
-}
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
new file mode 100644
index 0000000..9a79884
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
@@ -0,0 +1,59 @@
+package ch.qos.logback.classic.encoder;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggingEvent;
+
+public class PatternLayoutEncoderTest {
+
+  PatternLayoutEncoder ple = new PatternLayoutEncoder();
+  LoggerContext context = new LoggerContext();
+  ByteArrayOutputStream baos = new ByteArrayOutputStream();
+  Logger logger = context.getLogger(PatternLayoutEncoderTest.class);
+  Charset utf8Charset = Charset.forName("UTF-8");
+  
+  @Before
+  public void setUp() {
+    ple.setPattern("%m");
+    ple.setContext(context);
+  }
+
+  ILoggingEvent makeLoggingEvent(String message) {
+    return new LoggingEvent("", logger, Level.DEBUG, message, null, null);
+  }
+
+  @Test
+  public void smoke() throws IOException {
+    ple.start();
+    ple.init(baos);
+    String msg = "hello";
+    ILoggingEvent event = makeLoggingEvent(msg);
+    ple.doEncode(event);
+    ple.close();
+    assertEquals(msg, baos.toString());
+  }
+
+  @Test
+  public void charset() throws IOException {
+    ple.setCharset(utf8Charset);
+    ple.start();
+    ple.init(baos);
+    String msg = "\u03b1";
+    ILoggingEvent event = makeLoggingEvent(msg);
+    ple.doEncode(event);
+    ple.close();
+    assertEquals(msg, new String(baos.toByteArray(), utf8Charset));
+  }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
index bd1098e..0a168d9 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
@@ -74,9 +74,9 @@ public class ConsoleAppender<E> extends WriterAppender<E> {
 
     public void start() {
       if (target.equals(SYSTEM_OUT)) {
-        setWriter(System.out);
+        setOutputStream(System.out);
       } else {
-        setWriter(System.err);
+        setOutputStream(System.err);
       }
       super.start();
     }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
index 72be15c..b392ba8 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
@@ -199,7 +199,7 @@ public class FileAppender<E> extends WriterAppender<E> {
       // if (bufferedIO) {
       // w = new BufferedWriter(w, bufferSize);
       // }
-      setWriter(resilientFos);
+      setOutputStream(resilientFos);
     }
   }
 
diff --git a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
index e0410ed..94a2172 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
@@ -15,7 +15,6 @@ package ch.qos.logback.core;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 
 import ch.qos.logback.core.encoder.Encoder;
 import ch.qos.logback.core.spi.DeferredProcessingAware;
@@ -32,8 +31,15 @@ import ch.qos.logback.core.status.ErrorStatus;
  */
 public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
 
+  /**
+   * It is the encoder which is ultimately responsible for writing the event to
+   * an {@link OutputStream}.
+   */
   protected Encoder<E> encoder;
 
+  /**
+   * All synchronization in this class is done via the lock object.
+   */
   protected Object lock = new Object();
 
   /**
@@ -51,15 +57,7 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
   private boolean immediateFlush = true;
 
   /**
-   * The encoding to use when opening an InputStream.
-   * <p>
-   * The <code>encoding</code> variable is set to <code>null</null> by default 
-   * which results in the use of the system's default encoding.
-   */
-  private String encoding;
-
-  /**
-   * This is the {@link OutputStream outputStream} where we will write to.
+   * This is the {@link OutputStream outputStream} where output will be written.
    */
   private OutputStream outputStream;
 
@@ -86,10 +84,15 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
     immediateFlush = value;
   }
 
-  protected OutputStream getOutputStream() {
+  /**
+   * The underlying output stream used by this appender.
+   * 
+   * @return
+   */
+  public OutputStream getOutputStream() {
     return outputStream;
   }
-  
+
   /**
    * Returns value of the <b>ImmediateFlush</b> option.
    */
@@ -138,15 +141,15 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
    */
   public void stop() {
     synchronized (lock) {
-      closeWriter();
+      closeOutputStream();
       super.stop();
     }
   }
 
   /**
-   * Close the underlying {@link java.io.Writer}.
+   * Close the underlying {@link OutputStream}.
    */
-  protected void closeWriter() {
+  protected void closeOutputStream() {
     if (this.outputStream != null) {
       try {
         // before closing we have to output out layout's footer
@@ -154,43 +157,10 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
         this.outputStream.close();
         this.outputStream = null;
       } catch (IOException e) {
-        addStatus(new ErrorStatus("Could not close writer for WriterAppener.",
-            this, e));
-      }
-    }
-  }
-
-  /**
-   * Returns an OutputStreamWriter when passed an OutputStream. The encoding
-   * used will depend on the value of the <code>encoding</code> property. If the
-   * encoding value is specified incorrectly the writer will be opened using the
-   * default system encoding (an error message will be printed to the loglog.
-   */
-  protected OutputStreamWriter createWriter(OutputStream os) {
-    OutputStreamWriter retval = null;
-
-    String enc = getEncoding();
-    try {
-      if (enc != null) {
-        retval = new OutputStreamWriter(os, enc);
-      } else {
-        retval = new OutputStreamWriter(os);
-      }
-    } catch (IOException e) {
-      addStatus(new ErrorStatus("Error initializing output writer.", this, e));
-      if (enc != null) {
-        addStatus(new ErrorStatus("Unsupported encoding?", this));
+        addStatus(new ErrorStatus(
+            "Could not close output stream for WriterAppener.", this, e));
       }
     }
-    return retval;
-  }
-
-  public String getEncoding() {
-    return encoding;
-  }
-
-  public void setEncoding(String value) {
-    encoding = value;
   }
 
   void encoderInit() {
@@ -219,21 +189,22 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
 
   /**
    * <p>
-   * Sets the Writer where the log output will go. The specified Writer must be
-   * opened by the user and be writable. The <code>java.io.Writer</code> will be
-   * closed when the appender instance is closed.
+   * Sets the @link OutputStream} where the log output will go. The specified
+   * <code>OutputStream</code> must be opened by the user and be writable. The
+   * <code>OutputStream</code> will be closed when the appender instance is
+   * closed.
    * 
-   * @param writer
-   *          An already opened Writer.
+   * @param outputStream
+   *          An already opened OutputStream.
    */
-  public void setWriter(OutputStream outputStream) {
+  public void setOutputStream(OutputStream outputStream) {
     synchronized (lock) {
-      // close any previously opened writer
-      closeWriter();
+      // close any previously opened output stream
+      closeOutputStream();
 
       this.outputStream = outputStream;
       if (encoder == null) {
-        addWarn("Encoder not yet set. Cannot invoke init method ");
+        addWarn("Encoder not yet set. Cannot invoke it's init method");
         return;
       }
 
diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
index 3ed1ffa..038068b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
@@ -22,7 +22,7 @@ import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.action.Action;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 import ch.qos.logback.core.util.OptionHelper;
 
 /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
index cbbc966..caab0ce 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
@@ -2,6 +2,7 @@ package ch.qos.logback.core.html;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 
 import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.Layout;
@@ -11,6 +12,15 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
 
   protected Layout<E> layout;
 
+  /**
+   * The charset to use when converting a String into bytes.
+   * <p>
+   * By default this property has the value
+   * <code>null</null> which corresponds to 
+   * the system's default charset.
+   */
+  private Charset charset;
+
   public Layout<E> getLayout() {
     return layout;
   }
@@ -19,22 +29,29 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
     this.layout = layout;
   }
 
+  public Charset getCharset() {
+    return charset;
+  }
+
+  /**
+   * Set the charset to use when converting the string returned by the layout
+   * into bytes.
+   * <p>
+   * By default this property has the value
+   * <code>null</null> which corresponds to 
+   * the system's default charset.
+   * 
+   * @param charset
+   */
+  public void setCharset(Charset charset) {
+    this.charset = charset;
+  }
 
   public void init(OutputStream os) throws IOException {
     super.init(os);
     writeHeader();
   }
 
-  public void close() throws IOException {
-    writeFooter();
-  }
-
-  private void appendIfNotNull(StringBuilder sb, String s) {
-    if (s != null) {
-      sb.append(s);
-    }
-  }
-  
   void writeHeader() throws IOException {
     if (layout != null && (outputStream != null)) {
       StringBuilder sb = new StringBuilder();
@@ -45,28 +62,40 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
         // If at least one of file header or presentation header were not
         // null, then append a line separator.
         // This should be useful in most cases and should not hurt.
-        outputStream.write(sb.toString().getBytes());
+        outputStream.write(convertToBytes(sb.toString()));
         outputStream.flush();
       }
     }
   }
 
+  public void close() throws IOException {
+    writeFooter();
+  }
+
   void writeFooter() throws IOException {
     if (layout != null && outputStream != null) {
       StringBuilder sb = new StringBuilder();
       appendIfNotNull(sb, layout.getPresentationFooter());
       appendIfNotNull(sb, layout.getFileFooter());
       if (sb.length() > 0) {
-        outputStream.write(sb.toString().getBytes());
+        outputStream.write(convertToBytes(sb.toString()));
         outputStream.flush();
       }
 
     }
   }
 
+  private byte[] convertToBytes(String s) {
+    if (charset == null) {
+      return s.getBytes();
+    } else {
+      return s.getBytes(charset);
+    }
+  }
+
   public void doEncode(E event) throws IOException {
     String txt = layout.doLayout(event);
-    outputStream.write(txt.getBytes());
+    outputStream.write(convertToBytes(txt));
     outputStream.flush();
   }
 
@@ -82,4 +111,10 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
     started = false;
   }
 
+  private void appendIfNotNull(StringBuilder sb, String s) {
+    if (s != null) {
+      sb.append(s);
+    }
+  }
+
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
index ba46eac..2a4728b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
@@ -13,7 +13,7 @@
  */
 package ch.qos.logback.core.joran.action;
 
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 import ch.qos.logback.core.util.AggregationType;
 
 /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
index e59b277..ad636f6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
@@ -13,7 +13,7 @@
  */
 package ch.qos.logback.core.joran.action;
 
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 import ch.qos.logback.core.util.AggregationType;
 
 /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
index 28e6f1d..18907cd 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
@@ -19,7 +19,7 @@ import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.spi.InterpretationContext;
 import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 import ch.qos.logback.core.util.AggregationType;
 
 /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
index ceb5bbf..2f942c2 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
@@ -20,7 +20,7 @@ import org.xml.sax.Attributes;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
 import ch.qos.logback.core.joran.spi.NoAutoStartUtil;
 import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 import ch.qos.logback.core.spi.ContextAware;
 import ch.qos.logback.core.spi.LifeCycle;
 import ch.qos.logback.core.util.AggregationType;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
index af33532..924f6b7 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
@@ -17,7 +17,7 @@ package ch.qos.logback.core.joran.action;
 import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
 
 
 
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
similarity index 74%
rename from logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java
rename to logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
index c0c69d5..246a0cb 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
@@ -12,7 +12,7 @@
  * as published by the Free Software Foundation.
  */
 // Contributors:  Georg Lundesgaard
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -21,10 +21,10 @@ import java.beans.MethodDescriptor;
 import java.beans.PropertyDescriptor;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
+import java.nio.charset.Charset;
 
-import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.joran.action.IADataForComplexProperty;
+import ch.qos.logback.core.joran.spi.DefaultClass;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
 import ch.qos.logback.core.spi.ContextAwareBase;
 import ch.qos.logback.core.util.AggregationType;
 import ch.qos.logback.core.util.PropertySetterException;
@@ -35,7 +35,8 @@ import ch.qos.logback.core.util.PropertySetterException;
  * the Object specified in the constructor. This class relies on the JavaBeans
  * {@link Introspector} to analyze the given Object Class using reflection.
  * 
- * <p> Usage:
+ * <p>
+ * Usage:
  * 
  * <pre>
  * PropertySetter ps = new PropertySetter(anObject);
@@ -52,7 +53,6 @@ import ch.qos.logback.core.util.PropertySetterException;
  * @author Ceki Gulcu
  */
 public class PropertySetter extends ContextAwareBase {
-  private static final Class[] STING_CLASS_PARAMETER = new Class[] { String.class };
 
   protected Object obj;
   protected Class objClass;
@@ -64,7 +64,7 @@ public class PropertySetter extends ContextAwareBase {
    * preparation for invoking {@link #setProperty} one or more times.
    * 
    * @param obj
-   *                the object for which to set properties
+   *          the object for which to set properties
    */
   public PropertySetter(Object obj) {
     this.obj = obj;
@@ -94,15 +94,16 @@ public class PropertySetter extends ContextAwareBase {
    * setter argument type and partly from the value specified in the call to
    * this method.
    * 
-   * <p> If the setter expects a String no conversion is necessary. If it
-   * expects an int, then an attempt is made to convert 'value' to an int using
-   * new Integer(value). If the setter expects a boolean, the conversion is by
-   * new Boolean(value).
+   * <p>
+   * If the setter expects a String no conversion is necessary. If it expects an
+   * int, then an attempt is made to convert 'value' to an int using new
+   * Integer(value). If the setter expects a boolean, the conversion is by new
+   * Boolean(value).
    * 
    * @param name
-   *                name of the property
+   *          name of the property
    * @param value
-   *                String value of the property
+   *          String value of the property
    */
   public void setProperty(String name, String value) {
     if (value == null) {
@@ -129,12 +130,12 @@ public class PropertySetter extends ContextAwareBase {
    * Set the named property given a {@link PropertyDescriptor}.
    * 
    * @param prop
-   *                A PropertyDescriptor describing the characteristics of the
-   *                property to set.
+   *          A PropertyDescriptor describing the characteristics of the
+   *          property to set.
    * @param name
-   *                The named of the property to set.
+   *          The named of the property to set.
    * @param value
-   *                The value of the property.
+   *          The value of the property.
    */
   public void setProperty(PropertyDescriptor prop, String name, String value)
       throws PropertySetterException {
@@ -154,7 +155,7 @@ public class PropertySetter extends ContextAwareBase {
     Object arg;
 
     try {
-      arg = convertArg(value, paramTypes[0]);
+      arg = StringToObjectConverter.convertArg(this, value, paramTypes[0]);
     } catch (Throwable t) {
       throw new PropertySetterException("Conversion to type [" + paramTypes[0]
           + "] failed. ", t);
@@ -230,54 +231,19 @@ public class PropertySetter extends ContextAwareBase {
     Class<?> parameterClass = getParameterClassForMethod(method);
     if (parameterClass == null) {
       return AggregationType.NOT_FOUND;
-    } else {
-      Package p = parameterClass.getPackage();
-      if (parameterClass.isPrimitive()) {
-        return AggregationType.AS_BASIC_PROPERTY;
-      } else if (p != null && "java.lang".equals(p.getName())) {
-        return AggregationType.AS_BASIC_PROPERTY;
-      } else if (isBuildableFromString(parameterClass)) {
-        return AggregationType.AS_BASIC_PROPERTY;
-      } else if (parameterClass.isEnum()) {
-        return AggregationType.AS_BASIC_PROPERTY;
-      } else {
-        return AggregationType.AS_COMPLEX_PROPERTY;
-      }
     }
-  }
-
-  public Class findUnequivocallyInstantiableClass(
-      IADataForComplexProperty actionData) {
-    Class<?> clazz;
-    AggregationType at = actionData.getAggregationType();
-    switch (at) {
-    case AS_COMPLEX_PROPERTY:
-      Method setterMethod = findSetterMethod(actionData
-          .getComplexPropertyName());
-      clazz = getParameterClassForMethod(setterMethod);
-      if (clazz != null && isUnequivocallyInstantiable(clazz)) {
-        return clazz;
-      } else {
-        return null;
-      }
-    case AS_COMPLEX_PROPERTY_COLLECTION:
-      Method adderMethod = findAdderMethod(actionData.getComplexPropertyName());
-      clazz = getParameterClassForMethod(adderMethod);
-      if (clazz != null && isUnequivocallyInstantiable(clazz)) {
-        return clazz;
-      } else {
-        return null;
-      }
-    default:
-      throw new IllegalArgumentException(at
-          + " is not valid type in this method");
+    if (StringToObjectConverter.canBeBuiltFromSimpleString(parameterClass)) {
+      return AggregationType.AS_BASIC_PROPERTY;
+    } else {
+      return AggregationType.AS_COMPLEX_PROPERTY;
     }
   }
 
   /**
    * Can the given clazz instantiable with certainty?
    * 
-   * @param clazz The class to test for instantiability
+   * @param clazz
+   *          The class to test for instantiability
    * @return true if clazz can be instantiated, and false otherwise.
    */
   private boolean isUnequivocallyInstantiable(Class<?> clazz) {
@@ -353,7 +319,7 @@ public class PropertySetter extends ContextAwareBase {
 
     Object arg;
     try {
-      arg = convertArg(strValue, paramTypes[0]);
+      arg = StringToObjectConverter.convertArg(this, strValue, paramTypes[0]);
     } catch (Throwable t) {
       addError("Conversion to type [" + paramTypes[0] + "] failed. ", t);
       return;
@@ -424,77 +390,8 @@ public class PropertySetter extends ContextAwareBase {
     return name.substring(0, 1).toUpperCase() + name.substring(1);
   }
 
-  /**
-   * Convert <code>val</code> a String parameter to an object of a given type.
-   */
-  protected Object convertArg(String val, Class<?> type) {
-    if (val == null) {
-      return null;
-    }
-    String v = val.trim();
-    if (String.class.isAssignableFrom(type)) {
-      return v;
-    } else if (Integer.TYPE.isAssignableFrom(type)) {
-      return new Integer(v);
-    } else if (Long.TYPE.isAssignableFrom(type)) {
-      return new Long(v);
-    } else if (Float.TYPE.isAssignableFrom(type)) {
-      return new Float(v);
-    } else if (Double.TYPE.isAssignableFrom(type)) {
-      return new Double(v);
-    } else if (Boolean.TYPE.isAssignableFrom(type)) {
-      if ("true".equalsIgnoreCase(v)) {
-        return Boolean.TRUE;
-      } else if ("false".equalsIgnoreCase(v)) {
-        return Boolean.FALSE;
-      }
-    } else if (type.isEnum()) {
-      return convertEnum(v, type);
-    } else if (isBuildableFromString(type)) {
-      return buildFromString(type, v);
-    }
-
-    return null;
-  }
-
-  boolean isBuildableFromString(Class<?> parameterClass) {
-    try {
-      Method valueOfMethod = parameterClass.getMethod(CoreConstants.VALUE_OF,
-          STING_CLASS_PARAMETER);
-      int mod = valueOfMethod.getModifiers();
-      if (Modifier.isStatic(mod)) {
-        return true;
-      }
-    } catch (SecurityException e) {
-      // nop
-    } catch (NoSuchMethodException e) {
-      // nop
-    }
-    return false;
-  }
-
-  Object buildFromString(Class<?> type, String val) {
-    try {
-      Method valueOfMethod = type.getMethod(CoreConstants.VALUE_OF,
-          STING_CLASS_PARAMETER);
-      return valueOfMethod.invoke(null, val);
-    } catch (Exception e) {
-      addError("Failed to invoke " + CoreConstants.VALUE_OF
-          + "{} method in class [" + type.getName() + "] with value [" + val
-          + "]");
-      return null;
-    }
-  }
-
-  protected Object convertEnum(String val, Class<?> type) {
-    try {
-      Method m = type.getMethod(CoreConstants.VALUE_OF, STING_CLASS_PARAMETER);
-      return m.invoke(null, val);
-    } catch (Exception e) {
-      addError("Failed to convert value [" + val + "] to enum ["
-          + type.getName() + "]", e);
-    }
-    return null;
+  boolean isOfTypeCharset(Class<?> parameterClas) {
+    return Charset.class.isAssignableFrom(parameterClas);
   }
 
   protected Method getMethod(String methodName) {
@@ -566,14 +463,14 @@ public class PropertySetter extends ContextAwareBase {
   }
 
   Class getByConcreteType(String name, Method relevantMethod) {
-    
+
     Class<?> paramType = getParameterClassForMethod(relevantMethod);
     if (paramType == null) {
       return null;
     }
-    
+
     boolean isUnequivocallyInstantiable = isUnequivocallyInstantiable(paramType);
-    if(isUnequivocallyInstantiable) {
+    if (isUnequivocallyInstantiable) {
       return paramType;
     } else {
       return null;
@@ -584,8 +481,9 @@ public class PropertySetter extends ContextAwareBase {
   public Class getClassNameViaImplicitRules(String name,
       AggregationType aggregationType, DefaultNestedComponentRegistry registry) {
 
-    Class registryResult = registry.findDefaultComponentType(obj.getClass(), name);
-    if(registryResult!= null) {
+    Class registryResult = registry.findDefaultComponentType(obj.getClass(),
+        name);
+    if (registryResult != null) {
       return registryResult;
     }
     // find the relevant method for the given property name and aggregationType
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
new file mode 100644
index 0000000..8008f48
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
@@ -0,0 +1,135 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ * 
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ * 
+ * or (per the licensee's choosing)
+ * 
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.joran.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
+
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.spi.ContextAware;
+
+/**
+ * Utility class which can convert string into objects.
+ * @author Ceki G&uuml;lc&uuml;
+ *
+ */
+public class StringToObjectConverter {
+
+  private static final Class[] STING_CLASS_PARAMETER = new Class[] { String.class };
+
+  static public boolean canBeBuiltFromSimpleString(Class<?> parameterClass) {
+    Package p = parameterClass.getPackage();
+    if (parameterClass.isPrimitive()) {
+      return true;
+    } else if (p != null && "java.lang".equals(p.getName())) {
+      return true;
+    } else if (followsTheValueOfConvention(parameterClass)) {
+      return true;
+    } else if (parameterClass.isEnum()) {
+      return true;
+    }
+    return false;
+  }
+
+  /**
+   * Convert <code>val</code> a String parameter to an object of a given type.
+   */
+  @SuppressWarnings("unchecked")
+  public static Object convertArg(ContextAware ca, String val, Class<?> type) {
+    if (val == null) {
+      return null;
+    }
+    String v = val.trim();
+    if (String.class.isAssignableFrom(type)) {
+      return v;
+    } else if (Integer.TYPE.isAssignableFrom(type)) {
+      return new Integer(v);
+    } else if (Long.TYPE.isAssignableFrom(type)) {
+      return new Long(v);
+    } else if (Float.TYPE.isAssignableFrom(type)) {
+      return new Float(v);
+    } else if (Double.TYPE.isAssignableFrom(type)) {
+      return new Double(v);
+    } else if (Boolean.TYPE.isAssignableFrom(type)) {
+      if ("true".equalsIgnoreCase(v)) {
+        return Boolean.TRUE;
+      } else if ("false".equalsIgnoreCase(v)) {
+        return Boolean.FALSE;
+      }
+    } else if (type.isEnum()) {
+      return convertToEnum(ca, v, (Class<? extends Enum>) type);
+    } else if (StringToObjectConverter.followsTheValueOfConvention(type)) {
+      return convertByValueOfMethod(ca, type, v);
+    } else if (isOfTypeCharset(type)) {
+      return convertToCharset(ca, val);
+    }
+
+    return null;
+  }
+
+  static private boolean isOfTypeCharset(Class<?> type) {
+    return Charset.class.isAssignableFrom(type);
+  }
+
+  static private Charset convertToCharset(ContextAware ca, String val) {
+    try {
+      return Charset.forName(val);
+    } catch (UnsupportedCharsetException e) {
+      ca.addError("Failed to get charset [" + val + "]", e);
+      return null;
+    }
+  }
+
+  static private boolean followsTheValueOfConvention(Class<?> parameterClass) {
+    try {
+      Method valueOfMethod = parameterClass.getMethod(CoreConstants.VALUE_OF,
+          STING_CLASS_PARAMETER);
+      int mod = valueOfMethod.getModifiers();
+      if (Modifier.isStatic(mod)) {
+        return true;
+      }
+    } catch (SecurityException e) {
+      // nop
+    } catch (NoSuchMethodException e) {
+      // nop
+    }
+    return false;
+  }
+
+  private static Object convertByValueOfMethod(ContextAware ca, Class<?> type,
+      String val) {
+    try {
+      Method valueOfMethod = type.getMethod(CoreConstants.VALUE_OF,
+          STING_CLASS_PARAMETER);
+      return valueOfMethod.invoke(null, val);
+    } catch (Exception e) {
+      ca.addError("Failed to invoke " + CoreConstants.VALUE_OF
+          + "{} method in class [" + type.getName() + "] with value [" + val
+          + "]");
+      return null;
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static Object convertToEnum(ContextAware ca, String val,
+      Class<? extends Enum> enumType) {
+    return Enum.valueOf(enumType, val);
+  }
+
+  boolean isBuildableFromSimpleString() {
+    return false;
+  }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
index 7008f42..215a7b3 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
@@ -105,7 +105,7 @@ public class RollingFileAppender<E> extends FileAppender<E> {
       //
       // make sure to close the hereto active log file! Renaming under windows
       // does not work for open files.
-      this.closeWriter();
+      this.closeOutputStream();
 
       try {
         rollingPolicy.rollover();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
index e25d9d7..eea1422 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
@@ -101,7 +101,7 @@ public class WriterAppenderTest {
     encoder.setContext(context);
     
     wa.setEncoder(encoder);
-    wa.setWriter(baos);
+    wa.setOutputStream(baos);
     wa.start();
     
     wa.stop();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
index ef132f8..9321161 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
@@ -21,6 +21,6 @@ public class DummyWriterAppender<E> extends
     WriterAppender<E> {
 
   DummyWriterAppender(OutputStream os) {
-    this.setWriter(os);
+    this.setOutputStream(os);
   }
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
index a4d00d5..d65ac45 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
@@ -20,6 +20,7 @@ import org.junit.runners.Suite.SuiteClasses;
 @RunWith(Suite.class)
 @SuiteClasses({SkippingInInterpreterTest.class, TrivialConfiguratorTest.class, ch.qos.logback.core.joran.action.PackageTest.class,
   ch.qos.logback.core.joran.event.PackageTest.class,
+  ch.qos.logback.core.joran.util.PackageTest.class,
   ch.qos.logback.core.joran.spi.PackageTest.class,
   ch.qos.logback.core.joran.replay.PackageTest.class,
   ch.qos.logback.core.joran.implicitAction.PackageTest.class
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
index fca70f4..68de22c 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
@@ -16,10 +16,14 @@ package ch.qos.logback.core.joran.spi;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
+import java.awt.Window;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import ch.qos.logback.core.joran.util.House;
+
 public class DefaultNestedComponentRegistryTest {
 
   DefaultNestedComponentRegistry registry = new DefaultNestedComponentRegistry();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
index 07c691c..92bd15a 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
@@ -19,7 +19,7 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
-    PropertySetterTest.class, NoAutoStartUtilTest.class,
+    NoAutoStartUtilTest.class,
     DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
 public class PackageTest {
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
new file mode 100644
index 0000000..c2270b0
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
@@ -0,0 +1,158 @@
+package ch.qos.logback.core.joran.util;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.joran.spi.DefaultClass;
+import ch.qos.logback.core.spi.FilterReply;
+import ch.qos.logback.core.util.Duration;
+import ch.qos.logback.core.util.FileSize;
+
+public class House {
+  Door mainDoor;
+  int count;
+  boolean open;
+  String name;
+  String camelCase;
+  SwimmingPool pool;
+  Duration duration;
+  FileSize fs;
+  HouseColor houseColor;
+  FilterReply reply;
+
+  Charset charset;
+
+  List<String> adjectiveList = new ArrayList<String>();
+  List<Window> windowList = new ArrayList<Window>();
+  List<SwimmingPool> largePoolList = new ArrayList<SwimmingPool>();
+
+  public String getCamelCase() {
+    return camelCase;
+  }
+
+  public void setCamelCase(String camelCase) {
+    this.camelCase = camelCase;
+  }
+
+  public int getCount() {
+    return count;
+  }
+
+  public void setCount(int c) {
+    this.count = c;
+  }
+
+  public Door getDoor() {
+    return mainDoor;
+  }
+
+  public void setDoor(Door door) {
+    this.mainDoor = door;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public boolean isOpen() {
+    return open;
+  }
+
+  public void setOpen(boolean open) {
+    this.open = open;
+  }
+
+  @DefaultClass(LargeSwimmingPoolImpl.class)
+  public void addLargeSwimmingPool(SwimmingPool pool) {
+    this.pool = pool;
+  }
+
+  @DefaultClass(SwimmingPoolImpl.class)
+  public void setSwimmingPool(SwimmingPool pool) {
+    this.pool = pool;
+  }
+
+  public SwimmingPool getSwimmingPool() {
+    return pool;
+  }
+
+  public void addWindow(Window w) {
+    windowList.add(w);
+  }
+
+  public void addAdjective(String s) {
+    adjectiveList.add(s);
+  }
+
+  public Duration getDuration() {
+    return duration;
+  }
+
+  public void setDuration(Duration duration) {
+    this.duration = duration;
+  }
+
+  public FileSize getFs() {
+    return fs;
+  }
+
+  public void setFs(FileSize fs) {
+    this.fs = fs;
+  }
+
+  public void setHouseColor(HouseColor color) {
+    this.houseColor = color;
+  }
+
+  public HouseColor getHouseColor() {
+    return houseColor;
+  }
+
+  public void setFilterReply(FilterReply reply) {
+    this.reply = reply;
+  }
+
+  public FilterReply getFilterReply() {
+    return reply;
+  }
+
+  public Charset getCharset() {
+    return charset;
+  }
+
+  public void setCharset(Charset charset) {
+    this.charset = charset;
+  }
+}
+
+class Door {
+  int handle;
+}
+
+class Window {
+  int handle;
+}
+
+interface SwimmingPool {
+}
+
+class SwimmingPoolImpl implements SwimmingPool {
+  int length;
+  int width;
+  int depth;
+}
+
+class LargeSwimmingPoolImpl implements SwimmingPool {
+  int length;
+  int width;
+  int depth;
+}
+
+enum HouseColor {
+  WHITE, BLUE
+}
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
similarity index 73%
copy from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
copy to logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
index 07c691c..feb3d0a 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
@@ -11,15 +11,13 @@
  * under the terms of the GNU Lesser General Public License version 2.1
  * as published by the Free Software Foundation.
  */
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
-    PropertySetterTest.class, NoAutoStartUtilTest.class,
-    DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
+ at SuiteClasses( { StringToObjectConverterTest.class, PropertySetterTest.class })
 public class PackageTest {
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
similarity index 65%
rename from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
rename to logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
index 9436b87..0ac9396 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
@@ -11,33 +11,43 @@
  * under the terms of the GNU Lesser General Public License version 2.1
  * as published by the Free Software Foundation.
  */
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
 
+import org.junit.Before;
 import org.junit.Test;
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
 import ch.qos.logback.core.spi.FilterReply;
+import ch.qos.logback.core.status.StatusChecker;
 import ch.qos.logback.core.util.AggregationType;
-import ch.qos.logback.core.util.Duration;
-import ch.qos.logback.core.util.FileSize;
 
 public class PropertySetterTest {
 
   DefaultNestedComponentRegistry defaultComponentRegistry = new DefaultNestedComponentRegistry();
 
+  Context context = new ContextBase();
+  House house = new House();
+  PropertySetter setter = new PropertySetter(house);
+ 
+  
+  @Before
+  public void setUp() {
+    setter.setContext(context);
+  }
+  
   @Test
   public void testCanAggregateComponent() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     assertEquals(AggregationType.AS_COMPLEX_PROPERTY, setter
         .computeAggregationType("door"));
 
@@ -103,9 +113,6 @@ public class PropertySetterTest {
 
   @Test
   public void testSetCamelProperty() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
-
     setter.setProperty("camelCase", "trot");
     assertEquals("trot", house.getCamelCase());
 
@@ -115,17 +122,13 @@ public class PropertySetterTest {
 
   @Test
   public void testSetComplexProperty() {
-    House house = new House();
     Door door = new Door();
-    PropertySetter setter = new PropertySetter(house);
     setter.setComplexProperty("door", door);
     assertEquals(door, house.getDoor());
   }
 
   @Test
   public void testgetClassNameViaImplicitRules() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     Class compClass = setter.getClassNameViaImplicitRules("door",
         AggregationType.AS_COMPLEX_PROPERTY, defaultComponentRegistry);
     assertEquals(Door.class, compClass);
@@ -133,8 +136,6 @@ public class PropertySetterTest {
 
   @Test
   public void testgetComplexPropertyColleClassNameViaImplicitRules() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     Class compClass = setter.getClassNameViaImplicitRules("window",
         AggregationType.AS_COMPLEX_PROPERTY_COLLECTION,
         defaultComponentRegistry);
@@ -143,10 +144,6 @@ public class PropertySetterTest {
 
   @Test
   public void testPropertyCollection() {
-    House house = new House();
-    Context context = new ContextBase();
-    PropertySetter setter = new PropertySetter(house);
-    setter.setContext(context);
     setter.addBasicProperty("adjective", "nice");
     setter.addBasicProperty("adjective", "big");
 
@@ -157,8 +154,6 @@ public class PropertySetterTest {
 
   @Test
   public void testComplexCollection() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     Window w1 = new Window();
     w1.handle = 10;
     Window w2 = new Window();
@@ -173,25 +168,19 @@ public class PropertySetterTest {
 
   @Test
   public void testSetComplexWithCamelCaseName() {
-    House house = new House();
     SwimmingPool pool = new SwimmingPoolImpl();
-    PropertySetter setter = new PropertySetter(house);
     setter.setComplexProperty("swimmingPool", pool);
     assertEquals(pool, house.getSwimmingPool());
   }
 
   @Test
   public void testDuration() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     setter.setProperty("duration", "1.4 seconds");
     assertEquals(1400, house.getDuration().getMilliseconds());
   }
 
   @Test
   public void testFileSize() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     setter.setProperty("fs", "2 kb");
     assertEquals(2 * 1024, house.getFs().getSize());
   }
@@ -199,24 +188,18 @@ public class PropertySetterTest {
   @Test
   public void testFilterReply() {
     // test case reproducing bug #52
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     setter.setProperty("filterReply", "ACCEPT");
     assertEquals(FilterReply.ACCEPT, house.getFilterReply());
   }
 
   @Test
   public void testEnum() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     setter.setProperty("houseColor", "BLUE");
     assertEquals(HouseColor.BLUE, house.getHouseColor());
   }
 
   @Test
   public void testDefaultClassAnnonation() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     Method relevantMethod = setter.getRelevantMethod("SwimmingPool",
         AggregationType.AS_COMPLEX_PROPERTY);
     assertNotNull(relevantMethod);
@@ -232,8 +215,6 @@ public class PropertySetterTest {
   
   @Test
   public void testDefaultClassAnnotationForLists() {
-    House house = new House();
-    PropertySetter setter = new PropertySetter(house);
     Method relevantMethod = setter.getRelevantMethod("LargeSwimmingPool",
         AggregationType.AS_COMPLEX_PROPERTY_COLLECTION);
     assertNotNull(relevantMethod);
@@ -245,145 +226,19 @@ public class PropertySetterTest {
         "LargeSwimmingPool", AggregationType.AS_COMPLEX_PROPERTY_COLLECTION,
         defaultComponentRegistry);
     assertEquals(LargeSwimmingPoolImpl.class, classViaImplicitRules);
-    
-  }
-}
-
-class House {
-  Door mainDoor;
-  int count;
-  boolean open;
-  String name;
-  String camelCase;
-  SwimmingPool pool;
-  Duration duration;
-  FileSize fs;
-  HouseColor houseColor;
-  FilterReply reply;
-
-  List<String> adjectiveList = new ArrayList<String>();
-  List<Window> windowList = new ArrayList<Window>();
-  List<SwimmingPool> largePoolList = new ArrayList<SwimmingPool>();
-
-  public String getCamelCase() {
-    return camelCase;
-  }
-
-  public void setCamelCase(String camelCase) {
-    this.camelCase = camelCase;
-  }
-
-  public int getCount() {
-    return count;
-  }
-
-  public void setCount(int c) {
-    this.count = c;
-  }
-
-  public Door getDoor() {
-    return mainDoor;
-  }
-
-  public void setDoor(Door door) {
-    this.mainDoor = door;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public boolean isOpen() {
-    return open;
-  }
-
-  public void setOpen(boolean open) {
-    this.open = open;
-  }
-
-  @DefaultClass(LargeSwimmingPoolImpl.class)
-  public void addLargeSwimmingPool(SwimmingPool pool) {
-    this.pool = pool;
-  }
-
-  @DefaultClass(SwimmingPoolImpl.class)
-  public void setSwimmingPool(SwimmingPool pool) {
-    this.pool = pool;
-  }
-
-  public SwimmingPool getSwimmingPool() {
-    return pool;
-  }
-
-  public void addWindow(Window w) {
-    windowList.add(w);
-  }
-
-  public void addAdjective(String s) {
-    adjectiveList.add(s);
-  }
-
-  public Duration getDuration() {
-    return duration;
-  }
-
-  public void setDuration(Duration duration) {
-    this.duration = duration;
-  }
-
-  public FileSize getFs() {
-    return fs;
-  }
-
-  public void setFs(FileSize fs) {
-    this.fs = fs;
-  }
-
-  public void setHouseColor(HouseColor color) {
-    this.houseColor = color;
-  }
-
-  public HouseColor getHouseColor() {
-    return houseColor;
-  }
-
-  public void setFilterReply(FilterReply reply) {
-    this.reply = reply;
   }
+  
+  @Test
+  public void charset() {
+    setter.setProperty("charset", "UTF-8");
+    assertEquals(Charset.forName("UTF-8"), house.getCharset());
+    
+    house.setCharset(null);
+    setter.setProperty("charset", "UTF");
+    assertNull(house.getCharset());
 
-  public FilterReply getFilterReply() {
-    return reply;
+    StatusChecker checker = new StatusChecker(context);
+    checker.containsException(UnsupportedCharsetException.class);
   }
-
-}
-
-class Door {
-  int handle;
-}
-
-class Window {
-  int handle;
-}
-
-interface SwimmingPool {
-}
-
-class SwimmingPoolImpl implements SwimmingPool {
-  int length;
-  int width;
-  int depth;
-}
-
-class LargeSwimmingPoolImpl implements SwimmingPool {
-  int length;
-  int width;
-  int depth;
 }
 
-enum HouseColor {
-  WHITE, BLUE
-}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java
new file mode 100644
index 0000000..48886ea
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.core.joran.util;
+
+import org.junit.Test;
+
+public class StringToObjectConverterTest {
+
+  
+  
+  @Test 
+  public void doubleTest() {
+    fail("s");
+  }
+}
diff --git a/logback-examples/src/main/java/chapter4/ExitWoes1.java b/logback-examples/src/main/java/chapter4/ExitWoes1.java
index a265137..b14a36e 100644
--- a/logback-examples/src/main/java/chapter4/ExitWoes1.java
+++ b/logback-examples/src/main/java/chapter4/ExitWoes1.java
@@ -34,7 +34,7 @@ public class ExitWoes1 {
     writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
 
     OutputStream os = new FileOutputStream("exitWoes1.log");
-    writerAppender.setWriter(os);
+    writerAppender.setOutputStream(os);
     writerAppender.setImmediateFlush(false);
     writerAppender.start();
     Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
diff --git a/logback-examples/src/main/java/chapter4/ExitWoes2.java b/logback-examples/src/main/java/chapter4/ExitWoes2.java
index ab2b89c..d95631a 100644
--- a/logback-examples/src/main/java/chapter4/ExitWoes2.java
+++ b/logback-examples/src/main/java/chapter4/ExitWoes2.java
@@ -35,7 +35,7 @@ public class ExitWoes2 {
     writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
 
     OutputStream os = new FileOutputStream("exitWoes2.log");
-    writerAppender.setWriter(os);
+    writerAppender.setOutputStream(os);
     writerAppender.setImmediateFlush(false);
     writerAppender.start();
     Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);

-----------------------------------------------------------------------

Summary of changes:
 .../ch/qos/logback/classic/AllClassicTest.java     |    1 +
 .../classic/{control => encoder}/PackageTest.java  |    5 +-
 .../classic/encoder/PatternLayoutEncoderTest.java  |   59 ++++++
 .../java/ch/qos/logback/core/ConsoleAppender.java  |    4 +-
 .../java/ch/qos/logback/core/FileAppender.java     |    2 +-
 .../java/ch/qos/logback/core/WriterAppender.java   |   89 +++------
 .../core/db/BindDataSourceToJNDIAction.java        |    2 +-
 .../logback/core/html/LayoutWrappingEncoder.java   |   61 +++++--
 .../core/joran/action/IADataForBasicProperty.java  |    2 +-
 .../joran/action/IADataForComplexProperty.java     |    2 +-
 .../core/joran/action/NestedBasicPropertyIA.java   |    2 +-
 .../core/joran/action/NestedComplexPropertyIA.java |    2 +-
 .../qos/logback/core/joran/action/ParamAction.java |    2 +-
 .../core/joran/{spi => util}/PropertySetter.java   |  170 ++++-------------
 .../core/joran/util/StringToObjectConverter.java   |  135 +++++++++++++
 .../logback/core/rolling/RollingFileAppender.java  |    2 +-
 .../ch/qos/logback/core/WriterAppenderTest.java    |    2 +-
 .../logback/core/appender/DummyWriterAppender.java |    2 +-
 .../ch/qos/logback/core/joran/PackageTest.java     |    1 +
 .../spi/DefaultNestedComponentRegistryTest.java    |    4 +
 .../ch/qos/logback/core/joran/spi/PackageTest.java |    2 +-
 .../java/ch/qos/logback/core/joran/util/House.java |  158 +++++++++++++++
 .../logback/core/{ => joran/util}/PackageTest.java |    4 +-
 .../joran/{spi => util}/PropertySetterTest.java    |  201 +++-----------------
 .../joran/util/StringToObjectConverterTest.java    |   13 ++
 .../src/main/java/chapter4/ExitWoes1.java          |    2 +-
 .../src/main/java/chapter4/ExitWoes2.java          |    2 +-
 27 files changed, 530 insertions(+), 401 deletions(-)
 copy logback-classic/src/test/java/ch/qos/logback/classic/{control => encoder}/PackageTest.java (87%)
 create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
 rename logback-core/src/main/java/ch/qos/logback/core/joran/{spi => util}/PropertySetter.java (74%)
 create mode 100644 logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
 copy logback-core/src/test/java/ch/qos/logback/core/{ => joran/util}/PackageTest.java (84%)
 rename logback-core/src/test/java/ch/qos/logback/core/joran/{spi => util}/PropertySetterTest.java (65%)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list