@Test(expected = IllegalArgumentException.class) public void runWithKryoShouldRethrowException() { String value = pool.run( new KryoCallback<String>() { @Override public String execute(Kryo kryo) { throw new IllegalArgumentException(); } }); }
@Test public void runWithKryoShouldReturnResult() { String value = pool.run( new KryoCallback<String>() { @Override public String execute(Kryo kryo) { return "foo"; } }); assertEquals("foo", value); }
@Test public void runWithKryoShouldAddKryoToPool() { assertEquals(0, size()); pool.run( new KryoCallback<String>() { @Override public String execute(Kryo kryo) { return null; } }); assertEquals(1, size()); }
@Test public void runWithKryoShouldAddKryoToPoolOnException() { assertEquals(0, size()); try { pool.run( new KryoCallback<String>() { @Override public String execute(Kryo kryo) { throw new RuntimeException(); } }); fail("Exception should be rethrown."); } catch (RuntimeException e) { // expected } assertEquals(1, size()); }