commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1572193 - /commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
Date Wed, 26 Feb 2014 18:52:45 GMT
Author: markt
Date: Wed Feb 26 18:52:45 2014
New Revision: 1572193

URL: http://svn.apache.org/r1572193
Log:
Findbugs fixes

Modified:
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java?rev=1572193&r1=1572192&r2=1572193&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
Wed Feb 26 18:52:45 2014
@@ -18,6 +18,7 @@
 package org.apache.commons.dbcp2;
 
 import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.sql.Connection;
@@ -32,6 +33,7 @@ import junit.framework.TestSuite;
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.junit.Assert;
 
 /**
  * Tests for a  {@link GenericObjectPool} based {@link PoolingDriver}.
@@ -100,8 +102,8 @@ public class TestPoolingDriver extends T
         pcf.setDefaultAutoCommit(Boolean.TRUE);
         GenericObjectPool<PoolableConnection> connectionPool =
                 new GenericObjectPool<>(pcf);
-        @SuppressWarnings("unused") // Ensure PoolingDataSource can be created
         DataSource ds = new PoolingDataSource<>(connectionPool);
+        Assert.assertNotNull(ds);
     }
 
     public void test2() {
@@ -177,8 +179,7 @@ public class TestPoolingDriver extends T
         PoolingDriver driver2 = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
         driver2.closePool("test");
 
-        try {
-            DriverManager.getConnection("jdbc:apache:commons:dbcp:test");
+        try (Connection c = DriverManager.getConnection("jdbc:apache:commons:dbcp:test"))
{
             fail("expected SQLException");
         }
         catch (SQLException e) {
@@ -203,9 +204,9 @@ public class TestPoolingDriver extends T
     }
 
     public void testLogWriter() throws Exception {
-        PrintStream ps = new PrintStream(new ByteArrayOutputStream());
-        PrintWriter pw = new PrintWriter(new ByteArrayOutputStream());
-        System.setErr(new PrintStream(new ByteArrayOutputStream()));
+        PrintStream ps = new PrintStream(new ByteArrayOutputStream(), false, "UTF-8");
+        PrintWriter pw = new PrintWriter(new OutputStreamWriter(new ByteArrayOutputStream(),
"UTF-8"));
+        System.setErr(new PrintStream(new ByteArrayOutputStream(), false, "UTF-8"));
         SQLException ex;
 
         DriverManager.setLogWriter(pw);



Mime
View raw message