Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate log4j-jdbc-dbcp2 to JUnit 5 #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions log4j-jdbc-dbcp2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@
*/
package org.apache.logging.log4j.core.appender.db.jdbc;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.core.test.junit.Named;
import org.junit.jupiter.api.Test;

@LoggerContextSource(value = "log4j2-jdbc-dbcp2.xml", timeout = 10)
public class PoolableConnectionFactoryTest {

private static final String REL_PATH = "src/test/resources/log4j2-jdbc-dbcp2.xml";

@ClassRule
public static final LoggerContextRule LCR = LoggerContextRule.createShutdownTimeoutLoggerContextRule(REL_PATH);

@Test
public void test() {
final Appender appender = LCR.getAppender("databaseAppender");
Assert.assertNotNull("Problem loading configuration from " + REL_PATH, appender);
public void test(@Named("databaseAppender") final Appender appender) {
assertNotNull(appender, "Problem loading configuration from " + REL_PATH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
*/
package org.apache.logging.log4j.core.appender.db.jdbc;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.sql.Connection;
import java.sql.SQLException;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.test.appender.db.jdbc.JdbcH2TestHelper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PoolingDriverConnectionSourceTest {

Expand Down Expand Up @@ -75,9 +77,9 @@ public void testH2UserAndPassword() throws SQLException {
}

private void openAndClose(final PoolingDriverConnectionSource source) throws SQLException {
Assert.assertNotNull("PoolingDriverConnectionSource is null", source);
assertNotNull(source, "PoolingDriverConnectionSource is null");
try (final Connection conn = source.getConnection()) {
Assert.assertFalse(conn.isClosed());
assertFalse(conn.isClosed());
} finally {
source.stop();
}
Expand Down