### Question:
VAPChannel extends BaseChannel { protected void sendMessageHeader(ISOMsg m, int len) throws IOException { ISOHeader h = !isOverrideHeader() && m.getHeader() != null ? m.getISOHeader() : new BASE1Header (srcid, dstid, headerFormat); if (h instanceof BASE1Header) ((BASE1Header)h).setLen(len); serverOut.write(h.pack()); } 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 testSendMessageHeaderThrowsNullPointerException() throws Throwable { VAPChannel vAPChannel = new VAPChannel(); ISOMsg m = new ISOMsg("testVAPChannelMti"); byte[] b = new byte[0]; m.setHeader(b); try { vAPChannel.sendMessageHeader(m, 100); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.DataOutputStream.write(byte[])\" because \"this.serverOut\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(0, m.getDirection(), "m.getDirection()"); } }
@Test public void testSendMessageHeaderThrowsNullPointerException2() throws Throwable { VAPChannel vAPChannel = new VAPChannel("testVAPChannelHost", 100, new XMLPackager()); ISOMsg m = new ISOMsg("testVAPChannelMti"); m.setHeader(new BaseHeader()); try { vAPChannel.sendMessageHeader(m, 100); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.io.DataOutputStream.write(byte[])\" because \"this.serverOut\" is null", ex.getMessage(), "ex.getMessage()"); } assertEquals(0, m.getDirection(), "m.getDirection()"); } }
@Test public void testSendMessageHeaderThrowsNullPointerException3() throws Throwable { VAPChannel vAPChannel = new VAPChannel(); try { vAPChannel.sendMessageHeader(null, 100); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.iso.ISOMsg.getHeader()\" because \"m\" is null", ex.getMessage(), "ex.getMessage()"); } } }