Added unit tests for binaries (in progress). Added BINARY, LLBIN and LLLBIN to the DTD. Added a message template and a parsing template to the test config.

Fixed some problems with the stored values in IsoValues.


git-svn-id: https://j8583.svn.sourceforge.net/svnroot/j8583/j8583@64 db60a039-f72e-0410-b1d2-baa000846441
This commit is contained in:
chochos
2010-12-07 17:14:04 +00:00
parent 3c8cacbb8d
commit ad4f51d3cd
4 changed files with 86 additions and 5 deletions
+45
View File
@@ -0,0 +1,45 @@
package j8583;
import java.io.IOException;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.MessageFactory;
import com.solab.iso8583.util.HexCodec;
/** Test binary message encoding and binary fields. */
public class TestBinaries {
private MessageFactory mfactAscii = new MessageFactory();
private MessageFactory mfactBin = new MessageFactory();
@Before
public void setup() throws IOException {
mfactAscii.setConfigPath("config.xml");
mfactBin.setConfigPath("config.xml");
mfactAscii.setAssignDate(true);
mfactBin.setAssignDate(true);
mfactBin.setUseBinaryMessages(true);
}
@Test
public void testMessages() {
//Create a message with both factories
IsoMessage ascii = mfactAscii.newMessage(0x600);
IsoMessage bin = mfactBin.newMessage(0x600);
//HEXencode the binary message, headers should be similar to the ASCII version
String hexBin = HexCodec.hexEncode(bin.writeData());
String hexAscii = new String(ascii.writeData());
System.out.printf("bin: %s%nascii: %s%n", hexBin, hexAscii);
Assert.assertEquals("0600", hexBin.substring(0, 4));
//Should be the same up to the trace (first 64 chars)
Assert.assertEquals(hexAscii.substring(0, 64), hexBin.substring(0, 64));
//Parse both messages
//Compare values, should be the same
}
}
+20
View File
@@ -37,6 +37,15 @@
<field num="126" type="LLLVAR">...and yet another fixed field.</field>
</template>
<template type="0600">
<field num="4" type="AMOUNT">000000123400</field>
<field num="11" type="NUMERIC" length="6">123</field>
<field num="41" type="BINARY" length="8">abcdef</field>
<field num="43" type="ALPHA" length="40">Field of length 40</field>
<field num="62" type="LLBIN">0123456789abcdef</field>
<field num="102" type="LLLVAR">Field of type LLLVAR</field>
</template>
<!-- The server example uses this to read the requests -->
<parse type="0200">
<field num="3" type="NUMERIC" length="6" />
@@ -88,4 +97,15 @@
<field num="126" type="LLLVAR" />
</parse>
<!-- this is for binary tests (message encoding AND fields) -->
<parse type="0600">
<field num="4" type="AMOUNT" />
<field num="7" type="DATE10" />
<field num="11" type="NUMERIC" length="6" />
<field num="41" type="BINARY" length="8" />
<field num="43" type="ALPHA" length="40" />
<field num="62" type="LLBIN" />
<field num="102" type="LLLVAR" />
</parse>
</j8583-config>