Created
December 7, 2022 14:50
-
-
Save ar/e5459490510e5d4547e4e3b6880c06cb to your computer and use it in GitHub Desktop.
Packager Debug JBang script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS org.jpos:jpos:2.1.8-SNAPSHOT | |
//REPOS mavenCentral,jpos=https://jpos.org/maven | |
import org.jpos.iso.ISOMsg; | |
import org.jpos.iso.ISOUtil; | |
import org.jpos.iso.packager.GenericPackager; | |
import org.jpos.util.Logger; | |
import org.jpos.util.SimpleLogListener; | |
import java.util.Arrays; | |
import java.util.Locale; | |
import java.util.StringTokenizer; | |
import java.nio.ByteBuffer; | |
class PackagerDebug { | |
private static final String dump = | |
"28 00 80 20 00 00 00 80 00 00 04 00 00 00 00 00" | |
+"00 00 00 00 00 00 00 01 32 39 31 31 30 30 30 31" | |
+"20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 03" | |
+"01"; | |
public static void main(String... args) throws Exception { | |
byte[] b = ISOUtil.hex2byte(dump.replace(" ", "")); | |
System.out.println (ISOUtil.hexdump(b)); | |
GenericPackager packager = new GenericPackager("jar:packager/cmf.xml"); | |
ISOMsg m = new ISOMsg(); | |
Logger logger = new Logger(); | |
logger.addListener (new SimpleLogListener(System.out)); | |
m.setPackager (packager); | |
packager.setLogger (logger, "debug"); | |
m.unpack (b); | |
m.dump (System.out, ""); | |
ISOMsg m1 = new ISOMsg(); | |
m1.setPackager (packager); | |
m1.unpack (m.pack()); | |
m.dump (System.out, ""); | |
if (!Arrays.equals(b, m.pack())) { | |
System.out.println ("Pack/Unpack differs"); | |
System.out.println (ISOUtil.hexdump (b)); | |
System.out.println (ISOUtil.hexdump (m.pack())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment