Search in sources :

Example 16 with GenericPackager

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

the class BaseChannelTest method testNewSocketThrowsIllegalArgumentException.

@Test
public void testNewSocketThrowsIllegalArgumentException() throws Throwable {
    byte[] TPDU = new byte[0];
    BaseChannel hEXChannel = new HEXChannel("testBaseChannelHost", -1, new GenericPackager(), TPDU);
    try {
        hEXChannel.newSocket("test", -1);
        fail("Expected IllegalArgumentException to be thrown");
    } catch (IllegalArgumentException ex) {
        assertEquals("ex.getMessage()", "port out of range:-1", ex.getMessage());
        assertNull("(HEXChannel) hEXChannel.socketFactory", ((HEXChannel) hEXChannel).socketFactory);
    }
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) HEXChannel(org.jpos.iso.channel.HEXChannel) Test(org.junit.Test)

Example 17 with GenericPackager

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

the class ASCIIChannelTest method testSendMessageLength.

@Test
public void testSendMessageLength() throws Throwable {
    ASCIIChannel aSCIIChannel = new ASCIIChannel("testASCIIChannelHost", 100, new GenericPackager());
    try {
        aSCIIChannel.sendMessageLength(Integer.MIN_VALUE);
        fail("IOException expected");
    } catch (IOException ex) {
        assertEquals("ex.getMessage()", "invalid negative length (" + Integer.MIN_VALUE + ")", ex.getMessage());
    }
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) IOException(java.io.IOException) Test(org.junit.Test)

Example 18 with GenericPackager

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

the class HEXChannelTest method testConstructor.

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

Example 19 with GenericPackager

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

the class LoopbackChannelTest method testSetPackager.

@Test
public void testSetPackager() throws Throwable {
    LoopbackChannel loopbackChannel = new LoopbackChannel();
    loopbackChannel.setPackager(new GenericPackager());
    assertNull("loopbackChannel.getName()", loopbackChannel.getName());
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) Test(org.junit.Test)

Example 20 with GenericPackager

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

the class StatefulFilterTest method testFilterThrowsNullPointerException3.

@Test
public void testFilterThrowsNullPointerException3() throws Throwable {
    int[] key = new int[0];
    StatefulFilter statefulFilter = new StatefulFilter();
    statefulFilter.setKey(key);
    statefulFilter.setSpace((Space) null);
    try {
        statefulFilter.filter(new CSChannel("testStatefulFilterHost", 100, new GenericPackager()), new ISOMsg("testStatefulFilterMti"), new LogEvent("testStatefulFilterTag", "testString"));
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : GenericPackager(org.jpos.iso.packager.GenericPackager) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) CSChannel(org.jpos.iso.channel.CSChannel) Test(org.junit.Test)

Aggregations

GenericPackager (org.jpos.iso.packager.GenericPackager)20 Test (org.junit.Test)20 ISOMsg (org.jpos.iso.ISOMsg)7 FileInputStream (java.io.FileInputStream)6 GenericTagSequence (org.jpos.tlv.GenericTagSequence)5 LiteralTagValue (org.jpos.tlv.LiteralTagValue)4 ISOPackager (org.jpos.iso.ISOPackager)3 ISOField (org.jpos.iso.ISOField)2 HEXChannel (org.jpos.iso.channel.HEXChannel)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectOutput (java.io.ObjectOutput)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Configuration (org.jpos.core.Configuration)1 SimpleConfiguration (org.jpos.core.SimpleConfiguration)1 SubConfiguration (org.jpos.core.SubConfiguration)1 EMVTagSequence (org.jpos.emv.EMVTagSequence)1 LiteralEMVTag (org.jpos.emv.LiteralEMVTag)1 ASCIIChannel (org.jpos.iso.channel.ASCIIChannel)1 CSChannel (org.jpos.iso.channel.CSChannel)1