@Test public void testUnpackThrowsISOException() throws Throwable { CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[6]; fld[0] = new IFA_LLLLCHAR(100, "testCTCSubFieldPackagerDescription"); cTCSubFieldPackager.setFieldPackager(fld); byte[] b = new byte[4]; try { cTCSubFieldPackager.unpack(new ISOField(), b); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("org.jpos.iso.IFA_LLLLCHAR: Problem unpacking field 0", ex.getMessage(), "ex.getMessage()"); assertEquals("Invalid character found. Expected digit.", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } }
public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; }
CTCSubFieldPackager extends ISOBaseValidatingPackager { public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } }
CTCSubFieldPackager extends ISOBaseValidatingPackager { public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } CTCSubFieldPackager(); }
CTCSubFieldPackager extends ISOBaseValidatingPackager { public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } CTCSubFieldPackager(); byte[] pack( ISOComponent c ); int unpack( ISOComponent m, byte[] b ); ISOComponent validate( ISOComponent c ); }
CTCSubFieldPackager extends ISOBaseValidatingPackager { public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } CTCSubFieldPackager(); byte[] pack( ISOComponent c ); int unpack( ISOComponent m, byte[] b ); ISOComponent validate( ISOComponent c );  }