Search in sources :

Example 11 with ISOPackager

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

the class BASE24ChannelTest method testConstructor2.

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

Example 12 with ISOPackager

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

the class CSChannelTest method testConstructor3.

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

Example 13 with ISOPackager

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

the class GZIPChannelTest method testConstructor3.

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

Example 14 with ISOPackager

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

the class GZIPChannelTest method testConstructor.

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

Example 15 with ISOPackager

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

the class ISOMsgPanel method createISOMsgTable.

private JComponent createISOMsgTable() {
    TableModel dataModel = new AbstractTableModel() {

        private static final long serialVersionUID = 8917029825751856951L;

        @Override
        public int getColumnCount() {
            return 3;
        }

        @Override
        public int getRowCount() {
            return validFields.size();
        }

        @Override
        public String getColumnName(int columnIndex) {
            switch(columnIndex) {
                case 0:
                    return "#";
                case 1:
                    return "Content";
                case 2:
                    return "Description";
                default:
                    return "";
            }
        }

        @Override
        public Object getValueAt(int row, int col) {
            switch(col) {
                case 0:
                    return validFields.elementAt(row);
                case 1:
                    int index = (Integer) validFields.elementAt(row);
                    Object obj = m.getValue(index);
                    if (obj instanceof String) {
                        String s = obj.toString();
                        switch(index) {
                            case 2:
                            case 35:
                            case 45:
                                s = ISOUtil.protect(s);
                                break;
                            case 14:
                                s = "----";
                        }
                        return s;
                    } else if (obj instanceof byte[])
                        return ISOUtil.hexString((byte[]) obj);
                    else if (obj instanceof ISOMsg)
                        return "<ISOMsg>";
                    break;
                case 2:
                    int i = (Integer) validFields.elementAt(row);
                    ISOPackager p = m.getPackager();
                    return p.getFieldDescription(m, i);
            }
            return "<???>";
        }
    };
    JTable table = new JTable(dataModel);
    table.getColumnModel().getColumn(0).setPreferredWidth(10);
    table.setPreferredScrollableViewportSize(new Dimension(500, table.getRowCount() * table.getRowHeight()));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = table.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (!lsm.isSelectionEmpty()) {
                int selectedRow = lsm.getMinSelectionIndex();
                int index = (Integer) validFields.elementAt(selectedRow);
                Object obj = m.getValue(index);
                if (obj instanceof ISOMsg) {
                    ISOMsg sm = (ISOMsg) obj;
                    JFrame f = new JFrame("ISOMsg field " + index);
                    ISOMsgPanel p = new ISOMsgPanel(sm, false);
                    f.getContentPane().add(p);
                    f.pack();
                    f.show();
                }
            }
        }
    });
    return new JScrollPane(table);
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ISOPackager(org.jpos.iso.ISOPackager) ISOMsg(org.jpos.iso.ISOMsg) AbstractTableModel(javax.swing.table.AbstractTableModel) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

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