### Question:
VAPChannel extends BaseChannel { public void setConfiguration (Configuration cfg) throws ConfigurationException { super.setConfiguration (cfg); srcid = cfg.get ("srcid", "000000"); dstid = cfg.get ("dstid", "000000"); debugPoll = cfg.getBoolean("debug-poll", false); headerFormat = cfg.getInt("header-format", 2); replyKeepAlive = cfg.getBoolean("reply-keepalive", true); swapDirection = cfg.getBoolean("swap-direction", true); } VAPChannel();  VAPChannel(String host, int port, ISOPackager p);  VAPChannel(ISOPackager p);  VAPChannel(ISOPackager p, ServerSocket serverSocket); void setSrcId(String srcid); String getSrcId(); void setDstId(String dstid); String getDstId(); void send(ISOMsg m); void setConfiguration(Configuration cfg);  }### Answer:
@Test public void testSetConfiguration() throws Throwable { VAPChannel vAPChannel = new VAPChannel(new Base1Packager()); vAPChannel.setSocketFactory(new GenericSSLSocketFactory()); vAPChannel.setConfiguration(new SimpleConfiguration()); assertEquals("000000", vAPChannel.srcid, "vAPChannel.srcid"); assertEquals("000000", vAPChannel.dstid, "vAPChannel.dstid"); assertEquals(100000, vAPChannel.getMaxPacketLength(), "vAPChannel.getMaxPacketLength()"); assertEquals(0, vAPChannel.getPort(), "vAPChannel.getPort()"); assertNull(vAPChannel.getSocket(), "vAPChannel.getSocket()"); assertEquals(300000, vAPChannel.getTimeout(), "vAPChannel.getTimeout()"); assertFalse(vAPChannel.isOverrideHeader(), "vAPChannel.isOverrideHeader()"); assertNull(vAPChannel.getHost(), "vAPChannel.getHost()"); }
@Test public void testSetConfiguration1() throws Throwable { VAPChannel vAPChannel = new VAPChannel(new Base1SubFieldPackager()); vAPChannel.setConfiguration(new SimpleConfiguration()); assertEquals("000000", vAPChannel.srcid, "vAPChannel.srcid"); assertEquals("000000", vAPChannel.dstid, "vAPChannel.dstid"); assertEquals(100000, vAPChannel.getMaxPacketLength(), "vAPChannel.getMaxPacketLength()"); assertEquals(0, vAPChannel.getPort(), "vAPChannel.getPort()"); assertNull(vAPChannel.getSocket(), "vAPChannel.getSocket()"); assertEquals(300000, vAPChannel.getTimeout(), "vAPChannel.getTimeout()"); assertFalse(vAPChannel.isOverrideHeader(), "vAPChannel.isOverrideHeader()"); assertNull(vAPChannel.getHost(), "vAPChannel.getHost()"); }
@Test public void testSetConfigurationThrowsNullPointerException() throws Throwable { VAPChannel vAPChannel = new VAPChannel(new GenericPackager()); Configuration cfg = new SubConfiguration(); try { vAPChannel.setConfiguration(cfg); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.core.Configuration.get(String)\" because \"this.cfg\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(100000, vAPChannel.getMaxPacketLength(), "vAPChannel.getMaxPacketLength()"); assertEquals(0, vAPChannel.getPort(), "vAPChannel.getPort()"); assertNull(vAPChannel.getSocket(), "vAPChannel.getSocket()"); assertEquals(0, vAPChannel.getTimeout(), "vAPChannel.getTimeout()"); assertEquals("000000", vAPChannel.srcid, "vAPChannel.srcid"); assertFalse(vAPChannel.isOverrideHeader(), "vAPChannel.isOverrideHeader()"); assertNull(vAPChannel.getHost(), "vAPChannel.getHost()"); assertEquals("000000", vAPChannel.dstid, "vAPChannel.dstid"); } }