@Override public ISOMsg createMsg() { FSDMsg fsdmsg = new FSDMsg (schema); fsdmsg.setCharset(charset); return new FSDISOMsg (fsdmsg); }
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) {
@Test public void testDump() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); fSDMsg.copy("testFSDMsgFieldName", new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema")); byte[] h = new byte[3]; fSDMsg.setHeader(h); fSDMsg.dump(new PrintStream(new ByteArrayOutputStream(), true, "UTF-16"), "testFSDMsgIndent"); assertEquals("fSDMsg.fields.size()", 1, fSDMsg.fields.size()); }
@Test public void testDump3() throws Throwable { byte[] h = new byte[3]; FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); fSDMsg.setHeader(h); fSDMsg.dump(new PrintStream(new ByteArrayOutputStream(), true, "UTF-16"), "testFSDMsgIndent"); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test( expected = NullPointerException.class) public void testGetSchemaThrowsNullPointerException() throws Throwable { FSDMsg fSDMsg = new FSDMsg(null, "testFSDMsgBaseSchema"); fSDMsg.getSchema(); }
@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 testSet() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); fSDMsg.set("testFSDMsgName", null); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testConstructor1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); assertEquals("fSDMsg.basePath", "testFSDMsgBasePath", fSDMsg.basePath); assertEquals("fSDMsg.separators.size()", 6, fSDMsg.separators.size()); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); assertEquals("fSDMsg.baseSchema", "testFSDMsgBaseSchema", fSDMsg.baseSchema); }
@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 testGetHexBytes1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); byte[] result = fSDMsg.getHexBytes("testFSDMsgName"); assertNull("result", result); assertEquals("fSDMsg.fields.size()", 0, fSDMsg.fields.size()); }
@Test public void testRead2() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.read(is, 0, "2C", null); assertEquals("result", "", result); }
@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 testGetHexHeader1() throws Throwable { String result = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema").getHexHeader(); assertEquals("result", "", result); }
@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()); } }
@Test public void testHasField() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); fSDMsg.readField(null, "testString", 0, "", null); boolean result = fSDMsg.hasField("testString"); assertTrue("result", result); assertEquals("fSDMsg.fields.size()", 1, fSDMsg.fields.size()); }
@Test public void testIsSeparator1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); fSDMsg.setSeparator("testFSDMsgSeparatorName", ' '); boolean result = fSDMsg.isSeparator((byte) 32); assertTrue("result", result); }
@Test public void testPackToNoUnpadBDS() throws Throwable { Element schema = createSchema(); appendField(schema, "name", "B", "DS", 32); FSDMsg fSDMsg = new FSDMsg(SCHEMA_PREFIX); byte[] expected = "Test message ".getBytes(); fSDMsg.set("name", ISOUtil.hexString("Test message ".getBytes())); byte[] b = fSDMsg.packToBytes(); assertArrayEquals("FSDMsg.packToBytes() can't unpadding BDS fields", expected, b); }
public void testLoadMissingJarSchema() throws Exception { FSDMsg fsdm = new FSDMsg(SCHEMA_JAR_URL + "DSmsgX-"); String mac = "12345678123456781234567812345678"; String id = "01"; fsdm.set("id", id); fsdm.set("content", mac); try { fsdm.pack(); fail("FileNotFoundException expected"); } catch (FileNotFoundException ex) {} }
@Test public void testGetHexHeaderThrowsStringIndexOutOfBoundsException() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); byte[] h = new byte[0]; fSDMsg.setHeader(h); try { fSDMsg.getHexHeader(); fail("Expected StringIndexOutOfBoundsException to be thrown"); } catch (StringIndexOutOfBoundsException ex) { assertEquals("ex.getMessage()", "String index out of range: -2", ex.getMessage()); } }
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 {