This commit is contained in:
Enrique Zamudio
2015-02-19 18:13:15 -06:00
parent 15a3d03766
commit e310a859cb
2 changed files with 71 additions and 1 deletions
@@ -16,7 +16,7 @@ public class TestConfigParser {
@Test
public void testParser() throws IOException, ParseException {
MessageFactory<IsoMessage> mfact = new MessageFactory<IsoMessage>();
MessageFactory<IsoMessage> mfact = new MessageFactory<>();
mfact.setConfigPath("config.xml");
//Headers
Assert.assertNotNull(mfact.getIsoHeader(0x800));
@@ -58,4 +58,42 @@ public class TestConfigParser {
Assert.assertTrue(m.hasField(39));
}
@Test //issue 34
public void testMultilevelExtendParseGuides() throws IOException, ParseException {
MessageFactory<IsoMessage> mfact = new MessageFactory<>();
mfact.setConfigPath("issue34.xml");
//Parse a 200
final String m200 = "0200422000000880800001X1231235959123456101010202020TERMINAL484";
final String m210 = "0210422000000A80800001X123123595912345610101020202099TERMINAL484";
final String m400 = "0400422000000880800401X1231235959123456101010202020TERMINAL484001X";
final String m410 = "0410422000000a80800801X123123595912345610101020202099TERMINAL484001X";
IsoMessage m = mfact.parseMessage(m200.getBytes(), 0);
Assert.assertNotNull(m);
Assert.assertEquals("X", m.getObjectValue(2));
Assert.assertEquals("123456", m.getObjectValue(11));
Assert.assertEquals("TERMINAL", m.getObjectValue(41));
Assert.assertEquals("484", m.getObjectValue(49));
m = mfact.parseMessage(m210.getBytes(), 0);
Assert.assertNotNull(m);
Assert.assertEquals("X", m.getObjectValue(2));
Assert.assertEquals("123456", m.getObjectValue(11));
Assert.assertEquals("TERMINAL", m.getObjectValue(41));
Assert.assertEquals("484", m.getObjectValue(49));
Assert.assertEquals("99", m.getObjectValue(39));
m = mfact.parseMessage(m400.getBytes(), 0);
Assert.assertNotNull(m);
Assert.assertEquals("X", m.getObjectValue(2));
Assert.assertEquals("123456", m.getObjectValue(11));
Assert.assertEquals("TERMINAL", m.getObjectValue(41));
Assert.assertEquals("484", m.getObjectValue(49));
Assert.assertEquals("X", m.getObjectValue(62));
m = mfact.parseMessage(m410.getBytes(), 0);
Assert.assertNotNull(m);
Assert.assertEquals("X", m.getObjectValue(2));
Assert.assertEquals("123456", m.getObjectValue(11));
Assert.assertEquals("TERMINAL", m.getObjectValue(41));
Assert.assertEquals("484", m.getObjectValue(49));
Assert.assertEquals("99", m.getObjectValue(39));
Assert.assertEquals("X", m.getObjectValue(61));
}
}
+32
View File
@@ -0,0 +1,32 @@
<j8583-config>
<parse type="0200">
<field num="2" type="LLVAR" />
<field num="3" type="NUMERIC" length="6" />
<field num="4" type="NUMERIC" length="12" />
<field num="7" type="DATE10" />
<field num="11" type="NUMERIC" length="6" />
<field num="12" type="TIME" />
<field num="13" type="DATE4" />
<field num="15" type="DATE4" />
<field num="18" type="NUMERIC" length="4"/>
<field num="32" type="LLVAR" />
<field num="37" type="NUMERIC" length="12"/>
<field num="41" type="ALPHA" length="8"/>
<field num="42" type="ALPHA" length="15"/>
<field num="48" type="LLLVAR" />
<field num="49" type="ALPHA" length="3"/>
</parse>
<parse type="0210" extends="0200">
<field num="39" type="ALPHA" length="2" />
<field num="62" type="LLLVAR" />
</parse>
<parse type="0400" extends="0200">
<field num="62" type="LLLVAR" />
</parse>
<parse type="0410" extends="0400">
<field num="39" type="ALPHA" length="2" />
<field num="61" type="LLLVAR" />
</parse>
</j8583-config>