@SuppressWarnings("PMD.EmptyCatchBlock") public int getInt (String name) { int i = 0; try { i = Integer.parseInt (get (name)); } catch (Exception ignored) { } return i; } @SuppressWarnings("PMD.EmptyCatchBlock")
public Object clone(int[] fields) { FSDISOMsg m = (FSDISOMsg) super.clone(); m.fsd = new FSDMsg(fsd.getBasePath(), fsd.getBaseSchema()); for (int field : fields) { String f = Integer.toString(field); m.fsd.set(f, fsd.get(f)); } return m; } public void merge (ISOMsg m) {
public byte[] getHexBytes (String name) { String s = get (name); return s == null ? null : ISOUtil.hex2byte (s); } @SuppressWarnings("PMD.EmptyCatchBlock")
@Test public void testGet3() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); fSDMsg.get("testFSDMsgId", "B", 100, "testFSDMsgDefValue", null); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet11() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.get("testFSDMsgId", "Kv", 100, null, null); assertEquals("result", "", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet12() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); String result = fSDMsg.get("testFSDMsgId", "AD", 0, "testFSDMsgDefValue", null); assertEquals("result", "", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet10() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.get("testFSDMsgId", "AD", 100, null, null); assertEquals("result", " ", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet2() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.get("testFSDMsgId", "2C", 100, null, null); assertEquals("result", "", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet6() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); String result = fSDMsg.get("testFSDMsgId", " ", 100, "testFSDMsgDefValue", null); assertEquals("result", "testFSDMsgDefValue", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGet8() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.get("testFSDMsgId", "Kv", 100, "testFSDMsgDefValue", null); assertEquals("result", "testFSDMsgDefValue", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testGetThrowsRuntimeException() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); try { fSDMsg.get("testFSDMsgId", "3Ch", 100, "testFSDMsgDefValue", "3Ch"); fail("Expected RuntimeException to be thrown"); } catch (RuntimeException ex) { assertEquals("ex.getMessage()", "Invalid separator '3Ch'", ex.getMessage()); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); } }
@Test public void testGetThrowsRuntimeException6() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); try { fSDMsg.get("testFSDMsgId", "B]Z", 100, "testFSDMsgDefValue", "B]Z"); fail("Expected RuntimeException to be thrown"); } catch (RuntimeException ex) { assertEquals("ex.getMessage()", "Invalid separator 'B]Z'", ex.getMessage()); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); } }
public void testClone () throws Exception { FSDMsg m0 = new FSDMsg(SCHEMA_DIR_URL + "msgDS-"); m0.set ("alphavardata", "ABCDE"); FSDMsg m1 = (FSDMsg) m0.clone(); m1.set ("alphavardata", "12345"); assertEquals ("Original alphavardata", "ABCDE", m0.get ("alphavardata")); assertEquals ("Cloned alphavardata", "12345", m1.get ("alphavardata")); } public void testFSDISOMsgClone () throws Exception {
@Test public void testGetThrowsNullPointerException1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); try { fSDMsg.get("testFSDMsgId", null, 100, "testFSDMsgDefValue", null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); } }
public void testFinalField() throws Exception { String value1 = " 123 "; String field1 = "testafs"; String value2 = "ABC"; String field2 = "finalfield"; imsg.set(field1, value1); imsg.set(field2, value2); assertEquals("20203132331C414243",ISOUtil.hexString(imsg.pack().getBytes())); omsg.unpack(imsg.pack().getBytes()); assertEquals(" 123", omsg.get(field1)); assertEquals(value2, omsg.get(field2)); }
public void testSeparator() throws Exception { String value = "1"; String field = "testafs"; imsg.set(field, value); assertEquals("Separator", "1'FS'", imsg.pack().replace(FS, "'FS'")); omsg.unpack(imsg.pack().getBytes()); assertEquals(value, omsg.get(field)); } }
@Test public void testGet7() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); fSDMsg.set(" is used, but ", "testFSDMsgValue"); String result = fSDMsg.get(" is used, but ", "A", 100, "testFSDMsgDefValue", null); assertEquals("result", "testFSDMsgValue ", result); assertEquals("fSDMsg.fields.size()", 1, fSDMsg.fields.size()); }
public void testFSDISOMsgClone () throws Exception { FSDMsg m0 = new FSDMsg(SCHEMA_DIR_URL + "msgDS-"); m0.set ("alphavardata", "ABCDE"); FSDISOMsg iso0 = new FSDISOMsg (m0); FSDISOMsg iso1 = (FSDISOMsg) iso0.clone(); FSDMsg m1 = iso1.getFSDMsg(); m1.set ("alphavardata", "12345"); assertEquals ("Original alphavardata", "ABCDE", m0.get ("alphavardata")); assertEquals ("Cloned alphavardata", "12345", m1.get ("alphavardata")); } public void testFSDISOMsgPartialCloneAndMerge () throws Exception {
@Test public void testGetThrowsISOException1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); try { fSDMsg.get("testFSDMsgId", "NB", 0, "testFSDMsgDefValue", null); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("ex.getMessage()", "invalid len 18/0", ex.getMessage()); assertNull("ex.getNested()", ex.getNested()); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); } }