You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2017/01/07 19:46:52 UTC

logging-log4j2 git commit: Refactor JdbcAppender tests into JUnit rules

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 489d70846 -> 29a6821d0


Refactor JdbcAppender tests into JUnit rules

This adds two new JUnit rules: JdbcRule (for setup and teardown of a JDBC table) and JndiRule (for setup and teardown of a MockContext and binding of a value inside it).


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/29a6821d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/29a6821d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/29a6821d

Branch: refs/heads/master
Commit: 29a6821d0be759d977b4ee90db4c120f03bb6109
Parents: 489d708
Author: Matt Sicker <ma...@spr.com>
Authored: Sat Jan 7 13:46:42 2017 -0600
Committer: Matt Sicker <ma...@spr.com>
Committed: Sat Jan 7 13:46:42 2017 -0600

----------------------------------------------------------------------
 .../AbstractJdbcAppenderDataSourceTest.java     | 114 ++++++++++
 .../AbstractJdbcAppenderFactoryMethodTest.java  | 112 ++++++++++
 .../db/jdbc/AbstractJdbcAppenderTest.java       | 209 -------------------
 .../db/jdbc/JdbcAppenderH2DataSourceTest.java   |  46 ++++
 .../jdbc/JdbcAppenderH2FactoryMethodTest.java   |  51 +++++
 .../db/jdbc/JdbcAppenderHsqlDataSourceTest.java |  44 ++++
 .../jdbc/JdbcAppenderHsqlFactoryMethodTest.java |  50 +++++
 .../appender/db/jdbc/JdbcH2AppenderTest.java    |  55 -----
 .../db/jdbc/JdbcHyperSqlAppenderTest.java       |  56 -----
 .../apache/logging/log4j/junit/JdbcRule.java    |  77 +++++++
 .../apache/logging/log4j/junit/JndiRule.java    |  68 ++++++
 .../db/jdbc/log4j2-h2-factory-method.xml        |   4 +-
 .../db/jdbc/log4j2-hsqldb-factory-method.xml    |   4 +-
 13 files changed, 566 insertions(+), 324 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderDataSourceTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderDataSourceTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderDataSourceTest.java
