public void testReturnBlockThrows() { Exception expected = null; final Exception orig = new Exception("test"); Exceptions.StringBlock block = new Exceptions.StringBlock() { public String inner() throws Exception { throw orig; } }; try { block.exec(); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(orig, expected.getCause()); }
public void testReturnBlockThrows() { Exception expected = null; final Exception orig = new Exception("test"); Exceptions.StringBlock block = new Exceptions.StringBlock() { @Override public String inner() throws Exception { throw orig; } }; try { block.exec(); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(orig, expected.getCause()); }
public void testReturnBlockThrows() { Exception expected = null; final Exception orig = new Exception("test"); Exceptions.Block block = new Exceptions.Block() { public Object inner() throws Exception { throw orig; } }; try { block.exec(); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(orig, expected.getCause()); }
public void testVoidBlock() { final Exception orig = new SQLException(); assertNull(orig.getMessage()); Exception caught = null; Exceptions.VoidBlock block = new Exceptions.VoidBlock() { public void inner() throws Exception { throw orig; } }; try { block.exec(); } catch (WrappedException converted) { caught = converted; } assertNotNull(caught); assertEquals(orig, caught.getCause()); }
public void testVoidBlock() { final Exception orig = new SQLException(); assertNull(orig.getMessage()); Exception caught = null; Exceptions.VoidBlock block = new Exceptions.VoidBlock() { public void inner() throws Exception { throw orig; } }; try { block.exec(); } catch (WrappedException converted) { caught = converted; } assertNotNull(caught); assertEquals(orig, caught.getCause()); }
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 testVoidBlock() { final Exception orig = new SQLException(); assertNull(orig.getMessage()); Exception caught = null; Exceptions.VoidBlock block = new Exceptions.VoidBlock() { @Override public void inner() throws Exception { throw orig; } }; try { block.exec(); } catch (WrappedException converted) { caught = converted; } assertNotNull(caught); assertEquals(orig, caught.getCause()); }
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)) { @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); }