logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwilli...@apache.org
Subject svn commit: r1482202 - in /logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db: ./ jdbc/ jpa/ nosql/
Date Tue, 14 May 2013 04:38:03 GMT
Author: nickwilliams
Date: Tue May 14 04:38:03 2013
New Revision: 1482202

URL: http://svn.apache.org/r1482202
Log:
Cleaning up test class code

Modified:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.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/DataSourceConnectionSourceTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSourceTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/FactoryMethodConnectionSourceTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/nosql/NoSQLDatabaseManagerTest.java

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java Tue May 14 04:38:03 2013
@@ -16,48 +16,29 @@
  */
 package org.apache.logging.log4j.core.appender.db;
 
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.same;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LogEvent;
 import org.junit.After;
 import org.junit.Test;
 
-public class AbstractDatabaseAppenderTest {
-    private static abstract class LocalAbstractDatabaseAppender extends
-            AbstractDatabaseAppender<LocalAbstractDatabaseManager> {
-        public LocalAbstractDatabaseAppender(final String name, final Filter filter, final boolean handleException,
-                final LocalAbstractDatabaseManager manager) {
-            super(name, filter, handleException, manager);
-        }
-    }
-
-    private static abstract class LocalAbstractDatabaseManager extends AbstractDatabaseManager {
-        public LocalAbstractDatabaseManager(final String name, final int bufferSize) {
-            super(name, bufferSize);
-        }
-    }
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
 
+public class AbstractDatabaseAppenderTest {
     private LocalAbstractDatabaseAppender appender;
-
     private LocalAbstractDatabaseManager manager;
 
     public void setUp(final String name) {
-        this.manager = createMockBuilder(LocalAbstractDatabaseManager.class).withConstructor(String.class, int.class)
-                .withArgs(name, 0).addMockedMethod("release").createStrictMock();
+        this.manager = createMockBuilder(LocalAbstractDatabaseManager.class)
+                .withConstructor(String.class, int.class)
+                .withArgs(name, 0)
+                .addMockedMethod("release")
+                .createStrictMock();
 
         this.appender = createMockBuilder(LocalAbstractDatabaseAppender.class)
                 .withConstructor(String.class, Filter.class, boolean.class, LocalAbstractDatabaseManager.class)
-                .withArgs(name, null, true, this.manager).createStrictMock();
+                .withArgs(name, null, true, this.manager)
+                .createStrictMock();
     }
 
     @After
@@ -66,28 +47,6 @@ public class AbstractDatabaseAppenderTes
     }
 
     @Test
-    public void testAppend() {
-        this.setUp("name");
-
-        final LogEvent event1 = createStrictMock(LogEvent.class);
-        final LogEvent event2 = createStrictMock(LogEvent.class);
-
-        this.manager.writeInternal(same(event1));
-        expectLastCall();
-        replay(this.manager, this.appender);
-
-        this.appender.append(event1);
-
-        verify(this.manager, this.appender);
-        reset(this.manager, this.appender);
-        this.manager.writeInternal(same(event2));
-        expectLastCall();
-        replay(this.manager, this.appender);
-
-        this.appender.append(event2);
-    }
-
-    @Test
     public void testNameAndGetLayout01() {
         this.setUp("testName01");
 
@@ -108,6 +67,25 @@ public class AbstractDatabaseAppenderTes
     }
 
     @Test
+    public void testStartAndStop() {
+        this.setUp("name");
+
+        this.manager.connectInternal();
+        expectLastCall();
+        replay(this.manager, this.appender);
+
+        this.appender.start();
+
+        verify(this.manager, this.appender);
+        reset(this.manager, this.appender);
+        this.manager.release();
+        expectLastCall();
+        replay(this.manager, this.appender);
+
+        this.appender.stop();
+    }
+
+    @Test
     public void testReplaceManager() {
         this.setUp("name");
 
@@ -142,21 +120,38 @@ public class AbstractDatabaseAppenderTes
     }
 
     @Test
-    public void testStartAndStop() {
+    public void testAppend() {
         this.setUp("name");
 
-        this.manager.connectInternal();
+        final LogEvent event1 = createStrictMock(LogEvent.class);
+        final LogEvent event2 = createStrictMock(LogEvent.class);
+
+        this.manager.writeInternal(same(event1));
         expectLastCall();
         replay(this.manager, this.appender);
 
-        this.appender.start();
+        this.appender.append(event1);
 
         verify(this.manager, this.appender);
         reset(this.manager, this.appender);
-        this.manager.release();
+        this.manager.writeInternal(same(event2));
         expectLastCall();
         replay(this.manager, this.appender);
 
-        this.appender.stop();
+        this.appender.append(event2);
+    }
+
+    private static abstract class LocalAbstractDatabaseManager extends AbstractDatabaseManager {
+        public LocalAbstractDatabaseManager(final String name, final int bufferSize) {
+            super(name, bufferSize);
+        }
+    }
+
+    private static abstract class LocalAbstractDatabaseAppender extends
+            AbstractDatabaseAppender<LocalAbstractDatabaseManager> {
+        public LocalAbstractDatabaseAppender(final String name, final Filter filter, final boolean handleException,
+                                             final LocalAbstractDatabaseManager manager) {
+            super(name, filter, handleException, manager);
+        }
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java Tue May 14 04:38:03 2013
@@ -16,27 +16,22 @@
  */
 package org.apache.logging.log4j.core.appender.db;
 
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.same;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import org.apache.logging.log4j.core.LogEvent;
 import org.junit.After;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 public class AbstractDatabaseManagerTest {
     private AbstractDatabaseManager manager;
 
     public void setUp(final String name, final int buffer) {
-        this.manager = createMockBuilder(AbstractDatabaseManager.class).withConstructor(String.class, int.class)
-                .withArgs(name, buffer).addMockedMethod("release").createStrictMock();
+        this.manager = createMockBuilder(AbstractDatabaseManager.class)
+                .withConstructor(String.class, int.class)
+                .withArgs(name, buffer)
+                .addMockedMethod("release")
+                .createStrictMock();
     }
 
     @After
@@ -45,6 +40,80 @@ public class AbstractDatabaseManagerTest
     }
 
     @Test
+    public void testConnection01() {
+        this.setUp("testName01", 0);
+
+        replay(this.manager);
+
+        assertEquals("The name is not correct.", "testName01", this.manager.getName());
+        assertFalse("The manager should not be connected.", this.manager.isConnected());
+
+        verify(this.manager);
+        reset(this.manager);
+        this.manager.connectInternal();
+        expectLastCall();
+        replay(this.manager);
+
+        this.manager.connect();
+        assertTrue("The manager should be connected now.", this.manager.isConnected());
+
+        verify(this.manager);
+        reset(this.manager);
+        this.manager.disconnectInternal();
+        expectLastCall();
+        replay(this.manager);
+
+        this.manager.disconnect();
+        assertFalse("The manager should not be connected anymore.", this.manager.isConnected());
+    }
+
+    @Test
+    public void testConnection02() {
+        this.setUp("anotherName02", 0);
+
+        replay(this.manager);
+
+        assertEquals("The name is not correct.", "anotherName02", this.manager.getName());
+        assertFalse("The manager should not be connected.", this.manager.isConnected());
+
+        verify(this.manager);
+        reset(this.manager);
+        this.manager.connectInternal();
+        expectLastCall();
+        replay(this.manager);
+
+        this.manager.connect();
+        assertTrue("The manager should be connected now.", this.manager.isConnected());
+
+        verify(this.manager);
+        reset(this.manager);
+        this.manager.disconnectInternal();
+        expectLastCall();
+        replay(this.manager);
+
+        this.manager.releaseSub();
+        assertFalse("The manager should not be connected anymore.", this.manager.isConnected());
+    }
+
+    @Test
+    public void testToString01() {
+        this.setUp("someName01", 0);
+
+        replay(this.manager);
+
+        assertEquals("The string is not correct.", "someName01", this.manager.toString());
+    }
+
+    @Test
+    public void testToString02() {
+        this.setUp("bufferSize=12, anotherKey02=coolValue02", 12);
+
+        replay(this.manager);
+
+        assertEquals("The string is not correct.", "bufferSize=12, anotherKey02=coolValue02", this.manager.toString());
+    }
+
+    @Test
     public void testBuffering01() {
         this.setUp("name", 0);
 
@@ -176,78 +245,4 @@ public class AbstractDatabaseManagerTest
 
         this.manager.disconnect();
     }
-
-    @Test
-    public void testConnection01() {
-        this.setUp("testName01", 0);
-
-        replay(this.manager);
-
-        assertEquals("The name is not correct.", "testName01", this.manager.getName());
-        assertFalse("The manager should not be connected.", this.manager.isConnected());
-
-        verify(this.manager);
-        reset(this.manager);
-        this.manager.connectInternal();
-        expectLastCall();
-        replay(this.manager);
-
-        this.manager.connect();
-        assertTrue("The manager should be connected now.", this.manager.isConnected());
-
-        verify(this.manager);
-        reset(this.manager);
-        this.manager.disconnectInternal();
-        expectLastCall();
-        replay(this.manager);
-
-        this.manager.disconnect();
-        assertFalse("The manager should not be connected anymore.", this.manager.isConnected());
-    }
-
-    @Test
-    public void testConnection02() {
-        this.setUp("anotherName02", 0);
-
-        replay(this.manager);
-
-        assertEquals("The name is not correct.", "anotherName02", this.manager.getName());
-        assertFalse("The manager should not be connected.", this.manager.isConnected());
-
-        verify(this.manager);
-        reset(this.manager);
-        this.manager.connectInternal();
-        expectLastCall();
-        replay(this.manager);
-
-        this.manager.connect();
-        assertTrue("The manager should be connected now.", this.manager.isConnected());
-
-        verify(this.manager);
-        reset(this.manager);
-        this.manager.disconnectInternal();
-        expectLastCall();
-        replay(this.manager);
-
-        this.manager.releaseSub();
-        assertFalse("The manager should not be connected anymore.", this.manager.isConnected());
-    }
-
-    @Test
-    public void testToString01() {
-        this.setUp("someName01", 0);
-
-        replay(this.manager);
-
-        assertEquals("The string is not correct.", "someName01", this.manager.toString());
-    }
-
-    @Test
-    public void testToString02() {
-        this.setUp("bufferSize=12, anotherKey02=coolValue02", 12);
-
-        replay(this.manager);
-
-        assertEquals("The string is not correct.", "bufferSize=12, anotherKey02=coolValue02", this.manager.toString());
-    }
 }

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=1482202&r1=1482201&r2=1482202&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 Tue May 14 04:38:03 2013
@@ -16,16 +16,12 @@
  */
 package org.apache.logging.log4j.core.appender.db.jdbc;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class ColumnConfigTest {
     @Before
     public void setUp() {
@@ -38,57 +34,31 @@ public class ColumnConfigTest {
     }
 
     @Test
-    public void testDateColumn01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, null, "true");
-
-        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());
-    }
-
-    @Test
-    public void testDateColumn02() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02", null, null, "true");
+    public void testNullNameNoConfig() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, null, "%l", null, null);
 
