@Test public void testGetKeyThrowsNullPointerException() throws Throwable { QMUX qMUX = new QMUX(); ISOMsg m = new ISOMsg(); try { qMUX.getKey(m); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("Misconfigured QMUX. Please verify out queue is not null.", ex.getMessage(), "ex.getMessage()"); assertEquals(0, m.getDirection(), "m.getDirection()"); } }
public String getKey (ISOMsg m) throws ISOException { if (out == null) throw new NullPointerException ("Misconfigured QMUX. Please verify out queue is not null."); StringBuilder sb = new StringBuilder (out); sb.append ('.'); sb.append (mapMTI(m.getMTI())); if (headerIsKey && m.getHeader()!=null) { sb.append ('.'); sb.append(ISOUtil.hexString(m.getHeader())); sb.append ('.'); } boolean hasFields = false; String[] k = mtiKey.getOrDefault(m.getMTI().substring(0,2), key); for (String f : k) { String v = m.getString(f); if (v != null) { if ("11".equals(f)) { String vt = v.trim(); int l = m.getMTI().charAt(0) == '2' ? 12 : 6; if (vt.length() < l) v = ISOUtil.zeropad(vt, l); } if ("41".equals(f)) { v = ISOUtil.zeropad(v.trim(), 16); } hasFields = true; sb.append(v); } } if (!hasFields) throw new ISOException ("Key fields not found - not sending " + sb.toString()); return sb.toString(); }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public String getKey (ISOMsg m) throws ISOException { if (out == null) throw new NullPointerException ("Misconfigured QMUX. Please verify out queue is not null."); StringBuilder sb = new StringBuilder (out); sb.append ('.'); sb.append (mapMTI(m.getMTI())); if (headerIsKey && m.getHeader()!=null) { sb.append ('.'); sb.append(ISOUtil.hexString(m.getHeader())); sb.append ('.'); } boolean hasFields = false; String[] k = mtiKey.getOrDefault(m.getMTI().substring(0,2), key); for (String f : k) { String v = m.getString(f); if (v != null) { if ("11".equals(f)) { String vt = v.trim(); int l = m.getMTI().charAt(0) == '2' ? 12 : 6; if (vt.length() < l) v = ISOUtil.zeropad(vt, l); } if ("41".equals(f)) { v = ISOUtil.zeropad(v.trim(), 16); } hasFields = true; sb.append(v); } } if (!hasFields) throw new ISOException ("Key fields not found - not sending " + sb.toString()); return sb.toString(); } }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public String getKey (ISOMsg m) throws ISOException { if (out == null) throw new NullPointerException ("Misconfigured QMUX. Please verify out queue is not null."); StringBuilder sb = new StringBuilder (out); sb.append ('.'); sb.append (mapMTI(m.getMTI())); if (headerIsKey && m.getHeader()!=null) { sb.append ('.'); sb.append(ISOUtil.hexString(m.getHeader())); sb.append ('.'); } boolean hasFields = false; String[] k = mtiKey.getOrDefault(m.getMTI().substring(0,2), key); for (String f : k) { String v = m.getString(f); if (v != null) { if ("11".equals(f)) { String vt = v.trim(); int l = m.getMTI().charAt(0) == '2' ? 12 : 6; if (vt.length() < l) v = ISOUtil.zeropad(vt, l); } if ("41".equals(f)) { v = ISOUtil.zeropad(v.trim(), 16); } hasFields = true; sb.append(v); } } if (!hasFields) throw new ISOException ("Key fields not found - not sending " + sb.toString()); return sb.toString(); } QMUX(); }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public String getKey (ISOMsg m) throws ISOException { if (out == null) throw new NullPointerException ("Misconfigured QMUX. Please verify out queue is not null."); StringBuilder sb = new StringBuilder (out); sb.append ('.'); sb.append (mapMTI(m.getMTI())); if (headerIsKey && m.getHeader()!=null) { sb.append ('.'); sb.append(ISOUtil.hexString(m.getHeader())); sb.append ('.'); } boolean hasFields = false; String[] k = mtiKey.getOrDefault(m.getMTI().substring(0,2), key); for (String f : k) { String v = m.getString(f); if (v != null) { if ("11".equals(f)) { String vt = v.trim(); int l = m.getMTI().charAt(0) == '2' ? 12 : 6; if (vt.length() < l) v = ISOUtil.zeropad(vt, l); } if ("41".equals(f)) { v = ISOUtil.zeropad(v.trim(), 16); } hasFields = true; sb.append(v); } } if (!hasFields) throw new ISOException ("Key fields not found - not sending " + sb.toString()); return sb.toString(); } QMUX(); void initService(); void startService(); void stopService(); void destroyService(); static MUX getMUX(String name); ISOMsg request(ISOMsg m, long timeout); void request(ISOMsg m, long timeout, ISOResponseListener rl, Object handBack); @Override void notify(Object k, Object value); String getKey(ISOMsg m); @Override Metrics getMetrics(); synchronized void setInQueue(String in); String getInQueue(); synchronized void setOutQueue(String out); String getOutQueue(); Space getSpace(); synchronized void setUnhandledQueue(String unhandled); String getUnhandledQueue(); @SuppressWarnings("unused") String[] getReadyIndicatorNames(); void addISORequestListener(ISORequestListener l); boolean removeISORequestListener(ISORequestListener l); synchronized void resetCounters(); String getCountersAsString(); int getTXCounter(); int getRXCounter(); @Override int getTXExpired(); @Override int getTXPending(); @Override int getRXExpired(); @Override int getRXPending(); @Override int getRXUnhandled(); @Override int getRXForwarded(); long getLastTxnTimestampInMillis(); long getIdleTimeInMillis(); void send(ISOMsg m); boolean isConnected(); void dump(PrintStream p, String indent); }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public String getKey (ISOMsg m) throws ISOException { if (out == null) throw new NullPointerException ("Misconfigured QMUX. Please verify out queue is not null."); StringBuilder sb = new StringBuilder (out); sb.append ('.'); sb.append (mapMTI(m.getMTI())); if (headerIsKey && m.getHeader()!=null) { sb.append ('.'); sb.append(ISOUtil.hexString(m.getHeader())); sb.append ('.'); } boolean hasFields = false; String[] k = mtiKey.getOrDefault(m.getMTI().substring(0,2), key); for (String f : k) { String v = m.getString(f); if (v != null) { if ("11".equals(f)) { String vt = v.trim(); int l = m.getMTI().charAt(0) == '2' ? 12 : 6; if (vt.length() < l) v = ISOUtil.zeropad(vt, l); } if ("41".equals(f)) { v = ISOUtil.zeropad(v.trim(), 16); } hasFields = true; sb.append(v); } } if (!hasFields) throw new ISOException ("Key fields not found - not sending " + sb.toString()); return sb.toString(); } QMUX(); void initService(); void startService(); void stopService(); void destroyService(); static MUX getMUX(String name); ISOMsg request(ISOMsg m, long timeout); void request(ISOMsg m, long timeout, ISOResponseListener rl, Object handBack); @Override void notify(Object k, Object value); String getKey(ISOMsg m); @Override Metrics getMetrics(); synchronized void setInQueue(String in); String getInQueue(); synchronized void setOutQueue(String out); String getOutQueue(); Space getSpace(); synchronized void setUnhandledQueue(String unhandled); String getUnhandledQueue(); @SuppressWarnings("unused") String[] getReadyIndicatorNames(); void addISORequestListener(ISORequestListener l); boolean removeISORequestListener(ISORequestListener l); synchronized void resetCounters(); String getCountersAsString(); int getTXCounter(); int getRXCounter(); @Override int getTXExpired(); @Override int getTXPending(); @Override int getRXExpired(); @Override int getRXPending(); @Override int getRXUnhandled(); @Override int getRXForwarded(); long getLastTxnTimestampInMillis(); long getIdleTimeInMillis(); void send(ISOMsg m); boolean isConnected(); void dump(PrintStream p, String indent);  }