"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-jdbc-dbcp2/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/PoolingDriverConnectionSourceTest.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

PoolingDriverConnectionSourceTest.java  (apache-log4j-2.11.1-src):PoolingDriverConnectionSourceTest.java  (apache-log4j-2.11.2-src)
skipping to change at line 39 skipping to change at line 39
@Test @Test
public void testH2Properties() throws SQLException { public void testH2Properties() throws SQLException {
final Property[] properties = new Property[] { final Property[] properties = new Property[] {
// @formatter:off // @formatter:off
Property.createProperty("username", JdbcH2TestHelper.USER_NAME), Property.createProperty("username", JdbcH2TestHelper.USER_NAME),
Property.createProperty("password", JdbcH2TestHelper.PASSWORD), Property.createProperty("password", JdbcH2TestHelper.PASSWORD),
// @formatter:on // @formatter:on
}; };
// @formatter:off // @formatter:off
final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder() final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder()
.setConnectionString(JdbcH2TestHelper.CONNECTION_STRING) .setConnectionString(JdbcH2TestHelper.CONNECTION_STRING_MEM)
.setProperties(properties) .setProperties(properties)
.build(); .build();
// @formatter:on
openAndClose(source); openAndClose(source);
} }
@Test @Test
public void testH2PropertiesAndPoolName() throws SQLException { public void testH2PropertiesAndPoolName() throws SQLException {
final Property[] properties = new Property[] { final Property[] properties = new Property[] {
// @formatter:off // @formatter:off
Property.createProperty("username", JdbcH2TestHelper.USER_NAME), Property.createProperty("username", JdbcH2TestHelper.USER_NAME),
Property.createProperty("password", JdbcH2TestHelper.PASSWORD), Property.createProperty("password", JdbcH2TestHelper.PASSWORD),
// @formatter:on // @formatter:on
}; };
// @formatter:off // @formatter:off
final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder() final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder()
.setConnectionString(JdbcH2TestHelper.CONNECTION_STRING) .setConnectionString(JdbcH2TestHelper.CONNECTION_STRING_MEM)
.setProperties(properties) .setProperties(properties)
.setPoolName("MyPoolName") .setPoolName("MyPoolName")
.build(); .build();
openAndClose(source); openAndClose(source);
} }
@Test @Test
public void testH2UserAndPassword() throws SQLException { public void testH2UserAndPassword() throws SQLException {
// @formatter:off // @formatter:off
final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder() final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder()
.setConnectionString(JdbcH2TestHelper.CONNECTION_STRING) .setConnectionString(JdbcH2TestHelper.CONNECTION_STRING_MEM)
.setUserName(JdbcH2TestHelper.USER_NAME.toCharArray()) .setUserName(JdbcH2TestHelper.USER_NAME.toCharArray())
.setPassword(JdbcH2TestHelper.PASSWORD.toCharArray()) .setPassword(JdbcH2TestHelper.PASSWORD.toCharArray())
.build(); .build();
// @formatter:on // @formatter:on
openAndClose(source); openAndClose(source);
} }
private void openAndClose(final PoolingDriverConnectionSource source) thr private void openAndClose(final PoolingDriverConnectionSource source) throws
ows SQLException { SQLException {
Assert.assertNotNull("PoolingDriverConnectionSource is null", sou Assert.assertNotNull("PoolingDriverConnectionSource is null", source);
rce); try (Connection conn = source.getConnection()) {
try (Connection conn = source.getConnection()) {
Assert.assertFalse(conn.isClosed()); Assert.assertFalse(conn.isClosed());
} finally { } finally {
source.stop(); source.stop();
} }
} }
@Test @Test
public void testH2UserPasswordAndPoolName() throws SQLException { public void testH2UserPasswordAndPoolName() throws SQLException {
// @formatter:off // @formatter:off
final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder() final PoolingDriverConnectionSource source = PoolingDriverConnectionSour ce.newPoolingDriverConnectionSourceBuilder()
.setConnectionString(JdbcH2TestHelper.CONNECTION_STRING) .setConnectionString(JdbcH2TestHelper.CONNECTION_STRING_MEM)
.setUserName(JdbcH2TestHelper.USER_NAME.toCharArray()) .setUserName(JdbcH2TestHelper.USER_NAME.toCharArray())
.setPassword(JdbcH2TestHelper.PASSWORD.toCharArray()) .setPassword(JdbcH2TestHelper.PASSWORD.toCharArray())
.setPoolName("MyPoolName") .setPoolName("MyPoolName")
.build(); .build();
// @formatter:on
openAndClose(source); openAndClose(source);
} }
@Test
public void testPoolableConnectionFactoryConfig() throws SQLException {
final PoolableConnectionFactoryConfig poolableConnectionFactoryConfig =
PoolableConnectionFactoryConfig.newBuilder().setMaxConnLifetimeMillis(30000).bui
ld();
// @formatter:off
final PoolingDriverConnectionSource source = PoolingDriverConnectionSour
ce.newPoolingDriverConnectionSourceBuilder()
.setConnectionString(JdbcH2TestHelper.CONNECTION_STRING_MEM)
.setUserName(JdbcH2TestHelper.USER_NAME.toCharArray())
.setPassword(JdbcH2TestHelper.PASSWORD.toCharArray())
.setPoolName("MyPoolName")
.setPoolableConnectionFactoryConfig(poolableConnectionFactoryConfig)
.build();
// @formatter:on
openAndClose(source);
}
} }
 End of changes. 10 change blocks. 
11 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)