@Override public ISOMsg request(ISOMsg m, long timeout) throws ISOException { ISOMsg r = (ISOMsg) m.clone(); r.setResponseMTI(); r.set(39, "00"); return r; }
@Override public void dump(final PrintStream p, final String indent) { delegate.dump(p, indent); }
/** * add all fields present on received parameter to this ISOMsg<br> * please note that received fields take precedence over * existing ones (simplifying card agent message creation * and template handling) * @param m ISOMsg to merge */ @SuppressWarnings("PMD.EmptyCatchBlock") public void merge (ISOMsg m) { for (int i=0; i<=m.getMaxField(); i++) try { if (m.hasField(i)) set (m.getComponent(i)); } catch (ISOException ignored) { // should never happen } }
@Test public void testUnpack() throws ISOException { ISOMsg m1 = new ISOMsg(); m1.setPackager(p); m1.unpack(PACKED); assertEquals("0800", m1.getMTI()); assertEquals("000000", m1.getString(3)); assertEquals("000001", m1.getString(11)); assertEquals("29110001", m1.getString(41)); assertArrayEquals(ISOUtil.hex2byte("55AA1122"), m1.getBytes(55)); assertEquals("Test 127.2", m1.getString("127.2")); assertEquals("Test 127.3", m1.getString("127.3")); assertEquals("Test 127.4", m1.getString("127.4")); assertEquals("Test 127.5.1", m1.getString("127.5.1")); } }
/** * Return the byte[] value associated with the given ISOField number * @param fldno the Field Number * @return field's byte[] value or null if ISOException or UnsupportedEncodingException happens */ public byte[] getBytes (int fldno) { byte[] b = null; if (hasField (fldno)) { Object obj = getValue(fldno); if (obj instanceof String) b = ((String) obj).getBytes(ISOUtil.CHARSET); else if (obj instanceof byte[]) b = (byte[]) obj; } return b; } /**
public void testGetBytes() throws Exception { ISOMsg m = new ISOMsg("0800"); m.set (3, "000000"); m.set (52, "CAFEBABE".getBytes()); m.set ("63.2.3", "Field 63.2.3"); m.set ("63.2.4", m.getBytes (52)); assertEquals ("000000", m.getString (3)); assertEquals ("000000", new String(m.getBytes(3))); assertEquals ("CAFEBABE", new String(m.getBytes(52))); assertEquals ("Field 63.2.3", m.getString ("63.2.3")); assertEquals ("CAFEBABE", new String(m.getBytes("63.2.4"))); }
private void fixup (ISOMsg m, int[] bfields) throws ISOException { for (int f : bfields) { if (m.hasField(f)) { ISOComponent c = m.getComponent(f); if (c instanceof ISOField) m.set(f, ((ISOField) c).getBytes()); } } } private XMLReader createXMLReader () throws SAXException {
public void merge (ISOMsg m) { if (m instanceof FSDISOMsg) { fsd.merge (((FSDISOMsg)m).getFSDMsg()); } else { for (int i=0; i<=m.getMaxField(); i++) { if (m.hasField(i)) fsd.set (Integer.toString(i), m.getString(i)); } } } public void setResponseMTI() {
@Test public void testRecalcBitMap5() throws Throwable { ISOMsg iSOMsg = new ISOMsg(); iSOMsg.set(100, "testISOMsgValue"); iSOMsg.recalcBitMap(); byte[] value = new byte[2]; iSOMsg.set(Integer.valueOf(100), value); iSOMsg.recalcBitMap(); assertFalse("iSOMsg.dirty", iSOMsg.dirty); assertEquals("iSOMsg.fields.size()", 2, iSOMsg.fields.size()); }
@Test public void testSet5() throws Throwable { ISOMsg iSOMsg = new ISOMsg(); iSOMsg.setFieldNumber(0); ISOMsg iSOMsg2 = new ISOMsg(); iSOMsg2.set(100, "testISOMsgValue"); int[] fields = new int[2]; ISOMsg clone = (ISOMsg) iSOMsg2.clone(fields); clone.set((ISOComponent) iSOMsg.clone()); assertEquals("clone.fields.size()", 1, clone.fields.size()); assertTrue("clone.dirty", clone.dirty); }
/** * @return current MTI * @exception ISOException on inner message or MTI not set */ public String getMTI() throws ISOException { if (isInner()) throw new ISOException ("can't getMTI on inner message"); else if (!hasField(0)) throw new ISOException ("MTI not available"); return (String) getValue(0); }
@Test public void testClone() throws Throwable { byte[] header = new byte[2]; ISOHeader header2 = new BASE1Header(header); ISOMsg iSOMsg = new ISOMsg(); iSOMsg.setHeader(header2); ISOMsg result = (ISOMsg) iSOMsg.clone(); assertEquals("result.getDirection()", 0, result.getDirection()); assertEquals("iSOMsg.fields.size()", 0, iSOMsg.fields.size()); assertSame("iSOMsg.header", header2, iSOMsg.header); }
@Test public void testFilter5() throws Throwable { MacroFilter macroFilter = new MacroFilter(); LogEvent evt = new LogEvent(); ISOChannel channel = new NACChannel(); when(m.getMaxField()).thenReturn(0); when(m.hasField(0)).thenReturn(true); when(m.getValue(0)).thenReturn("N/A in Composite"); ISOMsg result = macroFilter.filter(channel, m, evt); assertSame("result", m, result); }
/** * moves a field (renumber) * @param oldFieldNumber old field number * @param newFieldNumber new field number * @throws ISOException on error */ public void move (int oldFieldNumber, int newFieldNumber) throws ISOException { ISOComponent c = getComponent (oldFieldNumber); unset (oldFieldNumber); if (c != null) { c.setFieldNumber (newFieldNumber); set (c); } else unset (newFieldNumber); }