Search in sources :

Example 6 with ISO93APackager

use of org.jpos.iso.packager.ISO93APackager in project jPOS by jpos.

the class VAPChannelTest method testConstructor1.

@Test
public void testConstructor1() throws Throwable {
    ISOPackager p = new ISO93APackager();
    ServerSocket serverSocket = new ServerSocket();
    VAPChannel vAPChannel = new VAPChannel(p, serverSocket);
    assertEquals(0, vAPChannel.getIncomingFilters().size(), "vAPChannel.getIncomingFilters().size()");
    assertEquals(100000, vAPChannel.getMaxPacketLength(), "vAPChannel.getMaxPacketLength()");
    assertSame(p, vAPChannel.getPackager(), "vAPChannel.getPackager()");
    assertEquals(0, vAPChannel.getPort(), "vAPChannel.getPort()");
    assertEquals("", vAPChannel.getName(), "vAPChannel.getName()");
    assertEquals(3, vAPChannel.getCounters().length, "vAPChannel.getCounters().length");
    assertNull(vAPChannel.getLogger(), "vAPChannel.getLogger()");
    assertNull(vAPChannel.getSocketFactory(), "vAPChannel.getSocketFactory()");
    assertNull(vAPChannel.getHeader(), "vAPChannel.getHeader()");
    assertEquals(0, vAPChannel.getOutgoingFilters().size(), "vAPChannel.getOutgoingFilters().size()");
    assertSame(serverSocket, vAPChannel.getServerSocket(), "vAPChannel.getServerSocket()");
    assertEquals("org.jpos.iso.channel.VAPChannel", vAPChannel.getOriginalRealm(), "vAPChannel.getOriginalRealm()");
    assertNull(vAPChannel.getRealm(), "vAPChannel.getRealm()");
    assertNull(vAPChannel.getHost(), "vAPChannel.getHost()");
}
Also used : ISO93APackager(org.jpos.iso.packager.ISO93APackager) ServerSocket(java.net.ServerSocket) Test(org.junit.jupiter.api.Test)

Example 7 with ISO93APackager

use of org.jpos.iso.packager.ISO93APackager in project jPOS by jpos.

the class NACChannelTest method testConstructor1.

@Test
public void testConstructor1() throws Throwable {
    byte[] TPDU = new byte[3];
    ISOPackager p = new ISO93APackager();
    NACChannel nACChannel = new NACChannel("testNACChannelHost", 100, p, TPDU);
    assertEquals(0, nACChannel.getIncomingFilters().size(), "nACChannel.getIncomingFilters().size()");
    assertEquals(100000, nACChannel.getMaxPacketLength(), "nACChannel.getMaxPacketLength()");
    assertSame(p, nACChannel.getPackager(), "nACChannel.getPackager()");
    assertEquals(100, nACChannel.getPort(), "nACChannel.getPort()");
    assertEquals("", nACChannel.getName(), "nACChannel.getName()");
    assertEquals(3, nACChannel.getCounters().length, "nACChannel.getCounters().length");
    assertNull(nACChannel.getLogger(), "nACChannel.getLogger()");
    assertNull(nACChannel.getSocketFactory(), "nACChannel.getSocketFactory()");
    assertSame(TPDU, nACChannel.getHeader(), "nACChannel.getHeader()");
    assertEquals(0, nACChannel.getOutgoingFilters().size(), "nACChannel.getOutgoingFilters().size()");
    assertNull(nACChannel.getServerSocket(), "nACChannel.getServerSocket()");
    assertEquals("org.jpos.iso.channel.NACChannel", nACChannel.getOriginalRealm(), "nACChannel.getOriginalRealm()");
    assertNull(nACChannel.getRealm(), "nACChannel.getRealm()");
    assertEquals("testNACChannelHost", nACChannel.getHost(), "nACChannel.getHost()");
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) ISO93APackager(org.jpos.iso.packager.ISO93APackager) Test(org.junit.jupiter.api.Test)

Example 8 with ISO93APackager

use of org.jpos.iso.packager.ISO93APackager in project jPOS by jpos.

the class NACChannelTest method testSendMessageHeaderThrowsNullPointerException2.

@Test
public void testSendMessageHeaderThrowsNullPointerException2() throws Throwable {
    NACChannel nACChannel = new NACChannel(new ISO93APackager(), "testString".getBytes());
    ISOMsg m = new ISOMsg();
    byte[] b = new byte[0];
    m.setHeader(b);
    try {
        nACChannel.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()");
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) ISO93APackager(org.jpos.iso.packager.ISO93APackager) Test(org.junit.jupiter.api.Test)

Example 9 with ISO93APackager

use of org.jpos.iso.packager.ISO93APackager in project jPOS by jpos.

the class NACChannelTest method testSendMessageLengthThrowsNullPointerException.

@Test
public void testSendMessageLengthThrowsNullPointerException() throws Throwable {
    byte[] TPDU = new byte[0];
    NACChannel nACChannel = new NACChannel("testNACChannelHost", 100, new ISO93APackager(), TPDU);
    try {
        nACChannel.sendMessageLength(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(int)\" because \"this.serverOut\" is null", ex.getMessage(), "ex.getMessage()");
        }
    }
}
Also used : ISO93APackager(org.jpos.iso.packager.ISO93APackager) Test(org.junit.jupiter.api.Test)

Example 10 with ISO93APackager

use of org.jpos.iso.packager.ISO93APackager in project jPOS by jpos.

the class NACChannelTest method testSetHeaderThrowsNullPointerException.

@Test
public void testSetHeaderThrowsNullPointerException() throws Throwable {
    byte[] TPDU = new byte[0];
    byte[] TPDU2 = new byte[1];
    NACChannel nACChannel = new NACChannel(new ISO93APackager(), TPDU2, new ServerSocket());
    new NACChannel(new ISO93BPackager(), TPDU).addFilter(new DelayFilter(), 100);
    try {
        nACChannel.setHeader((String) null);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        if (isJavaVersionAtMost(JAVA_14)) {
            assertNull(ex.getMessage(), "ex.getMessage()");
        } else {
            assertEquals("Cannot invoke \"String.length()\" because \"s\" is null", ex.getMessage(), "ex.getMessage()");
        }
        assertSame(TPDU2, nACChannel.getHeader(), "nACChannel.getHeader()");
    }
}
Also used : DelayFilter(org.jpos.iso.filter.DelayFilter) ISO93BPackager(org.jpos.iso.packager.ISO93BPackager) ISO93APackager(org.jpos.iso.packager.ISO93APackager) ServerSocket(java.net.ServerSocket) Test(org.junit.jupiter.api.Test)

Aggregations

ISO93APackager (org.jpos.iso.packager.ISO93APackager)10 Test (org.junit.jupiter.api.Test)10 ISOPackager (org.jpos.iso.ISOPackager)4 ServerSocket (java.net.ServerSocket)2 ISOMsg (org.jpos.iso.ISOMsg)1 DelayFilter (org.jpos.iso.filter.DelayFilter)1 ISO93BPackager (org.jpos.iso.packager.ISO93BPackager)1