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:
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user