logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1506631 - in /logging/log4j/log4j2/trunk/core/src: main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
Date Wed, 24 Jul 2013 17:14:50 GMT
Author: ggregory
Date: Wed Jul 24 17:14:50 2013
New Revision: 1506631

URL: http://svn.apache.org/r1506631
Log:
Test something else than the default content type. No need to compute the content type on
the fly, use the existing content type ivar.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1506631&r1=1506630&r2=1506631&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
Wed Jul 24 17:14:50 2013
@@ -99,7 +99,7 @@ public final class HTMLLayout extends Ab
     private final String headerSize;
 
     private HTMLLayout(final boolean locationInfo, final String title, final String contentType,
final Charset charset,
-                       final String font, final String fontSize, final String headerSize)
{
+            final String font, final String fontSize, final String headerSize) {
         super(charset);
         this.locationInfo = locationInfo;
         this.title = title;
@@ -208,7 +208,7 @@ public final class HTMLLayout extends Ab
      * @return The content type.
      */
     public String getContentType() {
-        return "text/html; charset=" + this.getCharset();
+        return contentType;
     }
 
     private void appendThrowableAsHTML(final Throwable throwable, final StringBuilder sbuf)
{
@@ -330,7 +330,7 @@ public final class HTMLLayout extends Ab
             title = DEFAULT_TITLE;
         }
         if (contentType == null) {
-            contentType = DEFAULT_CONTENT_TYPE;
+            contentType = DEFAULT_CONTENT_TYPE + "; charset=" + charset;
         }
         return new HTMLLayout(info, title, contentType, charset, font, fontSize, headerSize);
     }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java?rev=1506631&r1=1506630&r2=1506631&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/layout/HTMLLayoutTest.java
Wed Jul 24 17:14:50 2013
@@ -68,6 +68,12 @@ public class HTMLLayoutTest {
     }
     
     @Test
+    public void testContentType() {
+        final HTMLLayout layout = HTMLLayout.createLayout("true", null, "text/html; charset=UTF-16",
null, "small", null);
+        assertEquals("text/html; charset=UTF-16", layout.getContentType());
+    }
+    
+    @Test
     public void testDefaultCharset() {
         final HTMLLayout layout = HTMLLayout.createLayout("true", null, null, null, "small",
null);
         assertEquals(Charsets.UTF_8, layout.getCharset());



Mime
View raw message