new file mode 100644
index 0000000..e5cfb9f
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderDataSourceTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import javax.sql.DataSource;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.util.Throwables;
+import org.apache.logging.log4j.junit.JdbcRule;
+import org.apache.logging.log4j.junit.JndiRule;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.h2.util.IOUtils;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Abstract unit test for JdbcAppender using a {@link DataSource} configuration.
+ */
+public abstract class AbstractJdbcAppenderDataSourceTest {
+
+    @Rule
+    public final RuleChain rules;
+    private final JdbcRule jdbcRule;
+
+    protected AbstractJdbcAppenderDataSourceTest(final JdbcRule jdbcRule) {
+        this.rules = RuleChain.emptyRuleChain()
+            .around(new JndiRule("java:/comp/env/jdbc/TestDataSourceAppender", createMockDataSource()))
+            .around(jdbcRule)
+            .around(new LoggerContextRule(
+                "org/apache/logging/log4j/core/appender/db/jdbc/log4j2-data-source.xml"));
+        this.jdbcRule = jdbcRule;
+    }
+
+    private DataSource createMockDataSource() {
+        try {
+            final DataSource dataSource = mock(DataSource.class);
+            given(dataSource.getConnection()).willAnswer(new Answer<Connection>() {
+                @Override
+                public Connection answer(final InvocationOnMock invocation) throws Throwable {
+                    return jdbcRule.getConnectionSource().getConnection();
+                }
+            });
+            return dataSource;
+        } catch (final SQLException e) {
+            Throwables.rethrow(e);
+            throw new InternalError("unreachable");
+        }
+    }
+
+    @Test
+    public void testDataSourceConfig() throws Exception {
+        try (final Connection connection = jdbcRule.getConnectionSource().getConnection()) {
+            final Error exception = new Error("Final error massage is fatal!");
+            final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            final PrintWriter writer = new PrintWriter(outputStream);
+            exception.printStackTrace(writer);
+            writer.close();
+            final String stackTrace = outputStream.toString();
+
+            final long millis = System.currentTimeMillis();
+
+            final Logger logger = LogManager.getLogger(this.getClass().getName() + ".testDataSourceConfig");
+            logger.trace("Data source logged message 01.");
+            logger.fatal("Error from data source 02.", exception);
+
+            final Statement statement = connection.createStatement();
+            final ResultSet resultSet = statement.executeQuery("SELECT * FROM dsLogEntry ORDER BY id");
+
+            assertTrue("There should be at least one row.", resultSet.next());
+
+            final long date = resultSet.getTimestamp("eventDate").getTime();
+            assertTrue("The date should be later than pre-logging (1).", date >= millis);
+            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.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,
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(), -1));
+
+            assertFalse("There should not be two rows.", resultSet.next());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderFactoryMethodTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderFactoryMethodTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderFactoryMethodTest.java
new file mode 100644
index 0000000..cc12feb
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderFactoryMethodTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.junit.JdbcRule;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.util.Strings;
+import org.h2.util.IOUtils;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Abstract unit test for JdbcAppender using a {@link FactoryMethodConnectionSource} configuration.
+ */
+public abstract class AbstractJdbcAppenderFactoryMethodTest {
+
+    @Rule
+    public final RuleChain rules;
+    private final JdbcRule jdbcRule;
+
+    protected AbstractJdbcAppenderFactoryMethodTest(final JdbcRule jdbcRule, final String databaseType) {
+        this.rules = RuleChain.emptyRuleChain().around(jdbcRule).around(new LoggerContextRule(
+            "org/apache/logging/log4j/core/appender/db/jdbc/log4j2-" + databaseType + "-factory-method.xml"));
+        this.jdbcRule = jdbcRule;
+    }
+
+    @Test
+    public void testFactoryMethodConfig() throws Exception {
+        try (final Connection connection = jdbcRule.getConnectionSource().getConnection()) {
+            final SQLException exception = new SQLException("Some other error message!");
+            final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            final PrintWriter writer = new PrintWriter(outputStream);
+            exception.printStackTrace(writer);
+            writer.close();
+            final String stackTrace = outputStream.toString();
+
+            final long millis = System.currentTimeMillis();
+
+            ThreadContext.put("some_int", "42");
+            final Logger logger = LogManager.getLogger(this.getClass().getName() + ".testFactoryMethodConfig");
+            logger.debug("Factory logged message 01.");
+            logger.error("Error from factory 02.", exception);
+
+            final Statement statement = connection.createStatement();
+            final ResultSet resultSet = statement.executeQuery("SELECT * FROM fmLogEntry ORDER BY id");
+
+            assertTrue("There should be at least one row.", resultSet.next());
+
+            long date = resultSet.getTimestamp("eventDate").getTime();
+            long anotherDate = resultSet.getTimestamp("anotherDate").getTime();
+            assertEquals(date, anotherDate);
+            assertTrue("The date should be later than pre-logging (1).", date >= millis);
+            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.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).", Strings.EMPTY,
+                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(), -1));
+
+            assertTrue("There should be two rows.", resultSet.next());
+
+            date = resultSet.getTimestamp("eventDate").getTime();
+            anotherDate = resultSet.getTimestamp("anotherDate").getTime();
+            assertEquals(date, anotherDate);
+            assertTrue("The date should be later than pre-logging (2).", date >= millis);
+            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.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());
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
deleted file mode 100644
index e8855dc..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.appender.db.jdbc;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-import org.h2.util.IOUtils;
-import org.junit.After;
-import org.junit.Test;
-import org.mockejb.jndi.MockContextFactory;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
-public abstract class AbstractJdbcAppenderTest {
-    private final String databaseType;
-    private Connection connection;
-
-    public AbstractJdbcAppenderTest(final String databaseType) {
-        this.databaseType = databaseType;
-    }
-
-    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();
-        try (final Statement statement = this.connection.createStatement()) {
-            statement.executeUpdate(this.toCreateTableSqlString(tableName));
-        }
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
-                "org/apache/logging/log4j/core/appender/db/jdbc/" + configFileName);
-        final LoggerContext context = LoggerContext.getContext(false);
-        if (context.getConfiguration() instanceof DefaultConfiguration) {
-            context.reconfigure();
-        }
-        StatusLogger.getLogger().reset();
-    }
-
-    @After
-    public void tearDown() throws SQLException {
-        final LoggerContext context = LoggerContext.getContext(false);
-        try {
-            final Appender appender = context.getConfiguration().getAppender("databaseAppender");
-            assertNotNull("The appender should not be null.", appender);
-            assertTrue("The appender should be a JdbcAppender.", appender instanceof JdbcAppender);
-            ((JdbcAppender) appender).getManager().close();
-        } finally {
-            System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-            context.reconfigure();
-            StatusLogger.getLogger().reset();
-
-            try (Statement statement = this.connection.createStatement()) {
-                statement.execute("SHUTDOWN");
-            }
-
-            this.connection.close();
-        }
-    }
-
-    @Test
-    public void testDataSourceConfig() throws Exception {
-        final DataSource dataSource = mock(DataSource.class);
-        given(dataSource.getConnection()).willAnswer(new Answer<Connection>() {
-            @Override
-            public Connection answer(final InvocationOnMock invocation) throws Throwable {
-                return newConnection();
-            }
-        });
-
-        MockContextFactory.setAsInitial();
-
-        final InitialContext context = new InitialContext();
-        context.createSubcontext("java:");
-        context.createSubcontext("java:/comp");
-        context.createSubcontext("java:/comp/env");
-        context.createSubcontext("java:/comp/env/jdbc");
-
-        context.bind("java:/comp/env/jdbc/TestDataSourceAppender", dataSource);
-
-        try {
-            this.setUp("dsLogEntry", "log4j2-data-source.xml");
-
-            final Error exception = new Error("Final error massage is fatal!");
-            final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            final PrintWriter writer = new PrintWriter(outputStream);
-            exception.printStackTrace(writer);
-            writer.close();
-            final String stackTrace = outputStream.toString();
-
-            final long millis = System.currentTimeMillis();
-
-            final Logger logger = LogManager.getLogger(this.getClass().getName() + ".testDataSourceConfig");
-            logger.trace("Data source logged message 01.");
-            logger.fatal("Error from data source 02.", exception);
-
-            final Statement statement = this.connection.createStatement();
-            final ResultSet resultSet = statement.executeQuery("SELECT * FROM dsLogEntry ORDER BY id");
-
-            assertTrue("There should be at least one row.", resultSet.next());
-
-            final long date = resultSet.getTimestamp("eventDate").getTime();
-            assertTrue("The date should be later than pre-logging (1).", date >= millis);
-            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.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,
-                    IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(), -1));
-
-            assertFalse("There should not be two rows.", resultSet.next());
-        } finally {
-            MockContextFactory.revertSetAsInitial();
-        }
-    }
-
-    @Test
-    public void testFactoryMethodConfig() throws Exception {
-        this.setUp("fmLogEntry", "log4j2-" + this.databaseType + "-factory-method.xml");
-
-        final SQLException exception = new SQLException("Some other error message!");
-        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        final PrintWriter writer = new PrintWriter(outputStream);
-        exception.printStackTrace(writer);
-        writer.close();
-        final String stackTrace = outputStream.toString();
-
-        final long millis = System.currentTimeMillis();
-
-        ThreadContext.put("some_int", "42");
-        final Logger logger = LogManager.getLogger(this.getClass().getName() + ".testFactoryMethodConfig");
-        logger.debug("Factory logged message 01.");
-        logger.error("Error from factory 02.", exception);
-
-        final Statement statement = this.connection.createStatement();
-        final ResultSet resultSet = statement.executeQuery("SELECT * FROM fmLogEntry ORDER BY id");
-
-        assertTrue("There should be at least one row.", resultSet.next());
-
-        long date = resultSet.getTimestamp("eventDate").getTime();
-        long anotherDate = resultSet.getTimestamp("anotherDate").getTime();
-        assertEquals(date, anotherDate);
-        assertTrue("The date should be later than pre-logging (1).", date >= millis);
-        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.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).", Strings.EMPTY,
-                IOUtils.readStringAndClose(resultSet.getNClob("exception").getCharacterStream(), -1));
-
-        assertTrue("There should be two rows.", resultSet.next());
-
-        date = resultSet.getTimestamp("eventDate").getTime();
-        anotherDate = resultSet.getTimestamp("anotherDate").getTime();
-        assertEquals(date, anotherDate);
-        assertTrue("The date should be later than pre-logging (2).", date >= millis);
-        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.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());
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2DataSourceTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2DataSourceTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2DataSourceTest.java
new file mode 100644
index 0000000..6bb7b62
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2DataSourceTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.junit.JdbcRule;
+
+/**
+ *
+ */
+public class JdbcAppenderH2DataSourceTest extends AbstractJdbcAppenderDataSourceTest {
+    public JdbcAppenderH2DataSourceTest() {
+        super(
+            new JdbcRule(
+                new ConnectionSource() {
+                    @Override
+                    public Connection getConnection() throws SQLException {
+                        return DriverManager.getConnection("jdbc:h2:mem:Log4j", "sa", "");
+                    }
+                },
+                "CREATE TABLE dsLogEntry (" +
+                    "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level NVARCHAR(10), " +
+                    "logger NVARCHAR(255), message VARCHAR(1024), exception NCLOB, anotherDate TIMESTAMP" +
+                    ")",
+                "DROP TABLE dsLogEntry"
+            )
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2FactoryMethodTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2FactoryMethodTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2FactoryMethodTest.java
new file mode 100644
index 0000000..54bfd17
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderH2FactoryMethodTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.junit.JdbcRule;
+
+/**
+ *
+ */
+public class JdbcAppenderH2FactoryMethodTest extends AbstractJdbcAppenderFactoryMethodTest {
+    public JdbcAppenderH2FactoryMethodTest() {
+        super(
+            new JdbcRule(
+                new ConnectionSource() {
+                    @Override
+                    public Connection getConnection() throws SQLException {
+                        return JdbcAppenderH2FactoryMethodTest.getConnection();
+                    }
+                },
+                "CREATE TABLE fmLogEntry (" +
+                    "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level NVARCHAR(10), " +
+                    "logger NVARCHAR(255), message VARCHAR(1024), exception NCLOB, anotherDate TIMESTAMP" +
+                    ")",
+                "DROP TABLE fmLogEntry"
+            ),
+            "h2"
+        );
+    }
+
+    public static Connection getConnection() throws SQLException {
+        return DriverManager.getConnection("jdbc:h2:mem:Log4j", "sa", "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlDataSourceTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlDataSourceTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlDataSourceTest.java
new file mode 100644
index 0000000..9f3f8d7
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlDataSourceTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.junit.JdbcRule;
+
+/**
+ *
+ */
+public class JdbcAppenderHsqlDataSourceTest extends AbstractJdbcAppenderDataSourceTest {
+    public JdbcAppenderHsqlDataSourceTest() {
+        super(new JdbcRule(
+            new ConnectionSource() {
+                @Override
+                public Connection getConnection() throws SQLException {
+                    return DriverManager.getConnection("jdbc:hsqldb:mem:Log4j", "sa", "");
+                }
+            },
+            "CREATE TABLE dsLogEntry (" +
+                "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level VARCHAR(10), " +
+                "logger VARCHAR(255), message VARCHAR(1024), exception CLOB, anotherDate TIMESTAMP" +
+                ")",
+            "DROP TABLE dsLogEntry"
+        ));
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlFactoryMethodTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlFactoryMethodTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlFactoryMethodTest.java
new file mode 100644
index 0000000..1b4ca3e
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcAppenderHsqlFactoryMethodTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.db.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.logging.log4j.junit.JdbcRule;
+
+/**
+ *
+ */
+public class JdbcAppenderHsqlFactoryMethodTest extends AbstractJdbcAppenderFactoryMethodTest {
+    public JdbcAppenderHsqlFactoryMethodTest() {
+        super(new JdbcRule(
+                new ConnectionSource() {
+                    @Override
+                    public Connection getConnection() throws SQLException {
+                        return JdbcAppenderHsqlFactoryMethodTest.getConnection();
+                    }
+                },
+                "CREATE TABLE fmLogEntry (" +
+                    "id INTEGER IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level VARCHAR(10), " +
+                    "logger VARCHAR(255), message VARCHAR(1024), exception CLOB, anotherDate TIMESTAMP" +
+                    ")",
+                "DROP TABLE fmLogEntry"
+            ),
+            "hsqldb"
+        );
+    }
+
+    public static Connection getConnection() throws SQLException {
+        return DriverManager.getConnection("jdbc:hsqldb:mem:Log4j", "sa", "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
deleted file mode 100644
index 2d94acd..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcH2AppenderTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.appender.db.jdbc;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Tests the JDBC appender with the H2 database in memory.
- */
-public class JdbcH2AppenderTest extends AbstractJdbcAppenderTest {
-    private static final String USER_ID = "sa";
-    private static final String PASSWORD = Strings.EMPTY;
-
-    public JdbcH2AppenderTest() {
-        super("h2");
-    }
-
-    /**
-     * Referred from log4j2-h2-factory-method.xml.
-     */
-    public static Connection getConfigConnection() throws SQLException {
-        return DriverManager.getConnection("jdbc:h2:mem:Log4j", USER_ID, PASSWORD);
-    }
-
-    @Override
-    protected Connection newConnection() throws SQLException {
-        return DriverManager.getConnection("jdbc:h2:mem:Log4j", USER_ID, PASSWORD);
-    }
-
-    @Override
-    protected String toCreateTableSqlString(final 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, anotherDate TIMESTAMP" +
-                " )";
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
deleted file mode 100644
index 9a066c8..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcHyperSqlAppenderTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.appender.db.jdbc;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Tests the JDBC appender with the HyperSQL database (a.k.a. HSQLDB) in memory.
- */
-public class JdbcHyperSqlAppenderTest extends AbstractJdbcAppenderTest {
-    private static final String USER_ID = "sa";
-    private static final String PASSWORD = Strings.EMPTY;
-
-    public JdbcHyperSqlAppenderTest() {
-        super("hsqldb");
-    }
-
-    /**
-     * Referred from log4j2-hsqldb-factory-method.xml.
-     */
-    @SuppressWarnings("unused")
-    public static Connection getConfigConnection() throws SQLException {
-        return DriverManager.getConnection("jdbc:hsqldb:mem:Log4j;ifexists=true", USER_ID, PASSWORD);
-    }
-
-    @Override
-    protected Connection newConnection() throws SQLException {
-        return DriverManager.getConnection("jdbc:hsqldb:mem:Log4j", USER_ID, PASSWORD);
-    }
-
-    @Override
-    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 CLOB, anotherDate TIMESTAMP" +
-                " )";
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/junit/JdbcRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/JdbcRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/JdbcRule.java
new file mode 100644
index 0000000..9354a5e
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/JdbcRule.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.junit;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+
+/**
+ * JUnit rule to set up a database. This will create a table using the configure creation statement on startup, run its
+ * wrapped test(s), then execute a drop table statement on shutdown, and finally will attempt execute a {@code SHUTDOWN}
+ * command afterward (e.g., for H2, HSQLDB). When used in integration tests, this rule should be the outer rule in a
+ * chain with {@link LoggerContextRule}.
+ *
+ * @since 2.8
+ */
+public class JdbcRule implements TestRule {
+
+    private final ConnectionSource connectionSource;
+    private final String createTableStatement;
+    private final String dropTableStatement;
+
+    /**
+     * Creates a JdbcRule using a {@link ConnectionSource} and a table creation statement.
+     *
+     * @param connectionSource     a source for obtaining a Connection
+     * @param createTableStatement a SQL DDL statement to set up a table for use in a JUnit test
+     * @param dropTableStatement   a SQL DDL statement to drop the created table
+     */
+    public JdbcRule(final ConnectionSource connectionSource, final String createTableStatement,
+                    final String dropTableStatement) {
+        this.dropTableStatement = dropTableStatement;
+        this.connectionSource = connectionSource;
+        this.createTableStatement = createTableStatement;
+    }
+
+    public ConnectionSource getConnectionSource() {
+        return connectionSource;
+    }
+
+    @Override
+    public org.junit.runners.model.Statement apply(final org.junit.runners.model.Statement base,
+                                                   final Description description) {
+        return new org.junit.runners.model.Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                try (final Connection connection = connectionSource.getConnection()) {
+                    try (final Statement statement = connection.createStatement()) {
+                        statement.executeUpdate(createTableStatement);
+                    }
+                    base.evaluate();
+                    try (final Statement statement = connection.createStatement()) {
+                        statement.executeUpdate(dropTableStatement);
+                        statement.execute("SHUTDOWN");
+                    }
+                }
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/java/org/apache/logging/log4j/junit/JndiRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/JndiRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/JndiRule.java
new file mode 100644
index 0000000..a1d6d65
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/JndiRule.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.junit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.mockejb.jndi.MockContext;
+import org.mockejb.jndi.MockContextFactory;
+
+/**
+ * JUnit rule to create a {@link MockContext} and bind an object to a name.
+ *
+ * @since 2.8
+ */
+public class JndiRule implements TestRule {
+
+    private final String name;
+    private final Object value;
+
+    public JndiRule(final String name, final Object value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    @Override
+    public Statement apply(final Statement base, final Description description) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                try {
+                    MockContextFactory.setAsInitial();
+                    initialize();
+                    base.evaluate();
+                } finally {
+                    MockContextFactory.revertSetAsInitial();
+                }
+            }
+        };
+    }
+
+    private void initialize() throws NamingException {
+        final String[] components = name.split("/");
+        Context context = new InitialContext();
+        for (int i = 0; i < components.length - 1; i++) {
+            context = context.createSubcontext(components[i]);
+        }
+        context.bind(components[components.length - 1], value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml b/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
index 6b72c83..b7ef940 100644
--- a/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
+++ b/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-h2-factory-method.xml
@@ -22,8 +22,8 @@
       <PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
     </Console>
     <Jdbc name="databaseAppender" tableName="fmLogEntry" ignoreExceptions="false">
-      <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcH2AppenderTest"
-                         method="getConfigConnection" />
+      <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppenderH2FactoryMethodTest"
+                         method="getConnection" />
       <Column name="eventDate" isEventTimestamp="true" />
       <Column name="literalColumn" literal="'Some Other Literal Value'" />
       <Column name="level" pattern="%level" />

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/29a6821d/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml b/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
index 5faced5..b486dbf 100644
--- a/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
+++ b/log4j-core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc/log4j2-hsqldb-factory-method.xml
@@ -22,8 +22,8 @@
       <PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
     </Console>
     <Jdbc name="databaseAppender" tableName="fmLogEntry" ignoreExceptions="false">
-      <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcHyperSqlAppenderTest"
-                         method="getConfigConnection" />
+      <ConnectionFactory class="org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppenderHsqlFactoryMethodTest"
+                         method="getConnection" />
       <Column name="eventDate" isEventTimestamp="true" />
       <Column name="literalColumn" literal="'Some Other Literal Value'" />
       <Column name="level" pattern="%level" />