Skip to content

Commit 1a8df6b

Browse files
ninetteadhikariAlbaHerreriasjcoglan
authored andcommitted
Migrate log4j-jdbc-dbcp2 to JUnit 5 (#3007)
Co-authored-by: Alba Herrerias <[email protected]> Co-authored-by: James Coglan <[email protected]>
1 parent c70fe1c commit 1a8df6b

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

log4j-jdbc-dbcp2/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@
8282
<artifactId>junit-jupiter-engine</artifactId>
8383
<scope>test</scope>
8484
</dependency>
85-
<dependency>
86-
<groupId>org.junit.vintage</groupId>
87-
<artifactId>junit-vintage-engine</artifactId>
88-
<scope>test</scope>
89-
</dependency>
9085
</dependencies>
9186

9287
</project>

log4j-jdbc-dbcp2/src/test/java/org/apache/logging/log4j/dbcp2/appender/PoolableConnectionFactoryTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@
1616
*/
1717
package org.apache.logging.log4j.dbcp2.appender;
1818

19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
1921
import org.apache.logging.log4j.core.Appender;
20-
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
21-
import org.junit.Assert;
22-
import org.junit.ClassRule;
23-
import org.junit.Test;
22+
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
23+
import org.apache.logging.log4j.core.test.junit.Named;
24+
import org.junit.jupiter.api.Test;
2425

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

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

29-
@ClassRule
30-
public static final LoggerContextRule LCR = LoggerContextRule.createShutdownTimeoutLoggerContextRule(REL_PATH);
31-
3231
@Test
33-
public void test() {
34-
final Appender appender = LCR.getAppender("databaseAppender");
35-
Assert.assertNotNull("Problem loading configuration from " + REL_PATH, appender);
32+
public void test(@Named("databaseAppender") final Appender appender) {
33+
assertNotNull(appender, "Problem loading configuration from " + REL_PATH);
3634
}
3735
}

log4j-jdbc-dbcp2/src/test/java/org/apache/logging/log4j/dbcp2/appender/PoolingDriverConnectionSourceTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
*/
1717
package org.apache.logging.log4j.dbcp2.appender;
1818

19+
import static org.junit.jupiter.api.Assertions.assertFalse;
20+
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
1922
import java.sql.Connection;
2023
import java.sql.SQLException;
2124
import org.apache.logging.log4j.core.config.Property;
2225
import org.apache.logging.log4j.jdbc.appender.JdbcH2TestHelper;
23-
import org.junit.Assert;
24-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2527

2628
public class PoolingDriverConnectionSourceTest {
2729

@@ -76,9 +78,9 @@ public void testH2UserAndPassword() throws SQLException {
7678
}
7779

7880
private void openAndClose(final PoolingDriverConnectionSource source) throws SQLException {
79-
Assert.assertNotNull("PoolingDriverConnectionSource is null", source);
81+
assertNotNull(source, "PoolingDriverConnectionSource is null");
8082
try (final Connection conn = source.getConnection()) {
81-
Assert.assertFalse(conn.isClosed());
83+
assertFalse(conn.isClosed());
8284
} finally {
8385
source.stop();
8486
}

0 commit comments

Comments
 (0)