-        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());
+        assertNull("The result should be null.", config);
     }
 
     @Test
-    public void testLiteralAndDateNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, "literal", "true");
+    public void testPatternAndLiteralNoConfig() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", "%l", "literal", null);
 
         assertNull("The result should be null.", config);
     }
 
     @Test
-    public void testLiteralColumn01() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, "literalValue01", null);
+    public void testPatternAndDateNoConfig() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", "%l", null, "true");
 
-        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());
-        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());
+        assertNull("The result should be null.", config);
     }
 
     @Test
-    public void testLiteralColumn02() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02", null,
-                "USER1.MY_SEQUENCE.NEXT", null);
+    public void testLiteralAndDateNoConfig() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, "literal", "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());
-        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());
+        assertNull("The result should be null.", config);
     }
 
     @Test
@@ -113,24 +83,25 @@ public class ColumnConfigTest {
     }
 
     @Test
-    public void testNullNameNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, null, "%l", null, null);
-
-        assertNull("The result should be null.", config);
-    }
-
-    @Test
-    public void testPatternAndDateNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", "%l", null, "true");
+    public void testDateColumn01() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, null, "true");
 
-        assertNull("The result should be null.", config);
+        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());
     }
 
     @Test
-    public void testPatternAndLiteralNoConfig() {
-        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", "%l", "literal", null);
+    public void testDateColumn02() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02", null, null, "true");
 
-        assertNull("The result should be null.", config);
+        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());
     }
 
     @Test
