[Proxool-cvs] proxool/src/java-test/org/logicalcobwebs/proxool FatalSqlExceptionTest.java,1.4,1.5
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2003-11-04 23:58:52
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv21683/src/java-test/org/logicalcobwebs/proxool Modified Files: FatalSqlExceptionTest.java Log Message: Made more robust (against existing database state) Index: FatalSqlExceptionTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/FatalSqlExceptionTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FatalSqlExceptionTest.java 29 Sep 2003 17:50:45 -0000 1.4 --- FatalSqlExceptionTest.java 4 Nov 2003 23:58:48 -0000 1.5 *************** *** 42,53 **** Properties info = new Properties(); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! Connection c = null; try { ! c = DriverManager.getConnection(url); ! Statement s = c.createStatement(); s.execute("drop table Z"); } catch (SQLException e) { --- 42,67 ---- Properties info = new Properties(); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, String.valueOf(Boolean.TRUE)); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, String.valueOf(Boolean.TRUE)); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! Connection c1 = null; try { ! c1 = DriverManager.getConnection(url); ! } finally { ! if (c1 != null) { ! c1.close(); ! } ! } ! ! Connection c2 = null; ! try { ! c2 = DriverManager.getConnection(url); ! assertTrue("Expected same connection back", c1.equals(c2)); ! Statement s = c2.createStatement(); ! // Doing it twice will guarantee a failure. Even if it exists ! s.execute("drop table Z"); s.execute("drop table Z"); } catch (SQLException e) { *************** *** 55,73 **** // Expected exception (foo doesn't exist) LOG.debug("Expected exception (safe to ignore)", e); } try { ! if (c != null) { ! c.close(); } - } catch (SQLException e) { - LOG.debug("Couldn't close connection", e); } - Thread.sleep(1000); - - // Proxool should automatically throw away that connection that caused a fatal sql exception - assertEquals("availableConnectionCount", 0L, ProxoolFacade.getSnapshot(alias, false).getAvailableConnectionCount()); - } --- 69,88 ---- // Expected exception (foo doesn't exist) LOG.debug("Expected exception (safe to ignore)", e); + } finally { + if (c2 != null) { + c2.close(); + } } + Connection c3 = null; try { ! c3 = DriverManager.getConnection(url); ! assertTrue("Expected a different connection", !c2.equals(c3)); ! } finally { ! if (c3 != null) { ! c3.close(); } } } *************** *** 206,209 **** --- 221,227 ---- Revision history: $Log$ + Revision 1.5 2003/11/04 23:58:48 billhorsman + Made more robust (against existing database state) + Revision 1.4 2003/09/29 17:50:45 billhorsman Tests for new wrapper. |