Search in sources :

Example 1 with BASE1Header

use of org.jpos.iso.header.BASE1Header in project jPOS by jpos.

the class NCCChannelTest method testSendMessageHeaderThrowsNullPointerException1.

@Test
public void testSendMessageHeaderThrowsNullPointerException1() throws Throwable {
    byte[] TPDU = new byte[1];
    NCCChannel nCCChannel = new NCCChannel(new ISO87BPackager(), TPDU, new ServerSocket());
    ISOMsg m = new ISOMsg(100);
    m.setHeader(new BASE1Header("testNCCChannelSource", "testNCCChannelDestination"));
    try {
        nCCChannel.sendMessageHeader(m, 100);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : ISO87BPackager(org.jpos.iso.packager.ISO87BPackager) ISOMsg(org.jpos.iso.ISOMsg) BASE1Header(org.jpos.iso.header.BASE1Header) ServerSocket(java.net.ServerSocket) Test(org.junit.Test)

Example 2 with BASE1Header

use of org.jpos.iso.header.BASE1Header in project jPOS by jpos.

the class VAPChannelTest method testGetDynamicHeader.

@Test
public void testGetDynamicHeader() throws Throwable {
    VAPChannel vAPChannel = new VAPChannel();
    byte[] image = new byte[0];
    BASE1Header result = (BASE1Header) vAPChannel.getDynamicHeader(image);
    assertNotNull(result);
    assertTrue("Test completed without Exception", true);
}
Also used : BASE1Header(org.jpos.iso.header.BASE1Header) Test(org.junit.Test)

Example 3 with BASE1Header

use of org.jpos.iso.header.BASE1Header in project jPOS by jpos.

the class VAPChannelTest method testSendMessageHeaderThrowsArrayIndexOutOfBoundsException.

@Test
public void testSendMessageHeaderThrowsArrayIndexOutOfBoundsException() throws Throwable {
    VAPChannel vAPChannel = new VAPChannel();
    final byte[] image = new byte[2];
    VAPChannel vAPChannel2 = new VAPChannel(new ISO87BPackager());
    final BASE1Header dynamicHeader = (BASE1Header) vAPChannel2.getDynamicHeader(image);
    given(m.getHeader()).willReturn(image);
    given(m.getISOHeader()).willReturn(dynamicHeader);
    try {
        vAPChannel.sendMessageHeader(m, 100);
        fail("Expected ArrayIndexOutOfBoundsException to be thrown");
    } catch (ArrayIndexOutOfBoundsException ex) {
        assertEquals("ex.getMessage()", "3", ex.getMessage());
    }
}
Also used : ISO87BPackager(org.jpos.iso.packager.ISO87BPackager) BASE1Header(org.jpos.iso.header.BASE1Header) Test(org.junit.Test)

Example 4 with BASE1Header

use of org.jpos.iso.header.BASE1Header in project jPOS by jpos.

the class ISOMsg2Test method testWriteHeader.

@Test
public void testWriteHeader() throws Throwable {
    final ISOMsg m = mock(ISOMsg.class);
    final ISOVError isov = mock(ISOVError.class);
    ISOMsg iSOVMsg = new ISOVMsg(m, isov);
    final BASE1Header header = mock(BASE1Header.class);
    iSOVMsg.setHeader(header);
    final ObjectOutputStream out = mock(ObjectOutputStream.class);
    final byte[] bytes = new byte[1];
    bytes[0] = (byte) 0;
    given(header.getLength()).willReturn(1);
    given(header.pack()).willReturn(bytes);
    iSOVMsg.writeHeader(out);
    assertSame("(ISOVMsg) iSOVMsg.header", header, ((ISOVMsg) iSOVMsg).header);
    verify(out).write(bytes);
    verify(out).writeByte(72);
    verify(out).writeShort(1);
}
Also used : BASE1Header(org.jpos.iso.header.BASE1Header) ObjectOutputStream(java.io.ObjectOutputStream) Test(org.junit.Test)

Example 5 with BASE1Header

use of org.jpos.iso.header.BASE1Header in project jPOS by jpos.

the class VAPChannel method send.

/**
 * sends an ISOMsg over the TCP/IP session.
 *
 * swap source/destination addresses in BASE1Header if
 * a reply message is detected.<br>
 * Sending an incoming message is seen as a reply.
 *
 * @param m the Message to be sent
 * @exception IOException
 * @exception ISOException
 * @see ISOChannel#send
 */
public void send(ISOMsg m) throws IOException, ISOException {
    if (m.isIncoming() && m.getHeader() != null) {
        BASE1Header h = new BASE1Header(m.getHeader());
        h.swapDirection();
    }
    super.send(m);
}
Also used : BASE1Header(org.jpos.iso.header.BASE1Header)

Aggregations

BASE1Header (org.jpos.iso.header.BASE1Header)6 Test (org.junit.Test)4 ISO87BPackager (org.jpos.iso.packager.ISO87BPackager)2 ObjectOutputStream (java.io.ObjectOutputStream)1 ServerSocket (java.net.ServerSocket)1 ISOMsg (org.jpos.iso.ISOMsg)1