public void testRunSQLBlock() { ByteArrayOutputStream log = new ByteArrayOutputStream(); String msg = "search for me"; final Exception orig = new Exception(msg); SQLException caught = null; Exceptions.SQLBlock block = new Exceptions.SQLBlock( new PrintStream(log)) { @Override public Object inner() throws Exception { throw orig; } }; try { block.exec(); } catch (SQLException e) { caught = e; } assertNotNull(caught); assertEquals(orig, caught.getCause()); assertTrue(log.toString().indexOf(msg) >= 0); }
public void testRunSQLBlock() { ByteArrayOutputStream log = new ByteArrayOutputStream(); String msg = "search for me"; final Exception orig = new Exception(msg); SQLException caught = null; Exceptions.SQLBlock block = new Exceptions.SQLBlock( new PrintStream(log)) { public Object inner() throws Exception { throw orig; } }; try { block.exec(); } catch (SQLException e) { caught = e; } assertNotNull(caught); assertEquals(orig, caught.getCause()); assertTrue(log.toString().indexOf(msg) >= 0); }
public void testRunSQLBlock() { ByteArrayOutputStream log = new ByteArrayOutputStream(); String msg = "search for me"; final Exception orig = new Exception(msg); SQLException caught = null; Exceptions.SQLBlock block = new Exceptions.SQLBlock( new PrintStream(log)) { public Object inner() throws Exception { throw orig; } }; try { block.exec(); } catch (SQLException e) { caught = e; } assertNotNull(caught); assertEquals(orig, caught.getCause()); assertTrue(log.toString().indexOf(msg) >= 0); }
public Object exec() throws SQLException { try { return inner(); } catch (Exception e) { log(e); throw toSQLException(e); } } }
public Object exec() throws SQLException { try { return inner(); } catch (Exception e) { log(e); throw toSQLException(e); } } }
/** * @return the port of the MBean managed MySQL server * @throws SQLException */ String getPort() throws SQLException { Exceptions.SQLBlock block = new Exceptions.SQLBlock(System.err) { public Object inner() throws Exception { return getPortInner(); } }; return (String) block.exec(); }
public Object exec() throws SQLException { try { return inner(); } catch (Exception e) { log(e); throw toSQLException(e); } } }