Source:
<code>public void testExecute() throws Exception { OpExecutorImpl exec = new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, 3, <START> 10, -1, cancelCriterion, null); <END> Object result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { return "hello"; } }); assertEquals("hello", result); assertEquals(1, borrows); assertEquals(1, returns); assertEquals(0, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new SocketTimeoutException(); } }); fail("Should have got an exception"); } catch (ServerConnectivityException expected) { } assertEquals(1, borrows); assertEquals(3, exchanges); assertEquals(1, returns); assertEquals(4, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new ServerOperationException("Something didn't work"); } }); fail("Should have got an exception"); } catch (ServerOperationException expected) { } assertEquals(1, borrows); assertEquals(1, returns); assertEquals(0, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new IOException("Something didn't work"); } }); fail("Should have got an exception"); } catch (ServerConnectivityException expected) { } assertEquals(1, borrows); assertEquals(3, exchanges); assertEquals(1, returns); assertEquals(4, invalidateConnections); assertEquals(4, serverCrashes); }</code><technical_language>default for timeout is used, instead of hard-coding here, a reference DEFAULT_SERVER_CONNECTION_TIMEOUT defined in PoolFactory.java</technical_language>

Target:
public void testExecute() throws Exception { OpExecutorImpl exec = new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, 3, 10, PoolFactory.DEFAULT_SERVER_CONNECTION_TIMEOUT, cancelCriterion, null); Object result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { return "hello"; } }); assertEquals("hello", result); assertEquals(1, borrows); assertEquals(1, returns); assertEquals(0, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new SocketTimeoutException(); } }); fail("Should have got an exception"); } catch (ServerConnectivityException expected) { } assertEquals(1, borrows); assertEquals(3, exchanges); assertEquals(1, returns); assertEquals(4, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new ServerOperationException("Something didn't work"); } }); fail("Should have got an exception"); } catch (ServerOperationException expected) { } assertEquals(1, borrows); assertEquals(1, returns); assertEquals(0, invalidateConnections); assertEquals(0, serverCrashes); reset(); try { result = exec.execute(new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new IOException("Something didn't work"); } }); fail("Should have got an exception"); } catch (ServerConnectivityException expected) { } assertEquals(1, borrows); assertEquals(3, exchanges); assertEquals(1, returns); assertEquals(4, invalidateConnections); assertEquals(4, serverCrashes); }