@@ -157,4 +128,29 @@ public class ColumnConfigTest {
         assertNull("The literal value should be null.", config.getLiteralValue());
         assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
     }
+
+    @Test
+    public void testLiteralColumn01() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "columnName01", null, "literalValue01", 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());
+        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());
+    }
+
+    @Test
+    public void testLiteralColumn02() {
+        final ColumnConfig config = ColumnConfig.createColumnConfig(null, "anotherName02", null,
+                "USER1.MY_SEQUENCE.NEXT", null);
+
+        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());
+        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());
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DataSourceConnectionSourceTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DataSourceConnectionSourceTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DataSourceConnectionSourceTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DataSourceConnectionSourceTest.java Tue May 14 04:38:03 2013
@@ -16,18 +16,8 @@
  */
 package org.apache.logging.log4j.core.appender.db.jdbc;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
 import java.sql.Connection;
 import java.sql.SQLException;
-
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
@@ -37,6 +27,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockejb.jndi.MockContextFactory;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 public class DataSourceConnectionSourceTest {
     private InitialContext context;
 
@@ -57,6 +50,28 @@ public class DataSourceConnectionSourceT
     }
 
     @Test
+    public void testNoJndiName01() {
+        final DataSourceConnectionSource source = DataSourceConnectionSource.createConnectionSource(null);
+
+        assertNull("The connection source should be null.", source);
+    }
+
+    @Test
+    public void testNoJndiName02() {
+        final DataSourceConnectionSource source = DataSourceConnectionSource.createConnectionSource("");
+
+        assertNull("The connection source should be null.", source);
+    }
+
+    @Test
+    public void testNoDataSource() {
+        final DataSourceConnectionSource source = DataSourceConnectionSource
+                .createConnectionSource("java:/comp/env/jdbc/Logging01");
+
+        assertNull("The connection source should be null.", source);
+    }
+
+    @Test
     public void testDataSource01() throws NamingException, SQLException {
         final DataSource dataSource = createStrictMock(DataSource.class);
         final Connection connection1 = createStrictMock(Connection.class);
@@ -111,26 +126,4 @@ public class DataSourceConnectionSourceT
 
         verify(dataSource, connection1, connection2);
     }
