@Test public void testSetConfiguration() throws Throwable { ChannelPool channelPool = new ChannelPool(); Configuration cfg = new SimpleConfiguration(); channelPool.setConfiguration(cfg); assertSame("channelPool.cfg", cfg, channelPool.cfg); }
@Test public void testSize1() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.addChannel((ISOChannel) null); int result = channelPool.size(); assertEquals("result", 1, result); }
@Test public void testGetRealm1() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.setLogger(new Logger(), "testChannelPoolRealm"); String result = channelPool.getRealm(); assertEquals("result", "testChannelPoolRealm", result); }
@Test public void testAddChannel1() throws Throwable { ChannelPool channelPool = new ChannelPool(); ISOChannel channel = new ASCIIChannel(); channelPool.addChannel(channel); assertEquals("channelPool.pool.size()", 1, channelPool.pool.size()); assertSame("channelPool.pool.get(0)", channel, channelPool.pool.get(0)); }
@Test public void testIsConnected() throws Throwable { ChannelPool channelPool = new ChannelPool(); boolean result = channelPool.isConnected(); assertFalse("result", result); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); assertNull("channelPool.current", channelPool.current); }
@Test public void testGetLogger() throws Throwable { ChannelPool channelPool = new ChannelPool(); Logger logger = new Logger(); channelPool.setLogger(logger, "testChannelPoolRealm"); Logger result = channelPool.getLogger(); assertSame("result", logger, result); }
@Test public void testSetLogger() throws Throwable { ChannelPool channelPool = new ChannelPool(); Logger logger = new Logger(); channelPool.setLogger(logger, "testChannelPoolRealm"); assertSame("channelPool.logger", logger, channelPool.logger); assertEquals("channelPool.realm", "testChannelPoolRealm", channelPool.realm); }
@Test public void testDisconnect() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.addChannel(new BASE24TCPChannel()); channelPool.disconnect(); assertEquals("channelPool.pool.size()", 1, channelPool.pool.size()); assertNull("channelPool.current", channelPool.current); }
@Test public void testAddChannelThrowsNotFoundException() throws Throwable { ChannelPool channelPool = new ChannelPool(); try { channelPool.addChannel("testChannelPoolName1"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "channel.testChannelPoolName1", ex.getMessage()); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); } }
@Test public void testIsConnectedDoNotThrowNullPointerExceptionWithNullLogListener() throws Throwable { Logger logger = new Logger(); logger.addListener(null); ChannelPool channelPool = new ChannelPool(); channelPool.setLogger(logger, "testChannelPoolRealm"); assertEquals("connected.isFalse", false, channelPool.isConnected()); assertNull("channelPool.current", channelPool.current); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); assertTrue("channelPool.usable", channelPool.usable); }
@Test public void testDisconnectThrowsNullPointerException1() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.addChannel((ISOChannel) null); try { channelPool.disconnect(); 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); } }
@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 testSetConfigurationThrowsNullPointerException() throws Throwable { ChannelPool channelPool = new ChannelPool(); Configuration cfg = new SubConfiguration(); try { channelPool.setConfiguration(cfg); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertSame("channelPool.cfg", cfg, channelPool.cfg); assertNull("ex.getMessage()", ex.getMessage()); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); } }
@Test public void testSendThrowsIllegalArgumentException() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.addChannel(new GZIPChannel("testChannelPoolHost", -1, new Base1SubFieldPackager())); try { channelPool.send((ISOMsg) new ISOMsg().clone()); 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); } }
@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); } }
@Test public void testRemoveChannel() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.removeChannel(new BASE24TCPChannel()); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); }
@Test public void testDisconnect1() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.disconnect(); assertNull("channelPool.current", channelPool.current); }
@Test public void testSetUsable() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.setUsable(false); assertFalse("channelPool.usable", channelPool.usable); }
@Test public void testSetPackager() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.setPackager(new Base1SubFieldPackager()); assertEquals("channelPool.getName()", "", channelPool.getName()); }
@Test public void testSetName() throws Throwable { ChannelPool channelPool = new ChannelPool(); channelPool.setName("testChannelPoolName"); assertEquals("channelPool.name", "testChannelPoolName", channelPool.name); }