You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/01/19 00:09:36 UTC

cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp TestManual.java

dirkv       2004/01/18 15:09:36

  Modified:    dbcp/src/test/org/apache/commons/dbcp TestManual.java
  Log:
  Bugzilla Bug 26072 Null pointer exception being thrown in SQLNestedException
  - testcase for all NestedException variants
  
  Revision  Changes    Path
  1.17      +47 -3     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestManual.java
  
  Index: TestManual.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestManual.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestManual.java	10 Nov 2003 14:40:26 -0000	1.16
  +++ TestManual.java	18 Jan 2004 23:09:36 -0000	1.17
  @@ -61,6 +61,8 @@
   
   package org.apache.commons.dbcp;
   
  +import java.io.PrintStream;
  +import java.io.PrintWriter;
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.SQLException;
  @@ -162,5 +164,47 @@
           catch (SQLException e) {
               // OK
           }
  +    }
  +    
  +    public void testLogWriter() throws Exception {
  +        PrintStream ps = System.out;
  +        PrintWriter pw = new PrintWriter(System.err);
  +        SQLException ex;
  +        
  +        DriverManager.setLogWriter(pw);
  +        ex = new SQLNestedException("A", new Exception("a"));
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException("B", null);
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException(null, new Exception("c"));
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException(null, null);
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +
  +        DriverManager.setLogWriter(null);
  +        ex = new SQLNestedException("A", new Exception("a"));
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException("B", null);
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException(null, new Exception("c"));
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
  +        ex = new SQLNestedException(null, null);
  +        ex.printStackTrace();
  +        ex.printStackTrace(ps);
  +        ex.printStackTrace(pw);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org