-
-    @Test
-    public void testNoDataSource() {
-        final DataSourceConnectionSource source = DataSourceConnectionSource
-                .createConnectionSource("java:/comp/env/jdbc/Logging01");
-
-        assertNull("The connection source should be null.", source);
-    }
-
-    @Test
-    public void testNoJndiName01() {
-        final DataSourceConnectionSource source = DataSourceConnectionSource.createConnectionSource(null);
-
-        assertNull("The connection source should be null.", source);
-    }
-
-    @Test
-    public void testNoJndiName02() {
-        final DataSourceConnectionSource source = DataSourceConnectionSource.createConnectionSource("");
-
-        assertNull("The connection source should be null.", source);
-    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSourceTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSourceTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSourceTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSourceTest.java Tue May 14 04:38:03 2013
@@ -16,18 +16,6 @@
  */
 package org.apache.logging.log4j.core.appender.db.jdbc;
 
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
@@ -42,6 +30,9 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 public class DriverManagerConnectionSourceTest {
     private Driver driver;
 
@@ -61,58 +52,58 @@ public class DriverManagerConnectionSour
     }
 
     @Test
-    public void testInvalidUrl() throws SQLException {
-        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/database")).andReturn(false);
+    public void testNoUrl01() {
         replay(this.driver);
 
-        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(
-                "log4j2:test:appender:jdbc:url://localhost:2737/database", "username01", "password01");
+        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(null,
+                "username01", "password01");
 
         assertNull("The connection source should be null.", source);
     }
 
     @Test
-    public void testNoUrl01() {
+    public void testNoUrl02() {
         replay(this.driver);
 
-        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(null,
+        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource("",
                 "username01", "password01");
 
         assertNull("The connection source should be null.", source);
     }
 
     @Test
-    public void testNoUrl02() {
+    public void testInvalidUrl() throws SQLException {
+        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/database")).andReturn(false);
         replay(this.driver);
 
-        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource("",
-                "username01", "password01");
+        final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(
+                "log4j2:test:appender:jdbc:url://localhost:2737/database", "username01", "password01");
 
         assertNull("The connection source should be null.", source);
     }
 
     @Test
-    public void testValidUrlNoUsernamePassword01() throws SQLException {
+    public void testValidUrlUsernamePassword() throws SQLException {
         final Connection connection1 = createStrictMock(Connection.class);
         final Connection connection2 = createStrictMock(Connection.class);
 
         final Capture<Properties> capture = new Capture<Properties>(CaptureType.ALL);
 
-        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb")).andReturn(true);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb"), capture(capture)))
+        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/database")).andReturn(true);
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/database"), capture(capture)))
                 .andReturn(connection1);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb"), capture(capture)))
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/database"), capture(capture)))
                 .andReturn(connection2);
         replay(this.driver, connection1, connection2);
 
         final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(
-                "log4j2:test:appender:jdbc:url://localhost:2737/anotherDb", null, null);
+                "log4j2:test:appender:jdbc:url://localhost:2737/database", "username01", "password01");
 
         assertNotNull("The connection source should not be null.", source);
         assertEquals("The toString value is not correct.",
-                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/anotherDb, username=null, "
-                        + "passwordHash=" + NameUtil.md5(null + DriverManagerConnectionSource.class.getName()) + " }",
-                source.toString());
+                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/database, username=username01, "
+                        + "passwordHash=" + NameUtil.md5("password01" + DriverManagerConnectionSource.class.getName())
+                        + " }", source.toString());
         assertSame("The connection is not correct (1).", connection1, source.getConnection());
         assertSame("The connection is not correct (2).", connection2, source.getConnection());
 
@@ -121,37 +112,37 @@ public class DriverManagerConnectionSour
 
         final Properties properties1 = captured.get(0);
         assertNotNull("The properties object should not be null (1).", properties1);
-        assertNull("The username should be null (1).", properties1.getProperty("user"));
-        assertNull("The password should be null (1).", properties1.getProperty("password"));
+        assertEquals("The username is not correct (1).", "username01", properties1.getProperty("user"));
+        assertEquals("The password is not correct (1).", "password01", properties1.getProperty("password"));
 
         final Properties properties2 = captured.get(1);
         assertNotNull("The properties object should not be null (2).", properties2);
-        assertNull("The username should be null (2).", properties2.getProperty("user"));
-        assertNull("The password should be null (2).", properties2.getProperty("password"));
+        assertEquals("The username is not correct (2).", "username01", properties2.getProperty("user"));
+        assertEquals("The password is not correct (2).", "password01", properties2.getProperty("password"));
 
         verify(connection1, connection2);
     }
 
     @Test
-    public void testValidUrlNoUsernamePassword02() throws SQLException {
+    public void testValidUrlNoUsernamePassword01() throws SQLException {
         final Connection connection1 = createStrictMock(Connection.class);
         final Connection connection2 = createStrictMock(Connection.class);
 
         final Capture<Properties> capture = new Capture<Properties>(CaptureType.ALL);
 
-        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/finalDb")).andReturn(true);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/finalDb"), capture(capture)))
+        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb")).andReturn(true);
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb"), capture(capture)))
                 .andReturn(connection1);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/finalDb"), capture(capture)))
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/anotherDb"), capture(capture)))
                 .andReturn(connection2);
         replay(this.driver, connection1, connection2);
 
         final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(
-                "log4j2:test:appender:jdbc:url://localhost:2737/finalDb", "     ", "");
+                "log4j2:test:appender:jdbc:url://localhost:2737/anotherDb", null, null);
 
         assertNotNull("The connection source should not be null.", source);
         assertEquals("The toString value is not correct.",
-                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/finalDb, username=null, "
+                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/anotherDb, username=null, "
                         + "passwordHash=" + NameUtil.md5(null + DriverManagerConnectionSource.class.getName()) + " }",
                 source.toString());
         assertSame("The connection is not correct (1).", connection1, source.getConnection());
