logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwilli...@apache.org
Subject svn commit: r1483644 - in /logging/log4j/log4j2/trunk/core/src: main/java/org/apache/logging/log4j/core/appender/db/jdbc/ test/java/org/apache/logging/log4j/core/appender/db/jdbc/ test/resources/org/apache/logging/log4j/core/appender/db/jdbc/
Date Fri, 17 May 2013 04:04:18 GMT
Author: nickwilliams
Date: Fri May 17 04:04:17 2013
New Revision: 1483644

URL: http://svn.apache.org/r1483644
Log:
Added unicode and clob support to the JDBCAppender.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JDBCDatabaseManager.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-driver-manager.xml
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-driver-manager.xml
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfig.java
Fri May 17 04:04:17 2013
@@ -33,16 +33,20 @@ public final class ColumnConfig {
     private static final Logger LOGGER = StatusLogger.getLogger();
 
     private final String columnName;
-    private final boolean eventTimestamp;
     private final PatternLayout layout;
     private final String literalValue;
+    private final boolean eventTimestamp;
+    private final boolean unicode;
+    private final boolean clob;
 
     private ColumnConfig(final String columnName, final PatternLayout layout, final String
literalValue,
-                         final boolean eventDate) {
+                         final boolean eventDate, final boolean unicode, final boolean clob)
{
         this.columnName = columnName;
         this.layout = layout;
         this.literalValue = literalValue;
         this.eventTimestamp = eventDate;
+        this.unicode = unicode;
+        this.clob = clob;
     }
 
     public String getColumnName() {
@@ -61,6 +65,14 @@ public final class ColumnConfig {
         return this.eventTimestamp;
     }
 
+    public boolean isUnicode() {
+        return this.unicode;
+    }
+
+    public boolean isClob() {
+        return this.clob;
+    }
+
     @Override
     public String toString() {
         return "{ name=" + this.columnName + ", layout=" + this.layout + ", literal=" + this.literalValue
@@ -86,29 +98,36 @@ public final class ColumnConfig {
                                                   @PluginAttr("name") final String name,
                                                   @PluginAttr("pattern") final String pattern,
                                                   @PluginAttr("literal") final String literalValue,
-                                                  @PluginAttr("isEventTimestamp") final String
eventTimestamp) {
+                                                  @PluginAttr("isEventTimestamp") final String
eventTimestamp,
+                                                  @PluginAttr("isUnicode") final String unicode,
+                                                  @PluginAttr("isClob") final String clob)
{
         if (name == null || name.length() == 0) {
             LOGGER.error("The column config is not valid because it does not contain a column
name.");
             return null;
         }
 
-        final boolean isEventTimestamp = eventTimestamp != null && Boolean.parseBoolean(eventTimestamp);
-        final boolean isLiteralValue = literalValue != null && literalValue.length()
> 0;
         final boolean isPattern = pattern != null && pattern.length() > 0;
+        final boolean isLiteralValue = literalValue != null && literalValue.length()
> 0;
+        final boolean isEventTimestamp = eventTimestamp != null && Boolean.parseBoolean(eventTimestamp);
+        final boolean isUnicode = unicode == null || unicode.length() == 0 || Boolean.parseBoolean(unicode);
+        final boolean isClob = clob != null && Boolean.parseBoolean(clob);
 
-        if ((isEventTimestamp && isLiteralValue) || (isEventTimestamp &&
isPattern) || (isLiteralValue && isPattern)) {
+        if ((isPattern && isLiteralValue) || (isPattern && isEventTimestamp)
|| (isLiteralValue && isEventTimestamp)) {
             LOGGER.error("The pattern, literal, and isEventTimestamp attributes are mutually
exclusive.");
             return null;
         }
 
         if (isEventTimestamp) {
-            return new ColumnConfig(name, null, null, true);
+            return new ColumnConfig(name, null, null, true, false, false);
         }
         if (isLiteralValue) {
-            return new ColumnConfig(name, null, literalValue, false);
+            return new ColumnConfig(name, null, literalValue, false, false, false);
         }
         if (isPattern) {
-            return new ColumnConfig(name, PatternLayout.createLayout(pattern, config, null,
null, "true"), null, false);
+            return new ColumnConfig(
+                    name, PatternLayout.createLayout(pattern, config, null, null, "true"),
null, false, isUnicode,
+                    isClob
+            );
         }
 
         LOGGER.error("To configure a column you must specify a pattern or literal or set
isEventDate to true.");

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JDBCDatabaseManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JDBCDatabaseManager.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JDBCDatabaseManager.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JDBCDatabaseManager.java
Fri May 17 04:04:17 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.core.appender.db.jdbc;
 
+import java.io.StringReader;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
@@ -81,6 +82,7 @@ public final class JDBCDatabaseManager e
 
     @Override
     protected void writeInternal(final LogEvent event) {
+        StringReader reader = null;
         try {
             if (!this.isConnected() || this.connection == null || this.connection.isClosed())
{
                 LOGGER.error("Cannot write logging event; manager [{}] not connected to the
database.", this.getName());
@@ -92,7 +94,20 @@ public final class JDBCDatabaseManager e
                 if (column.isEventTimestamp) {
                     this.statement.setTimestamp(i++, new Timestamp(event.getMillis()));
                 } else {
-                    this.statement.setString(i++, column.layout.toSerializable(event));
+                    if (column.isClob) {
+                        reader = new StringReader(column.layout.toSerializable(event));
+                        if (column.isUnicode) {
+                            this.statement.setNClob(i++, reader);
+                        } else {
+                            this.statement.setClob(i++, reader);
+                        }
+                    } else {
+                        if (column.isUnicode) {
+                            this.statement.setNString(i++, column.layout.toSerializable(event));
+                        } else {
+                            this.statement.setString(i++, column.layout.toSerializable(event));
+                        }
+                    }
                 }
             }
 
@@ -101,6 +116,10 @@ public final class JDBCDatabaseManager e
             }
         } catch (final SQLException e) {
             LOGGER.error("Failed to insert record for log event in manager [{}].", this.getName(),
e);
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
         }
     }
 
@@ -162,7 +181,9 @@ public final class JDBCDatabaseManager e
                 if (config.getLiteralValue() != null) {
                     valuePart.append(config.getLiteralValue());
                 } else {
-                    columns.add(new Column(config.getLayout(), config.isEventTimestamp()));
+                    columns.add(new Column(
+                            config.getLayout(), config.isEventTimestamp(), config.isUnicode(),
config.isClob()
+                    ));
                     valuePart.append('?');
                 }
             }
@@ -178,12 +199,17 @@ public final class JDBCDatabaseManager e
      * Encapsulates information about a database column and how to persist data to it.
      */
     private static final class Column {
-        private final boolean isEventTimestamp;
         private final PatternLayout layout;
+        private final boolean isEventTimestamp;
+        private final boolean isUnicode;
+        private final boolean isClob;
 
-        private Column(final PatternLayout layout, final boolean isEventDate) {
+        private Column(final PatternLayout layout, final boolean isEventDate, final boolean
isUnicode,
+                       final boolean isClob) {
             this.layout = layout;
             this.isEventTimestamp = isEventDate;
+            this.isUnicode = isUnicode;
+            this.isClob = isClob;
         }
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
Fri May 17 04:04:17 2013
@@ -34,6 +34,7 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.DefaultConfiguration;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.easymock.IAnswer;
+import org.h2.util.IOUtils;
 import org.junit.After;
 import org.junit.Test;
 import org.mockejb.jndi.MockContextFactory;
@@ -51,6 +52,8 @@ public abstract class AbstractJdbcAppend
 
     protected abstract Connection newConnection() throws SQLException;
 
+    protected abstract String toCreateTableSqlString(final String tableName);
+
     protected void setUp(final String tableName, final String configFileName) throws SQLException
{
         this.connection = this.newConnection();
         final Statement statement = this.connection.createStatement();
@@ -147,11 +150,12 @@ public abstract class AbstractJdbcAppend
             assertTrue("The date should be earlier than now (1).", date <= System.currentTimeMillis());
             assertEquals("The literal column is not correct (1).", "Literal Value of Data
Source",
                     resultSet.getString("literalColumn"));
-            assertEquals("The level column is not correct (1).", "FATAL", resultSet.getString("level"));
-            assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getString("logger"));
+            assertEquals("The level column is not correct (1).", "FATAL", resultSet.getNString("level"));
+            assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getNString("logger"));
             assertEquals("The message column is not correct (1).", "Error from data source
02.",
                     resultSet.getString("message"));
-            assertEquals("The exception column is not correct (1).", stackTrace, resultSet.getString("exception"));
+            assertEquals("The exception column is not correct (1).", stackTrace,
+                    IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(),
-1));
 
             assertFalse("There should not be two rows.", resultSet.next());
 
@@ -162,7 +166,7 @@ public abstract class AbstractJdbcAppend
     }
 
     @Test
-    public void testDriverManagerConfig() throws SQLException {
+    public void testDriverManagerConfig() throws Exception {
         this.setUp("dmLogEntry", "log4j2-" + this.databaseType + "-driver-manager.xml");
 
         final RuntimeException exception = new RuntimeException("Hello, world!");
@@ -188,10 +192,11 @@ public abstract class AbstractJdbcAppend
         assertTrue("The date should be earlier than now (1).", date <= System.currentTimeMillis());
         assertEquals("The literal column is not correct (1).", "Literal Value Test String",
                 resultSet.getString("literalColumn"));
-        assertEquals("The level column is not correct (1).", "INFO", resultSet.getString("level"));
-        assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getString("logger"));
+        assertEquals("The level column is not correct (1).", "INFO", resultSet.getNString("level"));
+        assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getNString("logger"));
         assertEquals("The message column is not correct (1).", "Test my message 01.", resultSet.getString("message"));
-        assertEquals("The exception column is not correct (1).", "", resultSet.getString("exception"));
+        assertEquals("The exception column is not correct (1).", "",
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(),
-1));
 
         assertTrue("There should be two rows.", resultSet.next());
 
@@ -200,17 +205,18 @@ public abstract class AbstractJdbcAppend
         assertTrue("The date should be earlier than now (2).", date <= System.currentTimeMillis());
         assertEquals("The literal column is not correct (2).", "Literal Value Test String",
                 resultSet.getString("literalColumn"));
-        assertEquals("The level column is not correct (2).", "WARN", resultSet.getString("level"));
-        assertEquals("The logger column is not correct (2).", logger.getName(), resultSet.getString("logger"));
+        assertEquals("The level column is not correct (2).", "WARN", resultSet.getNString("level"));
+        assertEquals("The logger column is not correct (2).", logger.getName(), resultSet.getNString("logger"));
         assertEquals("The message column is not correct (2).", "This is another message 02.",
                 resultSet.getString("message"));
-        assertEquals("The exception column is not correct (2).", stackTrace, resultSet.getString("exception"));
+        assertEquals("The exception column is not correct (2).", stackTrace,
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(),
-1));
 
         assertFalse("There should not be three rows.", resultSet.next());
     }
 
     @Test
-    public void testFactoryMethodConfig() throws SQLException {
+    public void testFactoryMethodConfig() throws Exception {
         this.setUp("fmLogEntry", "log4j2-" + this.databaseType + "-factory-method.xml");
 
         final SQLException exception = new SQLException("Some other error message!");
@@ -236,11 +242,12 @@ public abstract class AbstractJdbcAppend
         assertTrue("The date should be earlier than now (1).", date <= System.currentTimeMillis());
         assertEquals("The literal column is not correct (1).", "Some Other Literal Value",
                 resultSet.getString("literalColumn"));
-        assertEquals("The level column is not correct (1).", "DEBUG", resultSet.getString("level"));
-        assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getString("logger"));
+        assertEquals("The level column is not correct (1).", "DEBUG", resultSet.getNString("level"));
+        assertEquals("The logger column is not correct (1).", logger.getName(), resultSet.getNString("logger"));
         assertEquals("The message column is not correct (1).", "Factory logged message 01.",
                 resultSet.getString("message"));
-        assertEquals("The exception column is not correct (1).", "", resultSet.getString("exception"));
+        assertEquals("The exception column is not correct (1).", "",
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(),
-1));
 
         assertTrue("There should be two rows.", resultSet.next());
 
@@ -249,17 +256,13 @@ public abstract class AbstractJdbcAppend
         assertTrue("The date should be earlier than now (2).", date <= System.currentTimeMillis());
         assertEquals("The literal column is not correct (2).", "Some Other Literal Value",
                 resultSet.getString("literalColumn"));
-        assertEquals("The level column is not correct (2).", "ERROR", resultSet.getString("level"));
-        assertEquals("The logger column is not correct (2).", logger.getName(), resultSet.getString("logger"));
-        assertEquals("The message column is not correct (2).", "Error from factory 02.",
resultSet.getString("message"));
-        assertEquals("The exception column is not correct (2).", stackTrace, resultSet.getString("exception"));
+        assertEquals("The level column is not correct (2).", "ERROR", resultSet.getNString("level"));
+        assertEquals("The logger column is not correct (2).", logger.getName(), resultSet.getNString("logger"));
+        assertEquals("The message column is not correct (2).", "Error from factory 02.",
+                resultSet.getString("message"));
+        assertEquals("The exception column is not correct (2).", stackTrace,
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(),
-1));
 
         assertFalse("There should not be three rows.", resultSet.next());
     }
-
-    protected String toCreateTableSqlString(final String tableName) {
-        return "CREATE TABLE " + tableName + " ( "
-                + "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level
VARCHAR(10), "
-                + "logger VARCHAR(255), message VARCHAR(1024), exception VARCHAR(1048576)"
+ " )";
-    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/ColumnConfigTest.java
Fri May 17 04:04:17 2013
@@ -35,78 +35,91 @@ public class ColumnConfigTest {
 
     @Test
     public void testNullNameNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, null, "%l", null,
null);
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, null, "%l", null,
null, null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testPatternAndLiteralNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
"%l", "literal", null);
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", "%l", "literal", null,
null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testPatternAndDateNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
"%l", null, "true");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", "%l", null, "true",
null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testLiteralAndDateNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
null, "literal", "true");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", null, "literal", "true",
null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testNoSettingNoConfig01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
null, null, null);
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", null, null, null, null,
null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testNoSettingNoConfig02() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
null, null, "false");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", null, null, "false",
null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testNoSettingNoConfig03() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
"", "", "");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", "", "", "", null, null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
     public void testDateColumn01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
