Search in sources :

Example 1 with ISOChannel

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

the class BSHFilterTest method testFilter1.

@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);
}
Also used : SimpleConfiguration(org.jpos.core.SimpleConfiguration) Configuration(org.jpos.core.Configuration) LogEvent(org.jpos.util.LogEvent) SimpleConfiguration(org.jpos.core.SimpleConfiguration) ISOVMsg(org.jpos.iso.ISOVMsg) ISOChannel(org.jpos.iso.ISOChannel) CSChannel(org.jpos.iso.channel.CSChannel) Test(org.junit.Test)

Example 2 with ISOChannel

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

the class ChannelAdaptorTest method stopCanWaitForWorkersEvenWhenOutgoingChannelNeverConnects.

@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();
        assertCallToStopCompletes(i);
    }
}
Also used : ISOException(org.jpos.iso.ISOException) ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.Test)

Example 3 with ISOChannel

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

the class ChannelPoolTest method testAddChannel1.

@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));
}
Also used : ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.Test)

Example 4 with ISOChannel

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

the class DelayFilterTest method testFilter2.

@Test
public void testFilter2() throws Throwable {
    DelayFilter delayFilter = new DelayFilter(-1);
    ISOChannel channel = new PADChannel(new CTCSubFieldPackager());
    LogEvent evt = new LogEvent("testDelayFilterTag", "");
    ISOMsg result = delayFilter.filter(channel, m, evt);
    assertEquals("evt.payLoad.size()", 2, evt.getPayLoad().size());
    assertEquals("evt.payLoad.get(1)", "<delay-filter delay=\"-1\"/>", evt.getPayLoad().get(1));
    assertSame("result", m, result);
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) PADChannel(org.jpos.iso.channel.PADChannel) CTCSubFieldPackager(org.jpos.iso.packager.CTCSubFieldPackager) ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.Test)

Example 5 with ISOChannel

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

the class MacroFilterTest method testFilter5.

@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");
    ISOMsg result = macroFilter.filter(channel, m, evt);
    assertSame("result", m, result);
}
Also used : NACChannel(org.jpos.iso.channel.NACChannel) ISOMsg(org.jpos.iso.ISOMsg) LogEvent(org.jpos.util.LogEvent) ISOChannel(org.jpos.iso.ISOChannel) Test(org.junit.Test)

Aggregations

ISOChannel (org.jpos.iso.ISOChannel)15 Test (org.junit.Test)10 LogEvent (org.jpos.util.LogEvent)9 ISOMsg (org.jpos.iso.ISOMsg)7 PADChannel (org.jpos.iso.channel.PADChannel)3 IOException (java.io.IOException)2 ConfigurationException (org.jpos.core.ConfigurationException)2 ISOException (org.jpos.iso.ISOException)2 CSChannel (org.jpos.iso.channel.CSChannel)2 ServerSocket (java.net.ServerSocket)1 Observable (java.util.Observable)1 StringTokenizer (java.util.StringTokenizer)1 Configuration (org.jpos.core.Configuration)1 SimpleConfiguration (org.jpos.core.SimpleConfiguration)1 FactoryChannel (org.jpos.iso.FactoryChannel)1 FilteredChannel (org.jpos.iso.FilteredChannel)1 ISOClientSocketFactory (org.jpos.iso.ISOClientSocketFactory)1 ISOPackager (org.jpos.iso.ISOPackager)1 ISOVMsg (org.jpos.iso.ISOVMsg)1 GZIPChannel (org.jpos.iso.channel.GZIPChannel)1