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;
}
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()");
}
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("");
}
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()");
}
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()");
}
Aggregations