@Test public void testConnectThrowsIOException() throws Throwable { ChannelPool channelPool = new ChannelPool(); try { channelPool.connect(); fail("Expected IOException to be thrown"); } catch (IOException ex) { assertEquals("ex.getClass()", IOException.class, ex.getClass()); assertNull("channelPool.current", channelPool.current); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); assertTrue("channelPool.usable", channelPool.usable); } }
@Test public void testConnectThrowsNullPointerException1() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.addChannel((ISOChannel) null); try { channelPool.connect(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("channelPool.pool.size()", 1, channelPool.pool.size()); assertNull("channelPool.current", channelPool.current); assertTrue("channelPool.usable", channelPool.usable); } }
@Test public void testConnectThrowsIllegalArgumentException() throws Throwable { byte[] TPDU = new byte[2]; ChannelPool channelPool = new ChannelPool(); channelPool.addChannel( new NACChannel("testChannelPoolHost", -1, new ISOBaseValidatingPackager(), TPDU)); try { channelPool.connect(); 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); } }