Search in sources :

Example 21 with ISOPackager

use of org.jpos.iso.ISOPackager in project jPOS by jpos.

the class OneShotChannelAdaptorMK2 method newChannel.

private ISOChannel newChannel(Element e, QFactory f) throws ConfigurationException {
    String channelName = QFactory.getAttributeValue(e, "class");
    if (channelName == null) {
        throw new ConfigurationException("class attribute missing from channel element.");
    }
    String packagerName = QFactory.getAttributeValue(e, "packager");
    ISOChannel channel = (ISOChannel) f.newInstance(channelName);
    ISOPackager packager;
    if (packagerName != null) {
        packager = (ISOPackager) f.newInstance(packagerName);
        channel.setPackager(packager);
        f.setConfiguration(packager, e);
    }
    QFactory.invoke(channel, "setHeader", QFactory.getAttributeValue(e, "header"));
    f.setLogger(channel, e);
    f.setConfiguration(channel, e);
    if (channel instanceof FilteredChannel) {
        addFilters((FilteredChannel) channel, e, f);
    }
    String socketFactoryString = getSocketFactory();
    if (socketFactoryString != null && channel instanceof FactoryChannel) {
        ISOClientSocketFactory sFac = (ISOClientSocketFactory) getFactory().newInstance(socketFactoryString);
        if (sFac != null && sFac instanceof LogSource) {
            ((LogSource) sFac).setLogger(log.getLogger(), getName() + ".socket-factory");
        }
        getFactory().setConfiguration(sFac, e);
        ((FactoryChannel) channel).setSocketFactory(sFac);
    }
    return channel;
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) ConfigurationException(org.jpos.core.ConfigurationException) LogSource(org.jpos.util.LogSource) FilteredChannel(org.jpos.iso.FilteredChannel) ISOClientSocketFactory(org.jpos.iso.ISOClientSocketFactory) FactoryChannel(org.jpos.iso.FactoryChannel) ISOChannel(org.jpos.iso.ISOChannel)

Example 22 with ISOPackager

use of org.jpos.iso.ISOPackager in project jPOS by jpos.

the class ISOMsgFieldValidatingPackagerTest method testConstructor.

@Test
public void testConstructor() throws Throwable {
    ISOPackager msgPackager = new ISOBaseValidatingPackager();
    ISOMsgFieldValidatingPackager iSOMsgFieldValidatingPackager = new ISOMsgFieldValidatingPackager(new IFB_LLLCHAR(), msgPackager);
    assertNull(iSOMsgFieldValidatingPackager.getDescription(), "iSOMsgFieldValidatingPackager.getDescription()");
    assertEquals(-1, iSOMsgFieldValidatingPackager.getMaxPackedLength(), "iSOMsgFieldValidatingPackager.getMaxPackedLength()");
    assertEquals(-1, iSOMsgFieldValidatingPackager.getLength(), "iSOMsgFieldValidatingPackager.getLength()");
}
Also used : IFB_LLLCHAR(org.jpos.iso.IFB_LLLCHAR) ISOPackager(org.jpos.iso.ISOPackager) Test(org.junit.jupiter.api.Test)

Example 23 with ISOPackager

use of org.jpos.iso.ISOPackager in project jPOS by jpos.

the class PackagerTestCase method testPerformance.

@Test
public void testPerformance() throws Exception {
    final int COUNT = 100000;
    ISOPackager p = new GenericPackager("src/main/resources/packager/iso87binary.xml");
    ISOMsg baseMsg = getMsg("ISO87");
    System.out.println("\n--- pack/unpack performance test ---\n");
    Profiler prof = new Profiler();
    TPS tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        pack(baseMsg, p);
        tps.tick();
    }
    prof.checkPoint("PACK " + tps.toString());
    byte[] buf = baseMsg.pack();
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        unpack(buf, p);
        tps.tick();
    }
    prof.checkPoint("UNPACK " + tps.toString());
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        pack(baseMsg, p);
        unpack(buf, p);
        tps.tick();
    }
    prof.checkPoint("PACK/UNPACK " + tps.toString());
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        updatePackAndUnpack(baseMsg, p);
        tps.tick();
    }
    prof.checkPoint("UPDATE/PACK/UNPACK " + tps.toString());
    prof.dump(System.out, "");
    System.out.println("");
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) ISOMsg(org.jpos.iso.ISOMsg) Profiler(org.jpos.util.Profiler) TPS(org.jpos.util.TPS) Test(org.junit.jupiter.api.Test)

Example 24 with ISOPackager

use of org.jpos.iso.ISOPackager in project jPOS by jpos.

the class PostChannelTest method testConstructor1.

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

Example 25 with ISOPackager

use of org.jpos.iso.ISOPackager in project jPOS by jpos.

the class PostChannelTest method testConstructor2.

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

Aggregations

ISOPackager (org.jpos.iso.ISOPackager)46 Test (org.junit.jupiter.api.Test)42 ServerSocket (java.net.ServerSocket)12 ISOBaseValidatingPackager (org.jpos.iso.packager.ISOBaseValidatingPackager)5 ISO93APackager (org.jpos.iso.packager.ISO93APackager)4 ISOMsg (org.jpos.iso.ISOMsg)3 Base1Packager (org.jpos.iso.packager.Base1Packager)3 CTCSubFieldPackager (org.jpos.iso.packager.CTCSubFieldPackager)3 GenericPackager (org.jpos.iso.packager.GenericPackager)3 ISO87APackagerBBitmap (org.jpos.iso.packager.ISO87APackagerBBitmap)3 ISO87BPackager (org.jpos.iso.packager.ISO87BPackager)3 PostPackager (org.jpos.iso.packager.PostPackager)3 XMLPackager (org.jpos.iso.packager.XMLPackager)3 GenericValidatingPackager (org.jpos.iso.packager.GenericValidatingPackager)2 ISO87APackager (org.jpos.iso.packager.ISO87APackager)2 ISO93BPackager (org.jpos.iso.packager.ISO93BPackager)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 AbstractTableModel (javax.swing.table.AbstractTableModel)1 TableModel (javax.swing.table.TableModel)1