Examples of ISOChannel


Examples of org.jpos.iso.ISOChannel

    }

    @Test
    public void testFilter() throws Throwable {
        MacroFilter macroFilter = new MacroFilter();
        ISOChannel channel = new GZIPChannel(new X92GenericPackager());
        LogEvent evt = new LogEvent("testMacroFilterTag", "\u0000\u0000");
        when(m.getMaxField()).thenReturn(0);
        ISOMsg result = macroFilter.filter(channel, m, evt);
        assertSame("result", m, result);
        verify(m).hasField(0);
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    }

    @Test
    public void testFilter3() throws Throwable {
        MacroFilter macroFilter = new MacroFilter();
        ISOChannel channel = new PADChannel(new GenericSubFieldPackager());
        LogEvent evt = new LogEvent();
        when(m.getMaxField()).thenReturn(0);
        when(m.hasField(0)).thenReturn(false);

        ISOMsg result = macroFilter.filter(channel, m, evt);
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    @Test
    public void testFilter5() throws Throwable {
        MacroFilter macroFilter = new MacroFilter();
        LogEvent evt = new LogEvent();
        ISOChannel channel = new NACChannel();

        when(m.getMaxField()).thenReturn(0);
        when(m.hasField(0)).thenReturn(true);
        when(m.getValue(0)).thenReturn("N/A in Composite");
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    @Test
    public void testFilter1() throws Throwable {
        BSHFilter bSHFilter = new BSHFilter();
        Configuration cfg = new SimpleConfiguration();
        bSHFilter.setConfiguration(cfg);
        ISOChannel channel = new CSChannel();
        LogEvent evt = new LogEvent();

        ISOVMsg result = (ISOVMsg) bSHFilter.filter(channel, m, evt);
        assertSame("result", m, result);
        assertSame("bSHFilter.cfg", cfg, bSHFilter.cfg);
View Full Code Here

Examples of org.jpos.iso.ISOChannel

        Object obj = sp.inp(key);
        if (obj instanceof ISOMsg) {
            ISOMsg m = (ISOMsg) obj;
            if ("LAST".equals(sendMethod)) {
                try {
                    ISOChannel c = server.getLastConnectedISOChannel();
                    if (c == null) {
                        throw new ISOException("Server has no active connections");
                    }
                    if (!c.isConnected()) {
                        throw new ISOException("Client disconnected");
                    }
                    c.send(m);
                }
                catch (Exception e) {
                    getLog().warn("notify", e);
                }
            }
            else if ("ALL".equals(sendMethod)) {
                String channelNames = getISOChannelNames();
                if (channelNames != null) {
                    StringTokenizer tok = new StringTokenizer(channelNames, " ");
                    while (tok.hasMoreTokens()) {
                        try {
                            ISOChannel c = server.getISOChannel(tok.nextToken());
                            if (c == null) {
                                throw new ISOException("Server has no active connections");
                            }
                            if (!c.isConnected()) {
                                throw new ISOException("Client disconnected");
                            }
                            c.send(m);
                        } catch (Exception e) {
                            getLog().warn("notify", e);
                        }
                    }
                }
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    @Test
    public void testFilter2() throws Throwable {
  int[] key = new int[0];
  StatefulFilter statefulFilter = new StatefulFilter();
  statefulFilter.setKey(key);
  ISOChannel iSOChannel = new PADChannel();
  LogEvent evt = new LogEvent("testStatefulFilterTag");
  ISOMsg m = mock(ISOMsg.class);

  given(m.getDirection()).willReturn(58);
View Full Code Here

Examples of org.jpos.iso.ISOChannel

public class ChannelPoolTest {

    @Test
    public void testAddChannel1() throws Throwable {
        ChannelPool channelPool = new ChannelPool();
        ISOChannel channel = new ASCIIChannel();
        channelPool.addChannel(channel);
        assertEquals("channelPool.pool.size()", 1, channelPool.pool.size());
        assertSame("channelPool.pool.get(0)", channel, channelPool.pool.get(0));
    }
View Full Code Here

Examples of org.jpos.iso.ISOChannel

        }
    }

    @Test
    public void stopCanWaitForWorkersEvenWhenOutgoingChannelNeverConnects() throws Exception {
        ISOChannel channel = mock(ISOChannel.class);
        when(channel.isConnected()).thenReturn(false);
        when(channel.receive()).thenThrow(new ISOException("unconnected ISOChannel"));

        // repeat test to ensure clean up occurs after stop
        for (int i = 0; i < 10; i++) {
            channelAdaptor = configureAndStart(new ChannelAdaptorWithoutQ2(channel));
            waitForSenderAndReceiverToStart();
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    @Test
    public void stopCanWaitForWorkersEvenWhenSenderBlockedTryingToConnect() throws Exception {
        // Think a link where the other ends plays the client role. Eg a BaseChannel with a serverSocket.
        // So connect() calls socket.accept(). If no client connects accept() blocks forever.
        // Ensures disconnect() is called on stop() regardless of channel.isConnected() return value.
        ISOChannel channel = mock(ISOChannel.class);

        ThreadTrap trap = new ThreadTrap(SENDER_THREAD_NAME);
        when(channel.isConnected()).thenReturn(false);
        trap.catchVictim().when(channel).connect();
        trap.release().when(channel).disconnect();

        channelAdaptor = configureAndStart(new ChannelAdaptorWithoutQ2(channel));
        waitForSenderAndReceiverToStart();
View Full Code Here

Examples of org.jpos.iso.ISOChannel

    @Test
    public void testFilter() throws Throwable {
        DelayFilter delayFilter = new DelayFilter(0);
        LogEvent evt = new LogEvent("testDelayFilterTag", "testString");
        ISOChannel channel = new CSChannel(new Base1SubFieldPackager(), new ServerSocket());
        ISOMsg result = delayFilter.filter(channel, m, evt);
        assertEquals("evt.payLoad.size()", 2, evt.getPayLoad().size());
        assertEquals("evt.payLoad.get(1)", "<delay-filter delay=\"0\"/>", evt.getPayLoad().get(1));
        assertSame("result", m, result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.