Exemple #1
0
 @Test
 public void testSetConfiguration() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   Configuration cfg = new SimpleConfiguration();
   channelPool.setConfiguration(cfg);
   assertSame("channelPool.cfg", cfg, channelPool.cfg);
 }
Exemple #2
0
 @Test
 public void testSize1() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.addChannel((ISOChannel) null);
   int result = channelPool.size();
   assertEquals("result", 1, result);
 }
Exemple #3
0
 @Test
 public void testGetRealm1() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.setLogger(new Logger(), "testChannelPoolRealm");
   String result = channelPool.getRealm();
   assertEquals("result", "testChannelPoolRealm", result);
 }
Exemple #4
0
 @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));
 }
Exemple #5
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);
 }
Exemple #6
0
 @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);
 }
Exemple #7
0
 @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);
 }
Exemple #8
0
 @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);
 }
Exemple #9
0
 @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());
   }
 }
Exemple #10
0
 @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);
 }
Exemple #11
0
 @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);
   }
 }
Exemple #12
0
 @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);
   }
 }
Exemple #13
0
 @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());
   }
 }
Exemple #14
0
 @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);
   }
 }
Exemple #15
0
 @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);
   }
 }
Exemple #16
0
 @Test
 public void testRemoveChannel() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.removeChannel(new BASE24TCPChannel());
   assertEquals("channelPool.pool.size()", 0, channelPool.pool.size());
 }
Exemple #17
0
 @Test
 public void testDisconnect1() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.disconnect();
   assertNull("channelPool.current", channelPool.current);
 }
Exemple #18
0
 @Test
 public void testSetUsable() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.setUsable(false);
   assertFalse("channelPool.usable", channelPool.usable);
 }
Exemple #19
0
 @Test
 public void testSetPackager() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.setPackager(new Base1SubFieldPackager());
   assertEquals("channelPool.getName()", "", channelPool.getName());
 }
Exemple #20
0
 @Test
 public void testSetName() throws Throwable {
   ChannelPool channelPool = new ChannelPool();
   channelPool.setName("testChannelPoolName");
   assertEquals("channelPool.name", "testChannelPoolName", channelPool.name);
 }