Пример #1
0
 @Test
 public void testReconnectThrowsIOException() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   try {
     channelPool.reconnect();
     fail("Expected IOException to be thrown");
   } catch (IOException ex) {
     assertEquals("ex.getClass()", IOException.class, ex.getClass());
     assertEquals("channelPool.pool.size()", 0, channelPool.pool.size());
     assertNull("channelPool.current", channelPool.current);
     assertTrue("channelPool.usable", channelPool.usable);
   }
 }
Пример #2
0
 @Test
 public void testReconnectThrowsIllegalArgumentException() throws Throwable {
   byte[] TPDU = new byte[2];
   ChannelPool channelPool = new ChannelPool();
   channelPool.addChannel(
       new NACChannel("testChannelPoolHost", -1, new ISOBaseValidatingPackager(), TPDU));
   try {
     channelPool.reconnect();
     fail("Expected IllegalArgumentException to be thrown");
   } catch (IllegalArgumentException ex) {
     assertEquals("ex.getMessage()", "port out of range:-1", ex.getMessage());
     assertEquals("channelPool.pool.size()", 1, channelPool.pool.size());
     assertNull("channelPool.current", channelPool.current);
     assertTrue("channelPool.usable", channelPool.usable);
   }
 }