Пример #1
0
 @Test
 public void testUnpack() {
   try {
     iSOAmount.unpack(new byte[1]);
     fail("ISOException Expected");
   } catch (ISOException isoe) {
     assertThat(isoe.getMessage(), is("Not available"));
   }
 }
Пример #2
0
 @Test
 public void testSetValueBadCurrencyCode() {
   try {
     iSOAmount.setValue("X23456789012");
     fail("expected exception");
   } catch (ISOException e) {
     assertThat(e.getMessage(), is("For input string: \"X23\""));
   }
 }
Пример #3
0
 @Test
 public void testUnPack2() throws IOException {
   try {
     iSOAmount.unpack((InputStream) null);
     fail("ISOException Expected");
   } catch (ISOException isoe) {
     assertThat(isoe.getMessage(), is("Not available"));
   }
 }
Пример #4
0
 @Test
 public void testSetValueBadLength() {
   try {
     iSOAmount.setValue("1234");
     fail("expected invalid length ISOException");
   } catch (ISOException e) {
     assertThat(e.getMessage(), is("ISOAmount invalid length 4"));
   }
 }
Пример #5
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   in.readByte(); // ignore version for now
   fieldNumber = in.readShort();
   byte fieldType;
   ISOComponent c;
   try {
     while ((fieldType = in.readByte()) != 'E') {
       c = null;
       switch (fieldType) {
         case 'F':
           c = new ISOField();
           break;
         case 'A':
           c = new ISOAmount();
           break;
         case 'B':
           c = new ISOBinaryField();
           break;
         case 'M':
           c = new ISOMsg();
           break;
         case 'H':
           readHeader(in);
           break;
         case 'P':
           readPackager(in);
           break;
         case 'D':
           readDirection(in);
           break;
         default:
           throw new IOException("malformed ISOMsg");
       }
       if (c != null) {
         ((Externalizable) c).readExternal(in);
         set(c);
       }
     }
   } catch (ISOException e) {
     throw new IOException(e.getMessage());
   }
 }