### Question:
NCCChannel extends BaseChannel { protected void sendMessageHeader(ISOMsg m, int len) throws IOException { byte[] h = m.getHeader(); if (h != null) { if (tpduSwap && h.length == 5) { byte[] tmp = new byte[2]; System.arraycopy (h, 1, tmp, 0, 2); System.arraycopy (h, 3, h, 1, 2); System.arraycopy (tmp, 0, h, 3, 2); } } else h = header ; if (h != null) serverOut.write(h); } NCCChannel();  NCCChannel(String host, int port, ISOPackager p, byte[] TPDU);  NCCChannel(ISOPackager p, byte[] TPDU);  NCCChannel(ISOPackager p, byte[] TPDU, ServerSocket serverSocket); void setHeader(String header); void setConfiguration(Configuration cfg);  }### Answer:
@Test public void testSendMessageHeader() throws Throwable { NCCChannel nCCChannel = new NCCChannel(); ISOMsg m = new ISOMsg(); nCCChannel.sendMessageHeader(m, 100); assertEquals(0, m.getDirection(), "m.getDirection()"); }
@Test public void testSendMessageHeaderThrowsNullPointerException() throws Throwable { byte[] TPDU = new byte[1]; NCCChannel nCCChannel = new NCCChannel(new ISO87BPackager(), TPDU, new ServerSocket()); ISOMsg m = new ISOMsg(); try { nCCChannel.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()"); } } }
@Test public void testSendMessageHeaderThrowsNullPointerException2() throws Throwable { byte[] TPDU = new byte[16]; NCCChannel nCCChannel = new NCCChannel(new ISO87APackager(), TPDU); try { nCCChannel.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()"); } } }