null, null, "true");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", null, null, "true",
null, null);
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "columnName01", config.getColumnName());
         assertNull("The pattern should be null.", config.getLayout());
         assertNull("The literal value should be null.", config.getLiteralValue());
         assertTrue("The timestamp flag should be true.", config.isEventTimestamp());
+        assertFalse("The unicode flag should be false.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 
     @Test
     public void testDateColumn02() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02",
null, null, "true");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "anotherName02", null, null, "true",
"true", "true");
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "anotherName02", config.getColumnName());
         assertNull("The pattern should be null.", config.getLayout());
         assertNull("The literal value should be null.", config.getLiteralValue());
         assertTrue("The timestamp flag should be true.", config.isEventTimestamp());
+        assertFalse("The unicode flag should be false.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 
     @Test
     public void testPatternColumn01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
"%l", null, null);
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", "%l", null, null, null,
null);
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "columnName01", config.getColumnName());
@@ -114,12 +127,14 @@ public class ColumnConfigTest {
         assertEquals("The pattern is not correct.", "%l", config.getLayout().toString());
         assertNull("The literal value should be null.", config.getLiteralValue());
         assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
+        assertTrue("The unicode flag should be true.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 
     @Test
     public void testPatternColumn02() {
-        final ColumnConfig config = ColumnConfig
-                .createColumnConfig(null, "anotherName02", "%X{id} %level", "", "false");
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "anotherName02", "%X{id} %level", "",
"false", "false", "true");
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "anotherName02", config.getColumnName());
@@ -127,11 +142,29 @@ public class ColumnConfigTest {
         assertEquals("The pattern is not correct.", "%X{id} %level", config.getLayout().toString());
         assertNull("The literal value should be null.", config.getLiteralValue());
         assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
+        assertFalse("The unicode flag should be false.", config.isUnicode());
+        assertTrue("The clob flag should be true.", config.isClob());
+    }
+
+    @Test
+    public void testPatternColumn03() {
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "anotherName02", "%X{id} %level", "",
"false", "true", "false");
+
+        assertNotNull("The result should not be null.", config);
+        assertEquals("The column name is not correct.", "anotherName02", config.getColumnName());
+        assertNotNull("The pattern should not be null.", config.getLayout());
+        assertEquals("The pattern is not correct.", "%X{id} %level", config.getLayout().toString());
+        assertNull("The literal value should be null.", config.getLiteralValue());
+        assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
+        assertTrue("The unicode flag should be true.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 
     @Test
     public void testLiteralColumn01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01",
null, "literalValue01", null);
+        final ColumnConfig config =
+                ColumnConfig.createColumnConfig(null, "columnName01", null, "literalValue01",
null, null, null);
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "columnName01", config.getColumnName());
@@ -139,12 +172,15 @@ public class ColumnConfigTest {
         assertNotNull("The literal value should be null.", config.getLiteralValue());
         assertEquals("The literal value is not correct.", "literalValue01", config.getLiteralValue());
         assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
+        assertFalse("The unicode flag should be false.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 
     @Test
     public void testLiteralColumn02() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02",
null,
-                "USER1.MY_SEQUENCE.NEXT", null);
+        final ColumnConfig config = ColumnConfig.createColumnConfig(
+                null, "anotherName02", null, "USER1.MY_SEQUENCE.NEXT", null, "true", "true"
+        );
 
         assertNotNull("The result should not be null.", config);
         assertEquals("The column name is not correct.", "anotherName02", config.getColumnName());
@@ -152,5 +188,7 @@ public class ColumnConfigTest {
         assertNotNull("The literal value should be null.", config.getLiteralValue());
         assertEquals("The literal value is not correct.", "USER1.MY_SEQUENCE.NEXT", config.getLiteralValue());
         assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
+        assertFalse("The unicode flag should be false.", config.isUnicode());
+        assertFalse("The clob flag should be false.", config.isClob());
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
Fri May 17 04:04:17 2013
@@ -43,4 +43,12 @@ public class JdbcH2AppenderTest extends 
     protected Connection newConnection() throws SQLException {
         return DriverManager.getConnection("jdbc:h2:mem:Log4j", USER_ID, PASSWORD);
     }
+
+    @Override
+    protected String toCreateTableSqlString(String tableName) {
+        return "CREATE TABLE " + tableName + " ( " +
+                    "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255),
level NVARCHAR(10), " +
+                    "logger NVARCHAR(255), message VARCHAR(1024), exception NCLOB" +
+                " )";
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
Fri May 17 04:04:17 2013
@@ -43,4 +43,12 @@ public class JdbcHyperSqlAppenderTest ex
     protected Connection newConnection() throws SQLException {
         return DriverManager.getConnection("jdbc:hsqldb:mem:Log4j", USER_ID, PASSWORD);
     }
+
+    @Override
+    protected String toCreateTableSqlString(String tableName) {
+        return "CREATE TABLE " + tableName + " ( " +
+                    "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255),
level VARCHAR(10), " +
+                    "logger VARCHAR(255), message VARCHAR(1024), exception CLOB" +
+                " )";
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml
Fri May 17 04:04:17 2013
@@ -27,8 +27,8 @@
       <Column name="literalColumn" literal="'Literal Value of Data Source'" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
-      <Column name="message" pattern="%message" />
-      <Column name="exception" pattern="%ex{full}" />
+      <Column name="message" pattern="%message" isUnicode="false" />
+      <Column name="exception" pattern="%ex{full}" isClob="true" />
     </Jdbc>
   </appenders>
 

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-driver-manager.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-driver-manager.xml?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-driver-manager.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-driver-manager.xml
Fri May 17 04:04:17 2013
@@ -27,8 +27,8 @@
       <Column name="literalColumn" literal="'Literal Value Test String'" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
-      <Column name="message" pattern="%message" />
-      <Column name="exception" pattern="%ex{full}" />
+      <Column name="message" pattern="%message" isUnicode="false" />
+      <Column name="exception" pattern="%ex{full}" isClob="true" />
     </Jdbc>
   </appenders>
 

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
Fri May 17 04:04:17 2013
@@ -23,13 +23,13 @@
     </Console>
     <Jdbc name="databaseAppender" tableName="fmLogEntry">
       <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcH2AppenderTest"
-         method="getConfigConnection" />
+                         method="getConfigConnection" />
       <Column name="eventDate" isEventTimestamp="true" />
       <Column name="literalColumn" literal="'Some Other Literal Value'" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
-      <Column name="message" pattern="%message" />
-      <Column name="exception" pattern="%ex{full}" />
+      <Column name="message" pattern="%message" isUnicode="false" />
+      <Column name="exception" pattern="%ex{full}" isClob="true" />
     </Jdbc>
   </appenders>
 

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-driver-manager.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-driver-manager.xml?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-driver-manager.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-driver-manager.xml
Fri May 17 04:04:17 2013
@@ -27,8 +27,8 @@
       <Column name="literalColumn" literal="'Literal Value Test String'" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
-      <Column name="message" pattern="%message" />
-      <Column name="exception" pattern="%ex{full}" />
+      <Column name="message" pattern="%message" isUnicode="false" />
+      <Column name="exception" pattern="%ex{full}" isClob="true" />
     </Jdbc>
   </appenders>
 

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml?rev=1483644&r1=1483643&r2=1483644&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
Fri May 17 04:04:17 2013
@@ -23,13 +23,13 @@
     </Console>
     <Jdbc name="databaseAppender" tableName="fmLogEntry">
       <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcHyperSqlAppenderTest"
-         method="getConfigConnection" />
+                         method="getConfigConnection" />
       <Column name="eventDate" isEventTimestamp="true" />
       <Column name="literalColumn" literal="'Some Other Literal Value'" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
-      <Column name="message" pattern="%message" />
-      <Column name="exception" pattern="%ex{full}" />
+      <Column name="message" pattern="%message" isUnicode="false" />
+      <Column name="exception" pattern="%ex{full}" isClob="true" />
     </Jdbc>
   </appenders>
 



Mime
View raw message