diff --git a/pom.xml b/pom.xml
index 898a61f..3c66488 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.solab
j8583
- 1.3.4
+ 1.3.3
jar
j8583
Java implementation of the ISO 8583 protocol, focused on making the creation, edition and reading of ISO8583 messages as simple and flexible as possible.
diff --git a/src/test/java/j8583/CustomField48.java b/src/test/java/j8583/CustomField48.java
new file mode 100644
index 0000000..2cad067
--- /dev/null
+++ b/src/test/java/j8583/CustomField48.java
@@ -0,0 +1,57 @@
+package j8583;
+
+import com.solab.iso8583.CustomField;
+
+/** This is an example of a custom field codec, which converts between strings and instances of this same class.
+ *
+ * @author Enrique Zamudio
+ */
+public class CustomField48 implements CustomField {
+
+ private String v1;
+ private int v2;
+
+ public void setValue1(String value) {
+ v1 = value;
+ }
+ public String getValue1() {
+ return v1;
+ }
+ public void setValue2(int value) {
+ v2 = value;
+ }
+ public int setValue2() {
+ return v2;
+ }
+
+ @Override
+ public CustomField48 decodeField(String value) {
+ CustomField48 cf = null;
+ if (value != null) {
+ if (value.length() == 1 && value.charAt(0) == '|') {
+ cf = new CustomField48();
+ } else {
+ int idx = value.lastIndexOf('|');
+ if (idx < 0 || idx == value.length() - 1) {
+ throw new IllegalArgumentException(String.format("Invalid data '%s' for field 48", value));
+ }
+ cf = new CustomField48();
+ cf.setValue1(value.substring(0, idx));
+ cf.setValue2(Integer.parseInt(value.substring(idx + 1)));
+ }
+ }
+ return cf;
+ }
+
+ @Override
+ public String encodeField(CustomField48 value) {
+ StringBuilder sb = new StringBuilder();
+ if (v1 != null) {
+ sb.append(v1);
+ }
+ sb.append('|');
+ sb.append(v2);
+ return sb.toString();
+ }
+
+}
diff --git a/src/test/java/j8583/SimpleMessageTests.java b/src/test/java/j8583/SimpleMessageTests.java
new file mode 100644
index 0000000..b150cef
--- /dev/null
+++ b/src/test/java/j8583/SimpleMessageTests.java
@@ -0,0 +1,75 @@
+package j8583;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.solab.iso8583.IsoMessage;
+import com.solab.iso8583.IsoType;
+import com.solab.iso8583.MessageFactory;
+
+/** These are very simple tests for creating and manipulating messages.
+ *
+ * @author Enrique Zamudio
+ */
+public class SimpleMessageTests {
+
+ private MessageFactory mf;
+
+ @Before
+ public void init() throws IOException {
+ mf = new MessageFactory();
+ mf.setCustomField(48, new CustomField48());
+ mf.setConfigPath("config.xml");
+ }
+
+ /** Creates a new message and checks that it has all the fields included in the config. */
+ @Test
+ public void testCreation() {
+ IsoMessage iso = mf.newMessage(0x200);
+ assert iso.getType() == 0x200;
+ assert iso.getField(3).getType() == IsoType.NUMERIC && ((Number)iso.getObjectValue(3)).intValue() == 650000;
+ assert iso.getField(32).getType() == IsoType.LLVAR;
+ assert iso.getField(35).getType() == IsoType.LLVAR;
+ assert iso.getField(43).getType() == IsoType.ALPHA && ((String)iso.getObjectValue(43)).length() == 40;
+ assert iso.getField(48).getType() == IsoType.LLLVAR && iso.getObjectValue(48) instanceof CustomField48;
+ assert iso.getField(49).getType() == IsoType.ALPHA;
+ assert iso.getField(60).getType() == IsoType.LLLVAR;
+ assert iso.getField(61).getType() == IsoType.LLLVAR;
+ assert iso.getField(100).getType() == IsoType.LLVAR;
+ assert iso.getField(102).getType() == IsoType.LLVAR;
+ for (int i = 4; i < 32; i++) {
+ assert !iso.hasField(i);
+ }
+ for (int i = 36; i < 48; i++) {
+ assert !iso.hasField(i);
+ }
+ for (int i = 50; i < 60; i++) {
+ assert !iso.hasField(i);
+ }
+ for (int i = 62; i < 100; i++) {
+ assert !iso.hasField(i);
+ }
+ for (int i = 103; i < 128; i++) {
+ assert !iso.hasField(i);
+ }
+ }
+
+ /** Parses a message from a file and checks the fields. */
+ @Test
+ public void testParsing() throws IOException, ParseException {
+ InputStream ins = getClass().getResourceAsStream("example.txt");
+ byte[] buf = new byte[400];
+ int pos = 0;
+ while (ins.available() > 0) {
+ buf[pos++] = (byte)ins.read();
+ }
+ ins.close();
+ IsoMessage iso = mf.parseMessage(buf, mf.getIsoHeader(0x210).length());
+ assert iso.getType() == 0x210;
+ }
+
+}
diff --git a/src/test/resources/PLACEHOLDER b/src/test/resources/PLACEHOLDER
deleted file mode 100644
index e69de29..0000000
diff --git a/src/test/resources/config.xml b/src/test/resources/config.xml
new file mode 100644
index 0000000..312e1fe
--- /dev/null
+++ b/src/test/resources/config.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 650000
+ 456
+ 4591700012340000=
+ SOLABTEST TEST-3 DF MX
+ Life, the Universe, and Everything|42
+ 484
+ B456PRO1+000
+ 1234P vamos a meter mas de 90 caracteres en este campo para comprobar si hay algun error en el parseo del mismo. Esta definido como un LLLVAR aqui por lo tanto esto debe caber sin problemas; las guias de parseo de 200 y 210 tienen LLLVAR en campo 61 tambien.
+ 999
+ ABCD
+
+
+
+
+ Fixed data from template
+ ABC
+ Field of length 42
+ Fixed field
+ Another fixed field
+ ...and yet another fixed field.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/resources/parse1.txt b/src/test/resources/parse1.txt
new file mode 100644
index 0000000..639ca31
--- /dev/null
+++ b/src/test/resources/parse1.txt
@@ -0,0 +1,2 @@
+ISO0250000550210B23A80012EA080180000000014000004650000000000003000042813054746877112594604280428081103123173766123456123456=00123442579114472300614209027600TESTSOLAB TEST-3 DF MX484012B123PRO1+000013 0000P0312304ABCD040ABCD8123477547
+