@@ -174,27 +165,27 @@ public class DriverManagerConnectionSour
     }
 
     @Test
-    public void testValidUrlUsernamePassword() throws SQLException {
+    public void testValidUrlNoUsernamePassword02() throws SQLException {
         final Connection connection1 = createStrictMock(Connection.class);
         final Connection connection2 = createStrictMock(Connection.class);
 
         final Capture<Properties> capture = new Capture<Properties>(CaptureType.ALL);
 
-        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/database")).andReturn(true);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/database"), capture(capture)))
+        expect(this.driver.acceptsURL("log4j2:test:appender:jdbc:url://localhost:2737/finalDb")).andReturn(true);
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/finalDb"), capture(capture)))
                 .andReturn(connection1);
-        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/database"), capture(capture)))
+        expect(this.driver.connect(eq("log4j2:test:appender:jdbc:url://localhost:2737/finalDb"), capture(capture)))
                 .andReturn(connection2);
         replay(this.driver, connection1, connection2);
 
         final DriverManagerConnectionSource source = DriverManagerConnectionSource.createConnectionSource(
-                "log4j2:test:appender:jdbc:url://localhost:2737/database", "username01", "password01");
+                "log4j2:test:appender:jdbc:url://localhost:2737/finalDb", "     ", "");
 
         assertNotNull("The connection source should not be null.", source);
         assertEquals("The toString value is not correct.",
-                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/database, username=username01, "
-                        + "passwordHash=" + NameUtil.md5("password01" + DriverManagerConnectionSource.class.getName())
-                        + " }", source.toString());
+                "driverManager{ url=log4j2:test:appender:jdbc:url://localhost:2737/finalDb, username=null, "
+                        + "passwordHash=" + NameUtil.md5(null + DriverManagerConnectionSource.class.getName()) + " }",
+                source.toString());
         assertSame("The connection is not correct (1).", connection1, source.getConnection());
         assertSame("The connection is not correct (2).", connection2, source.getConnection());
 
