use of org.jpos.iso.ISOBinaryField in project jPOS by jpos.
the class Base1_BITMAP126Test method testPackThrowsNullPointerException.
@Test
public void testPackThrowsNullPointerException() throws Throwable {
try {
new Base1_BITMAP126(100, "testBase1_BITMAP126Description").pack(new ISOBinaryField());
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
assertNull("ex.getMessage()", ex.getMessage());
}
}
use of org.jpos.iso.ISOBinaryField in project jPOS by jpos.
the class CTCSubElementPackagerTest method testPack.
@Test
public void testPack() throws Throwable {
CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager();
ISOFieldPackager[] fld = new ISOFieldPackager[2];
cTCSubElementPackager.setFieldPackager(fld);
byte[] result = cTCSubElementPackager.pack(new ISOBinaryField());
assertEquals("result.length", 0, result.length);
}
use of org.jpos.iso.ISOBinaryField in project jPOS by jpos.
the class CTCSubFieldPackagerTest method testPackThrowsISOException1.
@Test
public void testPackThrowsISOException1() throws Throwable {
try {
new CTCSubFieldPackager().pack(new ISOBinaryField(100));
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "null: null", ex.getMessage());
assertNull("ex.getNested().getMessage()", ex.getNested().getMessage());
}
}
use of org.jpos.iso.ISOBinaryField in project jPOS by jpos.
the class TagSequenceBase method readFrom.
@Override
public synchronized void readFrom(ISOMsg isoMsg) throws ISOException {
int maxField = isoMsg.getMaxField();
int minField = -1;
for (int i = 0; i <= maxField; i++) {
ISOComponent child = isoMsg.getComponent(i);
if (child instanceof ISOTaggedField) {
minField = i;
break;
}
}
if (minField == -1) {
// No TaggedFields to read
return;
}
for (int i = minField; i <= maxField; i++) {
ISOComponent child = isoMsg.getComponent(i);
if (child != null) {
if (child instanceof ISOTaggedField) {
TagValue tagValue;
ISOTaggedField taggedSubField = (ISOTaggedField) child;
ISOComponent delegate = taggedSubField.getDelegate();
if (delegate instanceof ISOMsg) {
Map subChildren = delegate.getChildren();
boolean allTaggedValue = true;
for (Object subChild : subChildren.values()) {
if (!(subChild instanceof ISOTaggedField)) {
allTaggedValue = false;
break;
}
}
if (allTaggedValue) {
tagValue = createTagValueSequence(taggedSubField.getTag());
((TagSequence) tagValue).readFrom((ISOMsg) delegate);
} else {
tagValue = new ISOMsgTagValue(getTag(), isoMsg);
}
} else if (delegate instanceof ISOBinaryField) {
tagValue = createBinaryTagValuePair(taggedSubField.getTag(), taggedSubField.getBytes());
} else if (delegate instanceof ISOField) {
tagValue = createLiteralTagValuePair(taggedSubField.getTag(), taggedSubField.getValue().toString());
} else {
throw new ISOException("Unknown ISOComponent subclass in ISOTaggedField: " + delegate.getClass());
}
this.add(tagValue);
} else {
throw new ISOException("Children after first ISOTaggedField should be instance of ISOTaggedField." + " Field " + i + " is not an ISOTaggedField");
}
}
}
}
Aggregations