@@ -203,13 +194,13 @@ public class DriverManagerConnectionSour
 
         final Properties properties1 = captured.get(0);
         assertNotNull("The properties object should not be null (1).", properties1);
-        assertEquals("The username is not correct (1).", "username01", properties1.getProperty("user"));
-        assertEquals("The password is not correct (1).", "password01", properties1.getProperty("password"));
+        assertNull("The username should be null (1).", properties1.getProperty("user"));
+        assertNull("The password should be null (1).", properties1.getProperty("password"));
 
         final Properties properties2 = captured.get(1);
         assertNotNull("The properties object should not be null (2).", properties2);
-        assertEquals("The username is not correct (2).", "username01", properties2.getProperty("user"));
-        assertEquals("The password is not correct (2).", "password01", properties2.getProperty("password"));
+        assertNull("The username should be null (2).", properties2.getProperty("user"));
+        assertNull("The password should be null (2).", properties2.getProperty("password"));
 
         verify(connection1, connection2);
     }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/FactoryMethodConnectionSourceTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/FactoryMethodConnectionSourceTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/FactoryMethodConnectionSourceTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/FactoryMethodConnectionSourceTest.java Tue May 14 04:38:03 2013
@@ -16,18 +16,8 @@
  */
 package org.apache.logging.log4j.core.appender.db.jdbc;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
 import java.sql.Connection;
 import java.sql.SQLException;
-
 import javax.sql.DataSource;
 
 import org.junit.After;
@@ -35,28 +25,10 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Test;
 
-public class FactoryMethodConnectionSourceTest {
-    @SuppressWarnings("unused")
-    protected static final class BadReturnTypeFactory {
-        public static String factoryMethod01() {
-            return "hello";
-        }
-    }
-
-    @SuppressWarnings("unused")
-    protected static final class ConnectionFactory {
-        public static Connection anotherMethod03() {
-            return (Connection) holder.get();
-        }
-    }
-
-    @SuppressWarnings("unused")
-    protected static final class DataSourceFactory {
-        public static DataSource factoryMethod02() {
-            return (DataSource) holder.get();
-        }
-    }
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
 
+public class FactoryMethodConnectionSourceTest {
     private static ThreadLocal<Object> holder = new ThreadLocal<Object>();
 
     @AfterClass
@@ -76,6 +48,22 @@ public class FactoryMethodConnectionSour
     }
 
     @Test
+    public void testNoClassName() {
+        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource(null,
+                "method");
+
+        assertNull("The connection source should be null.", source);
+    }
+
+    @Test
+    public void testNoMethodName() {
+        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource("someClass",
+                null);
+
+        assertNull("The connection source should be null.", source);
+    }
+
+    @Test
     public void testBadClassName() {
         final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource(
                 "org.apache.BadClass", "factoryMethod");
@@ -100,26 +88,6 @@ public class FactoryMethodConnectionSour
     }
 
     @Test
-    public void testConnectionReturnType() throws SQLException {
-        final Connection connection = createStrictMock(Connection.class);
-
-        replay(connection);
-
-        holder.set(connection);
-
-        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource(
-                ConnectionFactory.class.getName(), "anotherMethod03");
-
-        assertNotNull("The connection source should not be null.", source);
-        assertEquals("The toString value is not correct.", "factory{ public static java.sql.Connection "
-                + ConnectionFactory.class.getName() + ".anotherMethod03() }", source.toString());
-        assertSame("The connection is not correct (1).", connection, source.getConnection());
-        assertSame("The connection is not correct (2).", connection, source.getConnection());
-
-        verify(connection);
-    }
-
-    @Test
     public void testDataSourceReturnType() throws SQLException {
         final DataSource dataSource = createStrictMock(DataSource.class);
         final Connection connection1 = createStrictMock(Connection.class);
@@ -144,18 +112,43 @@ public class FactoryMethodConnectionSour
     }
 
     @Test
-    public void testNoClassName() {
-        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource(null,
-                "method");
+    public void testConnectionReturnType() throws SQLException {
+        final Connection connection = createStrictMock(Connection.class);
 
-        assertNull("The connection source should be null.", source);
+        replay(connection);
+
+        holder.set(connection);
+
+        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource(
+                ConnectionFactory.class.getName(), "anotherMethod03");
+
+        assertNotNull("The connection source should not be null.", source);
+        assertEquals("The toString value is not correct.", "factory{ public static java.sql.Connection "
+                + ConnectionFactory.class.getName() + ".anotherMethod03() }", source.toString());
+        assertSame("The connection is not correct (1).", connection, source.getConnection());
+        assertSame("The connection is not correct (2).", connection, source.getConnection());
+
+        verify(connection);
     }
 
-    @Test
-    public void testNoMethodName() {
-        final FactoryMethodConnectionSource source = FactoryMethodConnectionSource.createConnectionSource("someClass",
-                null);
+    @SuppressWarnings("unused")
+    protected static final class BadReturnTypeFactory {
+        public static String factoryMethod01() {
+            return "hello";
+        }
+    }
 
-        assertNull("The connection source should be null.", source);
+    @SuppressWarnings("unused")
+    protected static final class DataSourceFactory {
+        public static DataSource factoryMethod02() {
+            return (DataSource) holder.get();
+        }
+    }
+
+    @SuppressWarnings("unused")
+    protected static final class ConnectionFactory {
+        public static Connection anotherMethod03() {
+            return (Connection) holder.get();
+        }
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java Tue May 14 04:38:03 2013
@@ -16,6 +16,15 @@
  */
 package org.apache.logging.log4j.core.appender.db.jpa;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Map;
+
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.Appender;
@@ -27,15 +36,6 @@ import org.apache.logging.log4j.status.S
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Map;
-
 import static org.junit.Assert.*;
 
 public class JPAAppenderTest {
@@ -105,17 +105,25 @@ public class JPAAppenderTest {
     }
 
     @Test
-    public void testNonLogEventEntity() {
-        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, Object.class.getName(),
+    public void testNoPersistenceUnitName() {
+        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, TestEntity.class.getName(),
+                null);
+
+        assertNull("The appender should be null.", appender);
+    }
+
+    @Test
+    public void testBadEntityClassName() {
+        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, "com.foo.Bar",
                 "jpaAppenderTestUnit");
 
         assertNull("The appender should be null.", appender);
     }
 
     @Test
-    public void testNoPersistenceUnitName() {
-        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, TestEntity.class.getName(),
-                null);
+    public void testNonLogEventEntity() {
+        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, Object.class.getName(),
+                "jpaAppenderTestUnit");
 
         assertNull("The appender should be null.", appender);
     }
@@ -137,14 +145,6 @@ public class JPAAppenderTest {
     }
 
     @Test
-    public void testBadEntityClassName() {
-        final JPAAppender appender = JPAAppender.createAppender("name", null, null, null, "com.foo.Bar",
-                "jpaAppenderTestUnit");
-
-        assertNull("The appender should be null.", appender);
-    }
-
-    @Test
     @Ignore("until Hibernate implements support for @Convert, @Converter")
     public void testBaseJpaEntityAppender() throws SQLException {
         try {

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java Tue May 14 04:38:03 2013
@@ -16,11 +16,7 @@
  */
 package org.apache.logging.log4j.core.appender.db.jpa;
 
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter;
-
+import java.util.Map;
 import javax.persistence.Column;
 import javax.persistence.Convert;
 import javax.persistence.Entity;
@@ -29,7 +25,11 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 import javax.persistence.Transient;
-import java.util.Map;
+
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter;
 
 @Entity
 @Table(name = "jpaBasicLogEntry")
@@ -59,13 +59,6 @@ public class TestBasicEntity extends Bas
     }
 
     @Override
-    @Convert(converter = ContextMapJsonAttributeConverter.class)
-    @Column(name = "contextMapJson")
-    public Map<String, String> getContextMap() {
-        return super.getContextMap();
-    }
-
-    @Override
     @Transient
     public StackTraceElement getSource() {
         return super.getSource();
@@ -84,6 +77,13 @@ public class TestBasicEntity extends Bas
     }
 
     @Override
+    @Convert(converter = ContextMapJsonAttributeConverter.class)
+    @Column(name = "contextMapJson")
+    public Map<String, String> getContextMap() {
+        return super.getContextMap();
+    }
+
+    @Override
     @Transient
     public ThreadContext.ContextStack getContextStack() {
         return super.getContextStack();

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/nosql/NoSQLDatabaseManagerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/nosql/NoSQLDatabaseManagerTest.java?rev=1482202&r1=1482201&r2=1482202&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/nosql/NoSQLDatabaseManagerTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/nosql/NoSQLDatabaseManagerTest.java Tue May 14 04:38:03 2013
@@ -16,20 +16,6 @@
  */
 package org.apache.logging.log4j.core.appender.db.nosql;
 
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.getCurrentArguments;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-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.io.IOException;
 import java.sql.SQLException;
 import java.util.Date;
@@ -49,9 +35,12 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 public class NoSQLDatabaseManagerTest {
-    NoSQLConnection<Map<String, Object>, CouchDBObject> connection;
-    NoSQLProvider<NoSQLConnection<Map<String, Object>, CouchDBObject>> provider;
+    private NoSQLConnection<Map<String, Object>, CouchDBObject> connection;
+    private NoSQLProvider<NoSQLConnection<Map<String, Object>, CouchDBObject>> provider;
 
     @Before
     @SuppressWarnings("unchecked")
@@ -98,6 +87,63 @@ public class NoSQLDatabaseManagerTest {
     }
 
     @Test
+    public void testWriteInternalNotConnected01() {
+        replay(this.provider, this.connection);
+
+        final NoSQLDatabaseManager<?> manager = NoSQLDatabaseManager.getNoSQLDatabaseManager("name", 0, this.provider);
+
+        try {
+            verify(this.provider, this.connection);
+            reset(this.provider, this.connection);
+
+            final LogEvent event = createStrictMock(LogEvent.class);
+            replay(this.provider, this.connection, event);
+
+            manager.writeInternal(event);
+
+            verify(event);
+        } finally {
+            try {
+                manager.release();
+            } catch (final Throwable ignore) { /* */
+            }
+        }
+    }
+
+    @Test
+    public void testWriteInternalNotConnected02() {
+        expect(this.provider.getConnection()).andReturn(this.connection);
+        replay(this.provider, this.connection);
+
+        final NoSQLDatabaseManager<?> manager = NoSQLDatabaseManager.getNoSQLDatabaseManager("name", 0, this.provider);
+
+        try {
+            manager.connect();
+
+            verify(this.provider, this.connection);
+            reset(this.provider, this.connection);
+
+            final LogEvent event = createStrictMock(LogEvent.class);
+            expect(this.connection.isClosed()).andReturn(true);
+            replay(this.provider, this.connection, event);
+
+            manager.writeInternal(event);
+
+            verify(this.provider, this.connection, event);
+            reset(this.provider, this.connection);
+            expect(this.connection.isClosed()).andReturn(false);
+            this.connection.close();
+            expectLastCall();
+            replay(this.provider, this.connection);
+        } finally {
+            try {
+                manager.release();
+            } catch (final Throwable ignore) { /* */
+            }
+        }
+    }
+
+    @Test
     public void testWriteInternal01() {
         expect(this.provider.getConnection()).andReturn(this.connection);
         replay(this.provider, this.connection);
@@ -491,61 +537,4 @@ public class NoSQLDatabaseManagerTest {
             }
         }
     }
-
-    @Test
-    public void testWriteInternalNotConnected01() {
-        replay(this.provider, this.connection);
-
-        final NoSQLDatabaseManager<?> manager = NoSQLDatabaseManager.getNoSQLDatabaseManager("name", 0, this.provider);
-
-        try {
-            verify(this.provider, this.connection);
-            reset(this.provider, this.connection);
-
-            final LogEvent event = createStrictMock(LogEvent.class);
-            replay(this.provider, this.connection, event);
-
-            manager.writeInternal(event);
-
-            verify(event);
-        } finally {
-            try {
-                manager.release();
-            } catch (final Throwable ignore) { /* */
-            }
-        }
-    }
-
-    @Test
-    public void testWriteInternalNotConnected02() {
-        expect(this.provider.getConnection()).andReturn(this.connection);
-        replay(this.provider, this.connection);
-
-        final NoSQLDatabaseManager<?> manager = NoSQLDatabaseManager.getNoSQLDatabaseManager("name", 0, this.provider);
-
-        try {
-            manager.connect();
-
-            verify(this.provider, this.connection);
-            reset(this.provider, this.connection);
-
-            final LogEvent event = createStrictMock(LogEvent.class);
-            expect(this.connection.isClosed()).andReturn(true);
-            replay(this.provider, this.connection, event);
-
-            manager.writeInternal(event);
-
-            verify(this.provider, this.connection, event);
-            reset(this.provider, this.connection);
-            expect(this.connection.isClosed()).andReturn(false);
-            this.connection.close();
-            expectLastCall();
-            replay(this.provider, this.connection);
-        } finally {
-            try {
-                manager.release();
-            } catch (final Throwable ignore) { /* */
-            }
-        }
-    }
 }



Mime
View raw message