diff options
author | 2018-09-07 12:21:34 -0500 | |
---|---|---|
committer | 2018-09-07 12:22:50 -0500 | |
commit | 4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch) | |
tree | a36d03227b63a3e60346d6c3ca87b061087dae85 /misc/rosetta/src/test | |
parent | 824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff) |
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473
Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'misc/rosetta/src/test')
14 files changed, 1240 insertions, 1240 deletions
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java index 121deea0..3e12f594 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java @@ -44,225 +44,225 @@ import s.xsd.LargerData; import s.xsd.SampleData; public class JU_FromJSON { - private static int ITERATIONS = 10000; - static String str = "{\"SampleData\":[" + - "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + - "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}"; - InJson inJSON = new InJson(); + private static int ITERATIONS = 10000; + static String str = "{\"SampleData\":[" + + "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + + "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}"; + InJson inJSON = new InJson(); - @Test - public void rawParse() throws Exception { - System.out.println("*** PARSE JSON -> RAW Dump ***"); - System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(); - new OutRaw().extract(new StringReader(str),sbw,inJSON); - System.out.println(sbw.getBuffer()); - } - - @Test - public void parseJSON2Dump() throws Exception { - System.out.println("*** PARSE JSON -> Dump ***"); - System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - new OutDump().extract(new StringReader(str), sbw, inJSON); - - System.out.println(sbw.getBuffer()); - } - - @Test - public void nonprettyJSON() throws Exception { - System.out.println("*** JSON -> (Intermediate Stream) -> Non-pretty JSON ***"); - System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(1024); + @Test + public void rawParse() throws Exception { + System.out.println("*** PARSE JSON -> RAW Dump ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(); + new OutRaw().extract(new StringReader(str),sbw,inJSON); + System.out.println(sbw.getBuffer()); + } + + @Test + public void parseJSON2Dump() throws Exception { + System.out.println("*** PARSE JSON -> Dump ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + new OutDump().extract(new StringReader(str), sbw, inJSON); + + System.out.println(sbw.getBuffer()); + } + + @Test + public void nonprettyJSON() throws Exception { + System.out.println("*** JSON -> (Intermediate Stream) -> Non-pretty JSON ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(1024); - Out jout = new OutJson(); - Trans trans; - Report report = new Report(ITERATIONS,"JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(str); - TimeTaken tt = trans.start("Parse JSON", Env.JSON); - try { - jout.extract(sr, sbw, inJSON); - } finally { - tt.done(); - } - report.glean(trans,Env.JSON); - } while(report.go()); - - String result = sbw.toString(); - System.out.println(result); - Assert.assertEquals(result, str); - report.report(sbw); - System.out.println(sbw.toString()); - } - - @Test - public void parseJSON2JSON() throws Exception { - System.out.println("*** JSON -> (Intermediate Stream) -> Pretty JSON ***"); - System.out.println(str); + Out jout = new OutJson(); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + jout.extract(sr, sbw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + String result = sbw.toString(); + System.out.println(result); + Assert.assertEquals(result, str); + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void parseJSON2JSON() throws Exception { + System.out.println("*** JSON -> (Intermediate Stream) -> Pretty JSON ***"); + System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Out jout = new OutJson(); - Trans trans; - Report report = new Report(ITERATIONS,"JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(str); - TimeTaken tt = trans.start("Parse JSON", Env.JSON); - try { - jout.extract(sr, sbw, inJSON,true); - } finally { - tt.done(); - } - report.glean(trans,Env.JSON); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Out jout = new OutJson(); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + jout.extract(sr, sbw, inJSON,true); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } - @Test - public void parseJSON2XML() throws Exception { - System.out.println("*** PARSE JSON -> XML ***"); - System.out.println(str); + @Test + public void parseJSON2XML() throws Exception { + System.out.println("*** PARSE JSON -> XML ***"); + System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); - Trans trans; - Report report = new Report(ITERATIONS,"JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(str); - TimeTaken tt = trans.start("Parse JSON", Env.JSON); - try { - xout.extract(sr, sbw, inJSON); - } finally { - tt.done(); - } - report.glean(trans,Env.JSON); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + xout.extract(sr, sbw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } - @Test - public void parseJSON2PrettyXML() throws Exception { - System.out.println("*** PARSE JSON -> Pretty XML ***"); - System.out.println(str); + @Test + public void parseJSON2PrettyXML() throws Exception { + System.out.println("*** PARSE JSON -> Pretty XML ***"); + System.out.println(str); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - IndentPrintWriter ipw = new IndentPrintWriter(sbw); - - Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); - Trans trans; - Report report = new Report(ITERATIONS,"JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(str); - TimeTaken tt = trans.start("Parse JSON", Env.JSON); - try { - xout.extract(sr, ipw, inJSON); - } finally { - tt.done(); - } - report.glean(trans,Env.JSON); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } - - - @Test - public void jaxbObj2XML() throws Exception { - System.out.println("*** JAXB Object -> XML ***"); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + IndentPrintWriter ipw = new IndentPrintWriter(sbw); + + Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + xout.extract(sr, ipw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + + @Test + public void jaxbObj2XML() throws Exception { + System.out.println("*** JAXB Object -> XML ***"); - LargerData ld = new LargerData(); - SampleData sd = new SampleData(); - sd.setDate(System.currentTimeMillis()); - sd.setId("sd object \"1\""); - sd.getItem().add("Item 1.1"); - sd.getItem().add("Item 1.2"); - ld.getSampleData().add(sd); - sd = new SampleData(); - sd.setDate(System.currentTimeMillis()); - sd.setId("sd object \"2\""); - sd.getItem().add("Item 2.1"); - sd.getItem().add("Item 2.2"); - ld.getSampleData().add(sd); - ld.setFluff("MyFluff"); - - JAXBmar jaxBmar = new JAXBmar(LargerData.class); - //jaxBmar.asFragment(true); - //jaxBmar.pretty(true); - StringBuilderWriter sbw = new StringBuilderWriter(1024); + LargerData ld = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"1\""); + sd.getItem().add("Item 1.1"); + sd.getItem().add("Item 1.2"); + ld.getSampleData().add(sd); + sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"2\""); + sd.getItem().add("Item 2.1"); + sd.getItem().add("Item 2.2"); + ld.getSampleData().add(sd); + ld.setFluff("MyFluff"); + + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - TimeTaken tt = trans.start("JAXB", Env.XML); - try { - jaxBmar.marshal(LogTarget.NULL, ld, sbw); - } finally { - tt.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken tt = trans.start("JAXB", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } - @Test - public void jaxbObj2PrettyXML() throws Exception { - System.out.println("*** JAXB Object -> Pretty XML ***"); + @Test + public void jaxbObj2PrettyXML() throws Exception { + System.out.println("*** JAXB Object -> Pretty XML ***"); - LargerData ld = new LargerData(); - SampleData sd = new SampleData(); - sd.setDate(System.currentTimeMillis()); - sd.setId("sd object \"1\""); - sd.getItem().add("Item 1.1"); - sd.getItem().add("Item 1.2"); - ld.getSampleData().add(sd); - sd = new SampleData(); - sd.setDate(System.currentTimeMillis()); - sd.setId("sd object \"2\""); - sd.getItem().add("Item 2.1"); - sd.getItem().add("Item 2.2"); - ld.getSampleData().add(sd); - ld.setFluff("MyFluff"); - - JAXBmar jaxBmar = new JAXBmar(LargerData.class); - //jaxBmar.asFragment(true); - jaxBmar.pretty(true); - StringBuilderWriter sbw = new StringBuilderWriter(1024); + LargerData ld = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"1\""); + sd.getItem().add("Item 1.1"); + sd.getItem().add("Item 1.2"); + ld.getSampleData().add(sd); + sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"2\""); + sd.getItem().add("Item 2.1"); + sd.getItem().add("Item 2.2"); + ld.getSampleData().add(sd); + ld.setFluff("MyFluff"); + + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - TimeTaken tt = trans.start("JAXB", Env.XML); - try { - jaxBmar.marshal(LogTarget.NULL, ld, sbw); - } finally { - tt.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken tt = trans.start("JAXB", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); - report.report(sbw); - System.out.println(sbw.toString()); - } + report.report(sbw); + System.out.println(sbw.toString()); + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java index 58813621..2a4e3d2d 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java @@ -43,217 +43,217 @@ import org.onap.aaf.misc.rosetta.OutXML; import s.xsd.LargerData; public class JU_FromXML { - private static int ITERATIONS = 1; - ; - - private final static String xml = - "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + - "<LargerData xmlns=\"urn:s:xsd\">\n" + - " <SampleData>\n" + - " <id>sd object 1</id>\n" + - " <date>1346765355134</date>\n" + - " <item>Item 1.1</item>\n" + - " <item>Item 1.2</item>\n" + - " </SampleData>\n" + - " <SampleData>\n" + - " <id>sd object 2</id>\n" + - " <date>1346765355134</date>\n" + - " <item>Item 2.1</item>\n" + - " <item>Item 2.2</item>\n" + - " </SampleData>\n" + - " <fluff>MyFluff</fluff>\n" + - "</LargerData>\n"; - - - @Test - public void test() throws Exception { - InXML inXML = new InXML(LargerData.class); - - System.out.println(xml); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Reader rdr = new StringReader(xml); - - new OutRaw().extract(rdr, sbw, inXML); - System.out.println(sbw.getBuffer()); - } - + private static int ITERATIONS = 1; + ; + + private final static String xml = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + + "<LargerData xmlns=\"urn:s:xsd\">\n" + + " <SampleData>\n" + + " <id>sd object 1</id>\n" + + " <date>1346765355134</date>\n" + + " <item>Item 1.1</item>\n" + + " <item>Item 1.2</item>\n" + + " </SampleData>\n" + + " <SampleData>\n" + + " <id>sd object 2</id>\n" + + " <date>1346765355134</date>\n" + + " <item>Item 2.1</item>\n" + + " <item>Item 2.2</item>\n" + + " </SampleData>\n" + + " <fluff>MyFluff</fluff>\n" + + "</LargerData>\n"; + + + @Test + public void test() throws Exception { + InXML inXML = new InXML(LargerData.class); + + System.out.println(xml); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Reader rdr = new StringReader(xml); + + new OutRaw().extract(rdr, sbw, inXML); + System.out.println(sbw.getBuffer()); + } + - @Test - public void xml2JSON() throws Exception { - System.out.println("*** XML -> JSON (No Warm up) ***"); - Out jout = new OutJson(); - InXML inXML = new InXML(LargerData.class); + @Test + public void xml2JSON() throws Exception { + System.out.println("*** XML -> JSON (No Warm up) ***"); + Out jout = new OutJson(); + InXML inXML = new InXML(LargerData.class); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(xml); - TimeTaken tt = trans.start("Parse XML", Env.XML); - try { - jout.extract(sr, sbw, inXML); - } finally { - tt.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(xml); + TimeTaken tt = trans.start("Parse XML", Env.XML); + try { + jout.extract(sr, sbw, inXML); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } - @Test - public void xml2XML() throws Exception { - System.out.println("*** XML -> (Event Queue) -> XML (No Warm up) ***"); - Out xout = new OutXML("LargerData"); - InXML inXML = new InXML(LargerData.class); + @Test + public void xml2XML() throws Exception { + System.out.println("*** XML -> (Event Queue) -> XML (No Warm up) ***"); + Out xout = new OutXML("LargerData"); + InXML inXML = new InXML(LargerData.class); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(xml); - TimeTaken tt = trans.start("Parse XML", Env.XML); - try { - xout.extract(sr, sbw, inXML); - } finally { - tt.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } - - - @Test - public void warmup() throws Exception { - if(ITERATIONS>20) { - System.out.println("*** Warmup JAXB ***"); - - JAXBumar jaxbUmar = new JAXBumar(LargerData.class); - JAXBmar jaxBmar = new JAXBmar(LargerData.class); - //jaxBmar.asFragment(true); - //jaxBmar.pretty(true); - StringBuilderWriter sbw = new StringBuilderWriter(1024); - + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(xml); + TimeTaken tt = trans.start("Parse XML", Env.XML); + try { + xout.extract(sr, sbw, inXML); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + + @Test + public void warmup() throws Exception { + if(ITERATIONS>20) { + System.out.println("*** Warmup JAXB ***"); + + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + - LargerData ld; - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - TimeTaken all = trans.start("Combo", Env.SUB); - try { - TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); - try { - ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); - } finally { - tt.done(); - } - tt = trans.start("JAXB marshal", Env.XML); - try { - jaxBmar.marshal(LogTarget.NULL, ld, sbw); - } finally { - tt.done(); - } - } finally { - all.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); - } - } - @Test - public void xml2jaxb2xml() throws Exception { - System.out.println("*** XML -> JAXB Object -> XML ***"); - JAXBumar jaxbUmar = new JAXBumar(LargerData.class); - JAXBmar jaxBmar = new JAXBmar(LargerData.class); - //jaxBmar.asFragment(true); - //jaxBmar.pretty(true); - StringBuilderWriter sbw = new StringBuilderWriter(1024); + LargerData ld; + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + } + @Test + public void xml2jaxb2xml() throws Exception { + System.out.println("*** XML -> JAXB Object -> XML ***"); + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); - LargerData ld; - Trans trans; - Report report = new Report(ITERATIONS,"XML"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - TimeTaken all = trans.start("Combo", Env.SUB); - try { - TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); - try { - ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); - } finally { - tt.done(); - } - tt = trans.start("JAXB marshal", Env.XML); - try { - jaxBmar.marshal(LogTarget.NULL, ld, sbw); - } finally { - tt.done(); - } - } finally { - all.done(); - } - report.glean(trans,Env.XML); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); } + LargerData ld; + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); } - @Test - public void xml2jaxb2PrettyXml() throws Exception { - System.out.println("*** XML -> JAXB Object -> Pretty XML ***"); - JAXBumar jaxbUmar = new JAXBumar(LargerData.class); - JAXBmar jaxBmar = new JAXBmar(LargerData.class); - //jaxBmar.asFragment(true); - jaxBmar.pretty(true); - StringBuilderWriter sbw = new StringBuilderWriter(1024); + @Test + public void xml2jaxb2PrettyXml() throws Exception { + System.out.println("*** XML -> JAXB Object -> Pretty XML ***"); + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); - Trans trans = EnvFactory.newTrans(); - LargerData ld; - for(int i=0;i<ITERATIONS;++i) { - sbw.reset(); - TimeTaken all = trans.start("Combo", Env.SUB); - try { - TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); - try { - ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); - } finally { - tt.done(); - } - tt = trans.start("JAXB marshal", Env.XML); - try { - jaxBmar.marshal(LogTarget.NULL, ld, sbw); - } finally { - tt.done(); - } - } finally { - all.done(); - } - } - sbw.append('\n'); - Metric m; - if(ITERATIONS>20) { - m = trans.auditTrail(0,null); - } else { - m = trans.auditTrail(0, sbw.getBuffer()); - System.out.println(sbw.getBuffer()); - } - System.out.println(ITERATIONS + " entries, Total Time: " + m.total + "ms, Avg Time: " + m.total/ITERATIONS + "ms"); - } + Trans trans = EnvFactory.newTrans(); + LargerData ld; + for(int i=0;i<ITERATIONS;++i) { + sbw.reset(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + } + sbw.append('\n'); + Metric m; + if(ITERATIONS>20) { + m = trans.auditTrail(0,null); + } else { + m = trans.auditTrail(0, sbw.getBuffer()); + System.out.println(sbw.getBuffer()); + } + System.out.println(ITERATIONS + " entries, Total Time: " + m.total + "ms, Avg Time: " + m.total/ITERATIONS + "ms"); + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java index 080fc973..9ab06e7c 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java @@ -38,99 +38,99 @@ import org.onap.aaf.misc.rosetta.ParseException; public class JU_JSON { - @Test - public void test() throws IOException, ParseException { - InJson jin = new InJson(); - Out jout = new OutJson(); - - go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); - - go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\"],\"utc\":1360418381310}"); - go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\",\"My Comment 2\"],\"utc\":1360418381310}"); - - go(jin, jout, "{\"SampleData\":[" + - "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + - "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}" - ); - - go(jin, jout, "{\"SampleData\":[{\"date\":1316084945343}],\"fluff\":\"MyFluff\"}"); - - go(jin, jout, "{\"id\":\"Me,[}[eg[)(:x,\\\" Myself\",\"date\":1353094689100}"); - - // TODO: Clean out AT&T specific data - go(jin,jout, "{\"userid\":\"xk3233\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}"); - //go() - //"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><vote xmlns=\"urn:poll.att.com\"><userid>xk3233</userid><timestamp>1353082669667</timestamp></vote>"); - - // 3/11/2015 Jonathan found a case with missing comma - go(jin,jout, "{\"start\":\"2015-03-11T18:18:05.580-05:00\",\"end\":\"2015-09-11-05:00\",\"force\":\"false\",\"perm\":{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}" - + ",\"role\":\"org.osaaf.myns.myrole\"}"); - - // 3/12/2015 Jonathan Kurt Schurenberg noticed an issue of object names in an array. This is valid code. - go(jin,jout, "{\"role\":[{\"name\":\"org.osaaf.myns.myrole\",\"perms\":[{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myOtherAction\"}]}" - + ",{\"name\":\"org.osaaf.myns.myOtherRole\",\"perms\":[{\"type\":\"org.osaaf.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.myOthertype\",\"instance\":\"myOtherAction\"}]}]}"); - - // 3/13/2015 - discovered with complex Response - go(jin,jout, "{\"meth\":\"GET\",\"path\":\"/authz/perms/:type\",\"desc\":\"GetPermsByType\",\"comments\":[\"List All Permissions that match :type listed\"]," - + "\"contentType\":[\"application/Permissions+json;q=1.0;charset=utf-8;version=1.1,application/json;q=1.0;version=1.1\"" - + ",\"application/Perms+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0\",\"application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0\"" - + ",\"application/Permissions+xml;q=1.0;charset=utf-8;version=1.1,text/xml;q=1.0;version=1.1\"]}"); - - - // Test a Windoze "Pretty Print", validate skipping of Windoze characters as well as other odd control characters listed - // in json.org - StringWriter sw = new StringWriter(); - jout.extract(new StringReader( - "{\b\f\n\r\t \"id\"" - + ":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100" - + "\b\f\n\r\t }" - ),sw,jin); - Assert.assertEquals("{\"id\":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100}",sw.toString()); - System.out.println(sw.toString()); - - // 10/01/2015 Jonathan AAF-703 Ron Gallagher, this response is ok - go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}"); - // but when description:"" causes extra comma at end - go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\"}]}"); - // Test other empty string scenarios - go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"\"}]}","{\"perm\":[{}]}"); - go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"hi\"}]}","{\"perm\":[{\"description\":\"hi\"}]}"); - go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"action\":\"myAction\"}]}"); - - - go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"description\":\"something\"}]}"); - - go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}"); - - go(jin, jout, "{\"name\":\"\\\\\"}"); - - go(jin, jout, "{\"role\":\"org.osaaf.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"org.osaaf.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}"); - - - } - - - private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { - go(in,out,str,str); - } - - - private void go(Parse<Reader, ?> in, Out out, String str, String cmp) throws IOException, ParseException { - - System.out.println(str); - StringWriter sw = new StringWriter(1024); - out.extract(new StringReader(str), sw, in); - System.out.println(sw); - String result = sw.toString(); - - if(!result.equals(cmp)) { - sw.getBuffer().setLength(0); - new OutRaw().extract(new StringReader(str), sw, in); - System.out.println(sw); - } - - Assert.assertEquals(cmp,result); - System.out.println(); - - } + @Test + public void test() throws IOException, ParseException { + InJson jin = new InJson(); + Out jout = new OutJson(); + + go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); + + go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\"],\"utc\":1360418381310}"); + go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\",\"My Comment 2\"],\"utc\":1360418381310}"); + + go(jin, jout, "{\"SampleData\":[" + + "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + + "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}" + ); + + go(jin, jout, "{\"SampleData\":[{\"date\":1316084945343}],\"fluff\":\"MyFluff\"}"); + + go(jin, jout, "{\"id\":\"Me,[}[eg[)(:x,\\\" Myself\",\"date\":1353094689100}"); + + // TODO: Clean out AT&T specific data + go(jin,jout, "{\"userid\":\"xk3233\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}"); + //go() + //"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><vote xmlns=\"urn:poll.att.com\"><userid>xk3233</userid><timestamp>1353082669667</timestamp></vote>"); + + // 3/11/2015 Jonathan found a case with missing comma + go(jin,jout, "{\"start\":\"2015-03-11T18:18:05.580-05:00\",\"end\":\"2015-09-11-05:00\",\"force\":\"false\",\"perm\":{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}" + + ",\"role\":\"org.osaaf.myns.myrole\"}"); + + // 3/12/2015 Jonathan Kurt Schurenberg noticed an issue of object names in an array. This is valid code. + go(jin,jout, "{\"role\":[{\"name\":\"org.osaaf.myns.myrole\",\"perms\":[{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myOtherAction\"}]}" + + ",{\"name\":\"org.osaaf.myns.myOtherRole\",\"perms\":[{\"type\":\"org.osaaf.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.myOthertype\",\"instance\":\"myOtherAction\"}]}]}"); + + // 3/13/2015 - discovered with complex Response + go(jin,jout, "{\"meth\":\"GET\",\"path\":\"/authz/perms/:type\",\"desc\":\"GetPermsByType\",\"comments\":[\"List All Permissions that match :type listed\"]," + + "\"contentType\":[\"application/Permissions+json;q=1.0;charset=utf-8;version=1.1,application/json;q=1.0;version=1.1\"" + + ",\"application/Perms+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0\",\"application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0\"" + + ",\"application/Permissions+xml;q=1.0;charset=utf-8;version=1.1,text/xml;q=1.0;version=1.1\"]}"); + + + // Test a Windoze "Pretty Print", validate skipping of Windoze characters as well as other odd control characters listed + // in json.org + StringWriter sw = new StringWriter(); + jout.extract(new StringReader( + "{\b\f\n\r\t \"id\"" + + ":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100" + + "\b\f\n\r\t }" + ),sw,jin); + Assert.assertEquals("{\"id\":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100}",sw.toString()); + System.out.println(sw.toString()); + + // 10/01/2015 Jonathan AAF-703 Ron Gallagher, this response is ok + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}"); + // but when description:"" causes extra comma at end + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\"}]}"); + // Test other empty string scenarios + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"\"}]}","{\"perm\":[{}]}"); + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"hi\"}]}","{\"perm\":[{\"description\":\"hi\"}]}"); + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"action\":\"myAction\"}]}"); + + + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"description\":\"something\"}]}"); + + go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}"); + + go(jin, jout, "{\"name\":\"\\\\\"}"); + + go(jin, jout, "{\"role\":\"org.osaaf.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"org.osaaf.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}"); + + + } + + + private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { + go(in,out,str,str); + } + + + private void go(Parse<Reader, ?> in, Out out, String str, String cmp) throws IOException, ParseException { + + System.out.println(str); + StringWriter sw = new StringWriter(1024); + out.extract(new StringReader(str), sw, in); + System.out.println(sw); + String result = sw.toString(); + + if(!result.equals(cmp)) { + sw.getBuffer().setLength(0); + new OutRaw().extract(new StringReader(str), sw, in); + System.out.println(sw); + } + + Assert.assertEquals(cmp,result); + System.out.println(); + + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java index f72b6e69..229f1bf4 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java @@ -28,49 +28,49 @@ import static org.junit.Assert.*; public class JU_Ladder { - @Test - public void test() { - Ladder<String> ladder = new Ladder<String>(); - - for(int i=0;i<30;++i) { - for(int j=0;j<i;++j)ladder.ascend(); - String str = "Rung " + i; - assertEquals(ladder.peek(),null); - ladder.push(str); - assertEquals(str,ladder.peek()); - assertEquals(str,ladder.pop()); - assertEquals(null,ladder.peek()); - for(int j=0;j<i;++j)ladder.descend(); - } - assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8 - - ladder.cutTo(8); - assertEquals(ladder.height(),8); - - for(int i=0;i<30;++i) { - ladder.jumpTo(i); - String str = "Rung " + i; - assertEquals(ladder.peek(),null); - ladder.push(str); - assertEquals(ladder.peek(),str); - } + @Test + public void test() { + Ladder<String> ladder = new Ladder<String>(); + + for(int i=0;i<30;++i) { + for(int j=0;j<i;++j)ladder.ascend(); + String str = "Rung " + i; + assertEquals(ladder.peek(),null); + ladder.push(str); + assertEquals(str,ladder.peek()); + assertEquals(str,ladder.pop()); + assertEquals(null,ladder.peek()); + for(int j=0;j<i;++j)ladder.descend(); + } + assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8 + + ladder.cutTo(8); + assertEquals(ladder.height(),8); + + for(int i=0;i<30;++i) { + ladder.jumpTo(i); + String str = "Rung " + i; + assertEquals(ladder.peek(),null); + ladder.push(str); + assertEquals(ladder.peek(),str); + } - ladder.bottom(); - - for(int i=0;i<30;++i) { - assertEquals("Rung " + i,ladder.peek()); - ladder.ascend(); - } - - ladder.bottom(); - ladder.top(); - assertEquals("Rung 29",ladder.peek()); - - for(int i=0;i<30;++i) { - ladder.jumpTo(i); - assertEquals("Rung " + i,ladder.peek()); - } + ladder.bottom(); + + for(int i=0;i<30;++i) { + assertEquals("Rung " + i,ladder.peek()); + ladder.ascend(); + } + + ladder.bottom(); + ladder.top(); + assertEquals("Rung 29",ladder.peek()); + + for(int i=0;i<30;++i) { + ladder.jumpTo(i); + assertEquals("Rung " + i,ladder.peek()); + } - } + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java index cff5b43a..a1e94c51 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java @@ -35,36 +35,36 @@ import s.xsd.SampleData; public class JU_Nulls { - @AfterClass - public static void tearDownAfterClass() throws Exception { - } + @AfterClass + public static void tearDownAfterClass() throws Exception { + } - @Test - public void test() { - RosettaEnv env = new RosettaEnv(); - try { - RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); - df.out(Data.TYPE.JSON); - LargerData urr = new LargerData(); - SampleData sd = new SampleData(); - sd.setDate(1444125487798L); - sd.setId(null); - urr.getSampleData().add(sd); - urr.setFluff(null); - RosettaData<LargerData> data = df.newData(); -// StringWriter sw = new StringWriter(); -// df.direct(trans, urr, sw); -// System.out.println(sw.toString()); - data.load(urr); - System.out.println(data.asString()); - Assert.assertEquals("{\"SampleData\":[{\"date\":1444125487798}]}", data.asString()); - - System.out.println(data.out(Data.TYPE.RAW).asString()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } + @Test + public void test() { + RosettaEnv env = new RosettaEnv(); + try { + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + df.out(Data.TYPE.JSON); + LargerData urr = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(1444125487798L); + sd.setId(null); + urr.getSampleData().add(sd); + urr.setFluff(null); + RosettaData<LargerData> data = df.newData(); +// StringWriter sw = new StringWriter(); +// df.direct(trans, urr, sw); +// System.out.println(sw.toString()); + data.load(urr); + System.out.println(data.asString()); + Assert.assertEquals("{\"SampleData\":[{\"date\":1444125487798}]}", data.asString()); + + System.out.println(data.out(Data.TYPE.RAW).asString()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java index 07c73196..1a5f86f3 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java @@ -41,122 +41,122 @@ import s.xsd.Multi; import s.xsd.SampleData; public class JU_RosettaDF { - public static int ITERATIONS = 1; - - @Test - public void testCached() throws Exception { - RosettaEnv env = new RosettaEnv(); - RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); - JAXBmar jmar = new JAXBmar(LargerData.class); - - StringBuilderWriter sbw = new StringBuilderWriter(1024); - Trans trans = EnvFactory.newTrans(); - - Report report = new Report(ITERATIONS,"Load JSON","Extract JAXB", "JAXB Marshal", "Cached to XML", "Cached to JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Data<LargerData> data; - TimeTaken tt = trans.start("Load JSON", 1); - try { - data = df.newData(trans).out(Data.TYPE.JSON).in(Data.TYPE.JSON).load(JU_FromJSON.str); - } finally { - tt.done(); - } - LargerData ld; - tt = trans.start("Extract JAXB", 2); - try { - ld = data.asObject(); - } finally { - tt.done(); - } - - tt = trans.start("JAXB marshal", 3); - try { - jmar.marshal(trans.debug(), ld, sbw); - } finally { - tt.done(); - } - sbw.append('\n'); - - tt = trans.start("To XML from Cache",4); - try { - data.out(Data.TYPE.XML).to(sbw); - } finally { - tt.done(); - } - - sbw.append('\n'); - - tt = trans.start("To JSON from Cache",5); - try { - data.out(Data.TYPE.JSON).to(sbw); - } finally { - tt.done(); - } - report.glean(trans, 1,2,3,4,5); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw); - - } - - @Test - public void testDirect() throws Exception { - RosettaEnv env = new RosettaEnv(); - RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); - - StringBuilderWriter sbw = new StringBuilderWriter(1024); - Trans trans = EnvFactory.newTrans(); - - Report report = new Report(ITERATIONS); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - RosettaData<?> data = df.newData(trans).in(Data.TYPE.JSON).out(Data.TYPE.XML); - data.direct(new StringReader(JU_FromJSON.str), sbw); - report.glean(trans); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw); - - } - - @Test - public void testMulti() throws Exception { - RosettaEnv env = new RosettaEnv(); - RosettaDF<Multi> df = env.newDataFactory(Multi.class); - -// StringBuilderWriter sbw = new StringBuilderWriter(1024); -// Trans trans = EnvFactory.newTrans(); - - Multi m = new Multi(); - m.getF1().add("String1"); - m.getF2().add("String2"); - - System.out.println(df.newData().load(m).out(TYPE.RAW).asString()); - System.out.println(df.newData().load(m).out(TYPE.JSON).asString()); - - } - - @Test - public void testQuotes() throws Exception { - RosettaEnv env = new RosettaEnv(); - RosettaDF<SampleData> df = env.newDataFactory(SampleData.class); - - SampleData sd = new SampleData(); - sd.setId("\"AT&T Services, Inc.\""); - System.out.println(sd.getId()); - String out =df.newData().load(sd).out(TYPE.JSON).asString(); - System.out.println(out); - Assert.assertEquals( - "{\"id\":\"\\\"AT&T Services, Inc.\\\"\",\"date\":0}", - out); - - SampleData sd2 = df.newData().in(TYPE.JSON).load(out).asObject(); - System.out.println(sd2.getId()); - Assert.assertEquals(sd.getId(),sd2.getId()); - } + public static int ITERATIONS = 1; + + @Test + public void testCached() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + JAXBmar jmar = new JAXBmar(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + Trans trans = EnvFactory.newTrans(); + + Report report = new Report(ITERATIONS,"Load JSON","Extract JAXB", "JAXB Marshal", "Cached to XML", "Cached to JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Data<LargerData> data; + TimeTaken tt = trans.start("Load JSON", 1); + try { + data = df.newData(trans).out(Data.TYPE.JSON).in(Data.TYPE.JSON).load(JU_FromJSON.str); + } finally { + tt.done(); + } + LargerData ld; + tt = trans.start("Extract JAXB", 2); + try { + ld = data.asObject(); + } finally { + tt.done(); + } + + tt = trans.start("JAXB marshal", 3); + try { + jmar.marshal(trans.debug(), ld, sbw); + } finally { + tt.done(); + } + sbw.append('\n'); + + tt = trans.start("To XML from Cache",4); + try { + data.out(Data.TYPE.XML).to(sbw); + } finally { + tt.done(); + } + + sbw.append('\n'); + + tt = trans.start("To JSON from Cache",5); + try { + data.out(Data.TYPE.JSON).to(sbw); + } finally { + tt.done(); + } + report.glean(trans, 1,2,3,4,5); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw); + + } + + @Test + public void testDirect() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + Trans trans = EnvFactory.newTrans(); + + Report report = new Report(ITERATIONS); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + RosettaData<?> data = df.newData(trans).in(Data.TYPE.JSON).out(Data.TYPE.XML); + data.direct(new StringReader(JU_FromJSON.str), sbw); + report.glean(trans); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw); + + } + + @Test + public void testMulti() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<Multi> df = env.newDataFactory(Multi.class); + +// StringBuilderWriter sbw = new StringBuilderWriter(1024); +// Trans trans = EnvFactory.newTrans(); + + Multi m = new Multi(); + m.getF1().add("String1"); + m.getF2().add("String2"); + + System.out.println(df.newData().load(m).out(TYPE.RAW).asString()); + System.out.println(df.newData().load(m).out(TYPE.JSON).asString()); + + } + + @Test + public void testQuotes() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<SampleData> df = env.newDataFactory(SampleData.class); + + SampleData sd = new SampleData(); + sd.setId("\"AT&T Services, Inc.\""); + System.out.println(sd.getId()); + String out =df.newData().load(sd).out(TYPE.JSON).asString(); + System.out.println(out); + Assert.assertEquals( + "{\"id\":\"\\\"AT&T Services, Inc.\\\"\",\"date\":0}", + out); + + SampleData sd2 = df.newData().in(TYPE.JSON).load(out).asObject(); + System.out.println(sd2.getId()); + Assert.assertEquals(sd.getId(),sd2.getId()); + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java index 47953007..de1b5500 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java @@ -38,67 +38,67 @@ import org.onap.aaf.misc.rosetta.Saved; import s.xsd.LargerData; public class JU_Saved<b> { - private static int ITERATIONS = 100000; + private static int ITERATIONS = 100000; - @Test - public void test() throws Exception { - InJson inJSON = new InJson(); - OutDump dump = new OutDump(); - JaxInfo ji = JaxInfo.build(LargerData.class); - OutXML xml = new OutXML(ji);; - OutJson json = new OutJson(); - - Saved saved = new Saved(); - - StringBuilderWriter sbw = new StringBuilderWriter(1024); - - Trans trans; - Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON"); - do { - sbw.reset(); - trans = EnvFactory.newTrans(); - Reader sr = new StringReader(JU_FromJSON.str); - TimeTaken tt = trans.start("Parse Text, and Save", 1); - try { - saved.load(sr, inJSON); - } finally { - tt.done(); - } + @Test + public void test() throws Exception { + InJson inJSON = new InJson(); + OutDump dump = new OutDump(); + JaxInfo ji = JaxInfo.build(LargerData.class); + OutXML xml = new OutXML(ji);; + OutJson json = new OutJson(); + + Saved saved = new Saved(); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(JU_FromJSON.str); + TimeTaken tt = trans.start("Parse Text, and Save", 1); + try { + saved.load(sr, inJSON); + } finally { + tt.done(); + } -// sbw.append("==== Start Direct Raw =====\n"); -// new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON); -// -// sbw.append("==== Start Raw from Saved =====\n"); -// new OutRaw().extract(null,sbw,saved); +// sbw.append("==== Start Direct Raw =====\n"); +// new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON); +// +// sbw.append("==== Start Raw from Saved =====\n"); +// new OutRaw().extract(null,sbw,saved); - sbw.append("==== Start Dump from Saved =====\n"); - tt = trans.start("Dump", 2); - try { - dump.extract(null,sbw,saved); - } finally { - tt.done(); - } - - sbw.append("\n==== Start XML =====\n"); - tt = trans.start("XML", 3); - try { - xml.extract(null,sbw,saved); - } finally { - tt.done(); - } - - sbw.append("\n==== Start JSON =====\n"); - tt = trans.start("JSON", 4); - try { - json.extract(null,sbw,saved); - } finally { - tt.done(); - } - report.glean(trans,1,2,3,4); - } while(report.go()); - - report.report(sbw); - System.out.println(sbw.toString()); + sbw.append("==== Start Dump from Saved =====\n"); + tt = trans.start("Dump", 2); + try { + dump.extract(null,sbw,saved); + } finally { + tt.done(); + } + + sbw.append("\n==== Start XML =====\n"); + tt = trans.start("XML", 3); + try { + xml.extract(null,sbw,saved); + } finally { + tt.done(); + } + + sbw.append("\n==== Start JSON =====\n"); + tt = trans.start("JSON", 4); + try { + json.extract(null,sbw,saved); + } finally { + tt.done(); + } + report.glean(trans,1,2,3,4); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); - } + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java index 6047c03c..b0fc29a2 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java @@ -46,78 +46,78 @@ import org.onap.aaf.misc.rosetta.ParseException; public class JU_Stream2Obj { - /* - <?xml version="1.0" encoding=Config.UTF-8 standalone="yes"?> - <root xmlns="urn:inherit"> - <base xsi:type="derivedA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <name>myDerivedA_1</name> - <num>1432</num> - <shortName>mda_1</shortName> - <value>value_1</value> - <value>value_2</value> - </base> - </root> - - {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]} - */ - - @Test - public void json2Obj() throws APIException, SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException, IOException { - DerivedA da = new DerivedA(); - da.setName("myDerivedA_1"); - da.setNum((short)1432); - da.setShortName("mda_1"); - da.getValue().add("value_1"); - da.getValue().add("value_2"); - - Root root = new Root(); - root.getBase().add(da); - - da = new DerivedA(); - da.setName("myDerivedA_2"); - da.setNum((short)1432); - da.setShortName("mda_2"); - da.getValue().add("value_2.1"); - da.getValue().add("value_2.2"); - root.getBase().add(da); - - EnvJAXB env = new BasicEnv(); - DataFactory<Root> rootDF = env.newDataFactory(Root.class); - - String xml = rootDF.newData(env).out(Data.TYPE.XML).load(root).option(Data.PRETTY).asString(); - System.out.println(xml); - - InXML inXML; - Parse<Reader,?> in = inXML = new InXML(Root.class); - Out out = new OutRaw(); - - StringWriter sw = new StringWriter(); - out.extract(new StringReader(xml), sw, in); - System.out.println(sw.toString()); - - - out = new OutJson(); - - sw = new StringWriter(); - out.extract(new StringReader(xml), sw, in); - String json; - System.out.println(json = sw.toString()); - - in = new InJson(); - out = new OutRaw(); - - sw = new StringWriter(); - out.extract(new StringReader(json), sw, in); - System.out.println(sw.toString()); - - out = new OutXML(inXML); - - sw = new StringWriter(); - out.extract(new StringReader(json), sw, in, true); - System.out.println(sw.toString()); - - System.out.flush(); - - } + /* + <?xml version="1.0" encoding=Config.UTF-8 standalone="yes"?> + <root xmlns="urn:inherit"> + <base xsi:type="derivedA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <name>myDerivedA_1</name> + <num>1432</num> + <shortName>mda_1</shortName> + <value>value_1</value> + <value>value_2</value> + </base> + </root> + + {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]} + */ + + @Test + public void json2Obj() throws APIException, SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException, IOException { + DerivedA da = new DerivedA(); + da.setName("myDerivedA_1"); + da.setNum((short)1432); + da.setShortName("mda_1"); + da.getValue().add("value_1"); + da.getValue().add("value_2"); + + Root root = new Root(); + root.getBase().add(da); + + da = new DerivedA(); + da.setName("myDerivedA_2"); + da.setNum((short)1432); + da.setShortName("mda_2"); + da.getValue().add("value_2.1"); + da.getValue().add("value_2.2"); + root.getBase().add(da); + + EnvJAXB env = new BasicEnv(); + DataFactory<Root> rootDF = env.newDataFactory(Root.class); + + String xml = rootDF.newData(env).out(Data.TYPE.XML).load(root).option(Data.PRETTY).asString(); + System.out.println(xml); + + InXML inXML; + Parse<Reader,?> in = inXML = new InXML(Root.class); + Out out = new OutRaw(); + + StringWriter sw = new StringWriter(); + out.extract(new StringReader(xml), sw, in); + System.out.println(sw.toString()); + + + out = new OutJson(); + + sw = new StringWriter(); + out.extract(new StringReader(xml), sw, in); + String json; + System.out.println(json = sw.toString()); + + in = new InJson(); + out = new OutRaw(); + + sw = new StringWriter(); + out.extract(new StringReader(json), sw, in); + System.out.println(sw.toString()); + + out = new OutXML(inXML); + + sw = new StringWriter(); + out.extract(new StringReader(json), sw, in, true); + System.out.println(sw.toString()); + + System.out.flush(); + + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java index 1209e77d..7e767e5d 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java @@ -27,47 +27,47 @@ import org.onap.aaf.misc.rosetta.JaxInfo; import s.xsd.LargerData; public class JU_Struct { - public final static String XML ="<LargerData xmlns=\"urn:s:xsd\">\n" + - "<SampleData>\n" + - "<id>sd object 1</id>\n" + - "<date>1346439215932</date>\n" + - "<item>Item 1.1</item>\n" + - "<item>Item 1.2</item>\n" + - "</SampleData>\n" + - "<SampleData>\n" + - "<id>sd object 2</id>\n" + - "<date>1346439215932</date>\n" + - "<item>Item 2.1</item>\n" + - "<item>Item 2.2</item>\n" + - "</SampleData>\n" + - "<fluff>MyFluff</fluff>\n" + - "</LargerData>\n"; - -// @Test -// public void test2() throws Exception { + public final static String XML ="<LargerData xmlns=\"urn:s:xsd\">\n" + + "<SampleData>\n" + + "<id>sd object 1</id>\n" + + "<date>1346439215932</date>\n" + + "<item>Item 1.1</item>\n" + + "<item>Item 1.2</item>\n" + + "</SampleData>\n" + + "<SampleData>\n" + + "<id>sd object 2</id>\n" + + "<date>1346439215932</date>\n" + + "<item>Item 2.1</item>\n" + + "<item>Item 2.2</item>\n" + + "</SampleData>\n" + + "<fluff>MyFluff</fluff>\n" + + "</LargerData>\n"; + +// @Test +// public void test2() throws Exception { // -// SampleData sd = new SampleData(); -// sd.setDate(new Date().getTime()); -// sd.setId("myId"); -// sd.getItem().add("Item 1.1"); -// -// InObj<SampleData> inObj = new InObj<SampleData>(SampleData.class); +// SampleData sd = new SampleData(); +// sd.setDate(new Date().getTime()); +// sd.setId("myId"); +// sd.getItem().add("Item 1.1"); +// +// InObj<SampleData> inObj = new InObj<SampleData>(SampleData.class); // -// JaxSet<SampleData> jaxSet = JaxSet.get(SampleData.class); -// Setter<SampleData> setter = jaxSet.setter("id"); -// setter.set(sd, "Your ID"); -// -// for(Entry<String, Getter<SampleData>> es : jaxSet.getters()) { -// System.out.print(es.getKey()); -// System.out.print(' '); -// System.out.println(es.getValue().get(sd)); -// } -// } - - @Test - public void test() throws Exception { - JaxInfo ji = JaxInfo.build(LargerData.class); - System.out.println(ji); - } +// JaxSet<SampleData> jaxSet = JaxSet.get(SampleData.class); +// Setter<SampleData> setter = jaxSet.setter("id"); +// setter.set(sd, "Your ID"); +// +// for(Entry<String, Getter<SampleData>> es : jaxSet.getters()) { +// System.out.print(es.getKey()); +// System.out.print(' '); +// System.out.println(es.getValue().get(sd)); +// } +// } + + @Test + public void test() throws Exception { + JaxInfo ji = JaxInfo.build(LargerData.class); + System.out.println(ji); + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java index 5d76e3cb..032f9f1c 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java @@ -51,251 +51,251 @@ import types.xsd.Multi.Single; public class JU_Types { - @Test - public void single() throws Exception { - Single single = setSData(); - SingleMarshal psingle = new SingleMarshal(); - - OutRaw raw = new OutRaw(); - OutJson json = new OutJson(); - OutXML xml = new OutXML("Single","xmlns=urn:types:xsd"); - - - System.out.println("===== RAW ====="); - raw.extract(single, System.out, psingle); + @Test + public void single() throws Exception { + Single single = setSData(); + SingleMarshal psingle = new SingleMarshal(); + + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Single","xmlns=urn:types:xsd"); + + + System.out.println("===== RAW ====="); + raw.extract(single, System.out, psingle); - System.out.println("\n===== JSON ====="); - json.extract(single, System.out, psingle); - - System.out.println("\n\n===== Pretty JSON ====="); - json.extract(single, System.out, psingle, true); + System.out.println("\n===== JSON ====="); + json.extract(single, System.out, psingle); + + System.out.println("\n\n===== Pretty JSON ====="); + json.extract(single, System.out, psingle, true); - System.out.println("\n\n===== XML ====="); - xml.extract(single, System.out, psingle,false); + System.out.println("\n\n===== XML ====="); + xml.extract(single, System.out, psingle,false); - System.out.println("\n\n===== Pretty XML ====="); - xml.extract(single, System.out, psingle, true); + System.out.println("\n\n===== Pretty XML ====="); + xml.extract(single, System.out, psingle, true); - RosettaEnv env = new RosettaEnv(); - StringWriter sw = new StringWriter(); - xml.extract(single, sw, psingle, true); - JAXBumar jumar = new JAXBumar(single.getClass()); - JAXBmar jmar = new JAXBmar(new QName("Single","urn.types.xsd"),single.getClass()); - jmar.pretty(true); - sw = new StringWriter(); - jmar.marshal(env.info(), single, sw); - System.out.println(sw); - Single news = jumar.unmarshal(env.info(), sw.toString()); -// System.out.println(news.getDatetime()); -// sw = new StringWriter(); -// news.setDatetime(Chrono.timeStamp()); -// xml.extract(single, sw, psingle, true); - news = jumar.unmarshal(env.info(), sw.toString()); - System.out.println(sw.toString()); - - String sample = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" - + "\n<ns2:urn.types.xsd xmlns:ns2=\"Single\" xmlns=\"urn:types:xsd\">" - + "\n<str>MyString</str>" - + "\n<int>2147483647</int>" - + "\n<long>9223372036854775807</long>" - + "\n<date>2015-05-27-05:00</date>" - + "\n<datetime>2015-05-27T07:05:04.234-05:00</datetime>" - + "\n<binary>FF00FF0E082507807F</binary>" - + "\n<array>String 1</array>" - + "\n<array>String 2</array>" - + "\n</ns2:urn.types.xsd>"; - System.out.println(sample); - news = jumar.unmarshal(env.info(), sample); + RosettaEnv env = new RosettaEnv(); + StringWriter sw = new StringWriter(); + xml.extract(single, sw, psingle, true); + JAXBumar jumar = new JAXBumar(single.getClass()); + JAXBmar jmar = new JAXBmar(new QName("Single","urn.types.xsd"),single.getClass()); + jmar.pretty(true); + sw = new StringWriter(); + jmar.marshal(env.info(), single, sw); + System.out.println(sw); + Single news = jumar.unmarshal(env.info(), sw.toString()); +// System.out.println(news.getDatetime()); +// sw = new StringWriter(); +// news.setDatetime(Chrono.timeStamp()); +// xml.extract(single, sw, psingle, true); + news = jumar.unmarshal(env.info(), sw.toString()); + System.out.println(sw.toString()); + + String sample = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + + "\n<ns2:urn.types.xsd xmlns:ns2=\"Single\" xmlns=\"urn:types:xsd\">" + + "\n<str>MyString</str>" + + "\n<int>2147483647</int>" + + "\n<long>9223372036854775807</long>" + + "\n<date>2015-05-27-05:00</date>" + + "\n<datetime>2015-05-27T07:05:04.234-05:00</datetime>" + + "\n<binary>FF00FF0E082507807F</binary>" + + "\n<array>String 1</array>" + + "\n<array>String 2</array>" + + "\n</ns2:urn.types.xsd>"; + System.out.println(sample); + news = jumar.unmarshal(env.info(), sample); - System.out.println(news.getDatetime()); + System.out.println(news.getDatetime()); - } - - @Test - public void multi() throws Exception { - OutRaw raw = new OutRaw(); - OutJson json = new OutJson(); - OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); + } + + @Test + public void multi() throws Exception { + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); - Multi multi = new Multi(); - MultiMarshal pmulti = new MultiMarshal(); - - for(int i=0;i<10;++i) { - System.out.println("===== Multi Iteration " + i + " ====="); - if(i>0) { - multi.getSingle().add(setSData()); - } - System.out.println(" ===== RAW ====="); - raw.extract(multi, System.out, pmulti); - - System.out.println("\n ===== JSON ====="); - json.extract(multi, System.out, pmulti); - - System.out.println("\n\n ===== Pretty JSON ====="); - json.extract(multi, System.out, pmulti, true); - - System.out.println("\n\n ===== XML ====="); - xml.extract(multi, System.out, pmulti,false); - - System.out.println("\n\n ===== Pretty XML ====="); - xml.extract(multi, System.out, pmulti, true); - } - } + Multi multi = new Multi(); + MultiMarshal pmulti = new MultiMarshal(); + + for(int i=0;i<10;++i) { + System.out.println("===== Multi Iteration " + i + " ====="); + if(i>0) { + multi.getSingle().add(setSData()); + } + System.out.println(" ===== RAW ====="); + raw.extract(multi, System.out, pmulti); + + System.out.println("\n ===== JSON ====="); + json.extract(multi, System.out, pmulti); + + System.out.println("\n\n ===== Pretty JSON ====="); + json.extract(multi, System.out, pmulti, true); + + System.out.println("\n\n ===== XML ====="); + xml.extract(multi, System.out, pmulti,false); + + System.out.println("\n\n ===== Pretty XML ====="); + xml.extract(multi, System.out, pmulti, true); + } + } - @Test - public void doc() throws Exception { - OutRaw raw = new OutRaw(); - OutJson json = new OutJson(); - OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); + @Test + public void doc() throws Exception { + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); - Multi multi = new Multi(); - DocMarshal<Multi> doc = DocMarshal.root(new MultiMarshal()); - - for(int i=0;i<3;++i) { - System.out.println("===== Multi Iteration " + i + " ====="); - if(i>0) { - multi.getSingle().add(setSData()); - } - System.out.println(" ===== RAW ====="); - raw.extract(multi, System.out, doc); - - System.out.println("\n ===== JSON ====="); - json.extract(multi, System.out, doc); - - System.out.println("\n\n ===== Pretty JSON ====="); - json.extract(multi, System.out, doc, true); - - System.out.println("\n\n ===== XML ====="); - xml.extract(multi, System.out, doc,false); - - System.out.println("\n\n ===== Pretty XML ====="); - xml.extract(multi, System.out, doc, true); - } - } + Multi multi = new Multi(); + DocMarshal<Multi> doc = DocMarshal.root(new MultiMarshal()); + + for(int i=0;i<3;++i) { + System.out.println("===== Multi Iteration " + i + " ====="); + if(i>0) { + multi.getSingle().add(setSData()); + } + System.out.println(" ===== RAW ====="); + raw.extract(multi, System.out, doc); + + System.out.println("\n ===== JSON ====="); + json.extract(multi, System.out, doc); + + System.out.println("\n\n ===== Pretty JSON ====="); + json.extract(multi, System.out, doc, true); + + System.out.println("\n\n ===== XML ====="); + xml.extract(multi, System.out, doc,false); + + System.out.println("\n\n ===== Pretty XML ====="); + xml.extract(multi, System.out, doc, true); + } + } -// @Test -// public void saved() throws Exception { -// Saved saved = new Saved(); -// saved.extract(in, ignore, parser, options); -// } - - @Test - public void df() throws Exception { - RosettaEnv env = new RosettaEnv(); - RosettaDF<Multi> df = env.newDataFactory(Multi.class); - df.out(TYPE.JSON).option(Data.PRETTY); - - Multi multi = new Multi(); - multi.getSingle().add(setSData()); - +// @Test +// public void saved() throws Exception { +// Saved saved = new Saved(); +// saved.extract(in, ignore, parser, options); +// } + + @Test + public void df() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<Multi> df = env.newDataFactory(Multi.class); + df.out(TYPE.JSON).option(Data.PRETTY); + + Multi multi = new Multi(); + multi.getSingle().add(setSData()); + - System.out.println("========== Original loading"); - Trans trans = env.newTrans(); - RosettaData<Multi> data = df.newData(trans); - // Prime pump - for(int i=0;i<100;++i) { - data.load(multi); - } - trans = env.newTrans(); - data = df.newData(trans); - - int iters = 10000; - for(int i=0;i<iters;++i) { - data.load(multi); - } - Metric metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); - System.out.println(data.asString()); - System.out.println(metrics.total/iters + "ms avg"); + System.out.println("========== Original loading"); + Trans trans = env.newTrans(); + RosettaData<Multi> data = df.newData(trans); + // Prime pump + for(int i=0;i<100;++i) { + data.load(multi); + } + trans = env.newTrans(); + data = df.newData(trans); + + int iters = 10000; + for(int i=0;i<iters;++i) { + data.load(multi); + } + Metric metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(data.asString()); + System.out.println(metrics.total/iters + "ms avg"); - System.out.println("========== New loading"); - // With new - df.rootMarshal(DocMarshal.root(new MultiMarshal())); - trans = env.newTrans(); - data = df.newData(trans); + System.out.println("========== New loading"); + // With new + df.rootMarshal(DocMarshal.root(new MultiMarshal())); + trans = env.newTrans(); + data = df.newData(trans); - // Prime pump - for(int i=0;i<100;++i) { - data.load(multi); - } - trans = env.newTrans(); - data = df.newData(trans); - - for(int i=0;i<iters;++i) { - data.load(multi); - } - metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); - System.out.println(data.asString()); - System.out.println(metrics.total/iters + "ms avg"); - - // Assert.assertEquals(first, second); + // Prime pump + for(int i=0;i<100;++i) { + data.load(multi); + } + trans = env.newTrans(); + data = df.newData(trans); + + for(int i=0;i<iters;++i) { + data.load(multi); + } + metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(data.asString()); + System.out.println(metrics.total/iters + "ms avg"); + + // Assert.assertEquals(first, second); - System.out.println("========== Direct Object to JSON String"); - trans = env.newTrans(); - data = df.newData(trans); - StringBuilderWriter sbw = new StringBuilderWriter(256); - // Prime pump - for(int i=0;i<100;++i) { - sbw.reset(); - data.direct(multi, sbw, true); - } - trans = env.newTrans(); - data = df.newData(trans); + System.out.println("========== Direct Object to JSON String"); + trans = env.newTrans(); + data = df.newData(trans); + StringBuilderWriter sbw = new StringBuilderWriter(256); + // Prime pump + for(int i=0;i<100;++i) { + sbw.reset(); + data.direct(multi, sbw, true); + } + trans = env.newTrans(); + data = df.newData(trans); - for(int i=0;i<iters;++i) { - sbw.reset(); - data.direct(multi, sbw, true); - } - - metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); - System.out.println(sbw.toString()); - System.out.println(metrics.total/iters + "ms avg"); - - } - - private Single setSData() { - Single s = new Single(); - s.setStr("MyString"); - s.setInt(Integer.MAX_VALUE); - s.setLong(Long.MAX_VALUE); - XMLGregorianCalendar ts = Chrono.timeStamp(); - s.setDate(ts); - s.setDatetime(ts); - byte[] bytes= new byte[] {-1,0,(byte)0XFF,0xE,0x8,0x25,0x7,Byte.MIN_VALUE,Byte.MAX_VALUE}; - s.setBinary(bytes); - s.getArray().add("String 1"); - s.getArray().add("String 2"); - return s; - } + for(int i=0;i<iters;++i) { + sbw.reset(); + data.direct(multi, sbw, true); + } + + metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(sbw.toString()); + System.out.println(metrics.total/iters + "ms avg"); + + } + + private Single setSData() { + Single s = new Single(); + s.setStr("MyString"); + s.setInt(Integer.MAX_VALUE); + s.setLong(Long.MAX_VALUE); + XMLGregorianCalendar ts = Chrono.timeStamp(); + s.setDate(ts); + s.setDatetime(ts); + byte[] bytes= new byte[] {-1,0,(byte)0XFF,0xE,0x8,0x25,0x7,Byte.MIN_VALUE,Byte.MAX_VALUE}; + s.setBinary(bytes); + s.getArray().add("String 1"); + s.getArray().add("String 2"); + return s; + } -// @Test -// public void jsonInOut() throws IOException, ParseException { -// Parse<?> jin = new InJson(); -// Out jout = new OutJson(); +// @Test +// public void jsonInOut() throws IOException, ParseException { +// Parse<?> jin = new InJson(); +// Out jout = new OutJson(); // -//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); -// -// } - - - /* - private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { - - System.out.println(str); - StringWriter sw = new StringWriter(1024); - out.extract(new StringReader(str), sw, in); - System.out.println(sw); - String result = sw.toString(); - - if(!result.equals(str)) { - sw.getBuffer().setLength(0); - new OutRaw().extract(new StringReader(str), sw, in); - System.out.println(sw); - } +//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); +// +// } + + + /* + private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { + + System.out.println(str); + StringWriter sw = new StringWriter(1024); + out.extract(new StringReader(str), sw, in); + System.out.println(sw); + String result = sw.toString(); + + if(!result.equals(str)) { + sw.getBuffer().setLength(0); + new OutRaw().extract(new StringReader(str), sw, in); + System.out.println(sw); + } - Assert.assertEquals(str,result); - System.out.println(); + Assert.assertEquals(str,result); + System.out.println(); - } - */ + } + */ } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java index ab0c921a..6ebd07a3 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java @@ -32,60 +32,60 @@ import org.onap.aaf.misc.rosetta.Parsed; public class OutDump extends Out{ - @Override - public<IN, S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { - IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); + @Override + public<IN, S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { + IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); - Parsed<S> p = prs.newParsed(); - - while((p = prs.parse(in,p.reuse())).valid()) { - switch(p.event) { - case Parse.START_OBJ: - ipw.append("Start Object "); - ipw.append(p.name); - ipw.inc(); - break; - case Parse.END_OBJ: - printData(ipw,p); - ipw.dec(); - ipw.append("End Object "); - ipw.append(p.name); - break; - case Parse.START_ARRAY: - ipw.inc(); - ipw.append("Start Array "); - ipw.append(p.name); - ipw.append('\n'); - break; - case Parse.END_ARRAY: - printData(ipw,p); - ipw.dec(); - ipw.append("End Array "); - ipw.append('\n'); - break; - case Parse.NEXT: - printData(ipw,p); - break; - } - } - } - - private void printData(IndentPrintWriter ipw, Parsed<?> parsed) { - if(parsed.hasData()) { - ipw.append("Data:["); - if(parsed.hasName()) { - ipw.append(parsed.name); - ipw.append(" : "); - } - ipw.append(parsed.sb); - ipw.append("]"); - ipw.append('\n'); - } - } + Parsed<S> p = prs.newParsed(); + + while((p = prs.parse(in,p.reuse())).valid()) { + switch(p.event) { + case Parse.START_OBJ: + ipw.append("Start Object "); + ipw.append(p.name); + ipw.inc(); + break; + case Parse.END_OBJ: + printData(ipw,p); + ipw.dec(); + ipw.append("End Object "); + ipw.append(p.name); + break; + case Parse.START_ARRAY: + ipw.inc(); + ipw.append("Start Array "); + ipw.append(p.name); + ipw.append('\n'); + break; + case Parse.END_ARRAY: + printData(ipw,p); + ipw.dec(); + ipw.append("End Array "); + ipw.append('\n'); + break; + case Parse.NEXT: + printData(ipw,p); + break; + } + } + } + + private void printData(IndentPrintWriter ipw, Parsed<?> parsed) { + if(parsed.hasData()) { + ipw.append("Data:["); + if(parsed.hasName()) { + ipw.append(parsed.name); + ipw.append(" : "); + } + ipw.append(parsed.sb); + ipw.append("]"); + ipw.append('\n'); + } + } - @Override - public String logName() { - return "Rosetta OutDump"; - } + @Override + public String logName() { + return "Rosetta OutDump"; + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java index 5c709adc..df4fec07 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java @@ -28,40 +28,40 @@ import org.onap.aaf.misc.env.Trans; import org.onap.aaf.misc.env.Trans.Metric; public class Report { - float total; - float buckets[]; - String[] names; - private int iterations; - private int count; - - public Report(int iters, String ... names) { - iterations = iters; - buckets = new float[names.length]; - this.names = names; - total=0; - count = 0; - } - - public void glean(Trans trans, int ... type) { - Metric m = trans.auditTrail(0, null, type); - total+=m.total; - int min = Math.min(buckets.length, m.buckets.length); - for(int b=0;b<min;++b) { - buckets[b]+=m.buckets[b]; - } - } - - public boolean go() { - return ++count<iterations; - } - - - public void report(Writer sbw) throws IOException { - sbw.append("\n"+count + " entries, Total Time: " + total + "ms, Avg Time: " + total/count + "ms\n"); - int min = Math.min(buckets.length, names.length); - for(int i=0;i<min;++i) { - sbw.append(" Time: " + names[i] + ' ' + buckets[i] + "ms, Avg Time: " + buckets[i]/count + "ms\n"); - } + float total; + float buckets[]; + String[] names; + private int iterations; + private int count; + + public Report(int iters, String ... names) { + iterations = iters; + buckets = new float[names.length]; + this.names = names; + total=0; + count = 0; + } + + public void glean(Trans trans, int ... type) { + Metric m = trans.auditTrail(0, null, type); + total+=m.total; + int min = Math.min(buckets.length, m.buckets.length); + for(int b=0;b<min;++b) { + buckets[b]+=m.buckets[b]; + } + } + + public boolean go() { + return ++count<iterations; + } + + + public void report(Writer sbw) throws IOException { + sbw.append("\n"+count + " entries, Total Time: " + total + "ms, Avg Time: " + total/count + "ms\n"); + int min = Math.min(buckets.length, names.length); + for(int i=0;i<min;++i) { + sbw.append(" Time: " + names[i] + ' ' + buckets[i] + "ms, Avg Time: " + buckets[i]/count + "ms\n"); + } - } + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java index 5e96a379..b28ca766 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java @@ -30,12 +30,12 @@ import types.xsd.Multi; import types.xsd.Multi.Single; public class MultiMarshal extends ObjMarshal<Multi> { - public MultiMarshal() { - add(new ObjArray<Multi,Single>("single",new SingleMarshal()) { - @Override - protected List<Single> data(Multi t) { - return t.getSingle(); - } - }); - } + public MultiMarshal() { + add(new ObjArray<Multi,Single>("single",new SingleMarshal()) { + @Override + protected List<Single> data(Multi t) { + return t.getSingle(); + } + }); + } }
\ No newline at end of file diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java index 932277de..bde91c9e 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java @@ -37,55 +37,55 @@ import org.onap.aaf.misc.rosetta.marshal.ObjMarshal; import types.xsd.Multi.Single; public class SingleMarshal extends ObjMarshal<Single> { - public SingleMarshal() { - add(new FieldString<Single>("str") { - @Override - protected String data(Single t) { - return t.getStr(); - } - }); - - add(new FieldNumeric<Integer, Single>("int") { - @Override - protected Integer data(Single t) { - return t.getInt(); - } - }); - - add(new FieldNumeric<Long,Single>("long") { - @Override - protected Long data(Single t) { - return t.getLong(); - } - }); + public SingleMarshal() { + add(new FieldString<Single>("str") { + @Override + protected String data(Single t) { + return t.getStr(); + } + }); + + add(new FieldNumeric<Integer, Single>("int") { + @Override + protected Integer data(Single t) { + return t.getInt(); + } + }); + + add(new FieldNumeric<Long,Single>("long") { + @Override + protected Long data(Single t) { + return t.getLong(); + } + }); - add(new FieldDate<Single>("date") { - @Override - protected XMLGregorianCalendar data(Single t) { - return t.getDate(); - } - }); + add(new FieldDate<Single>("date") { + @Override + protected XMLGregorianCalendar data(Single t) { + return t.getDate(); + } + }); - add(new FieldDateTime<Single>("datetime") { - @Override - protected XMLGregorianCalendar data(Single t) { - return t.getDate(); - } - }); - - add(new FieldHexBinary<Single>("binary") { - @Override - protected byte[] data(Single t) { - return t.getBinary(); - } - }); - - add(new FieldArray<Single,String>("array", DataWriter.STRING) { - @Override - protected List<String> data(Single t) { - return t.getArray(); - } - }); + add(new FieldDateTime<Single>("datetime") { + @Override + protected XMLGregorianCalendar data(Single t) { + return t.getDate(); + } + }); + + add(new FieldHexBinary<Single>("binary") { + @Override + protected byte[] data(Single t) { + return t.getBinary(); + } + }); + + add(new FieldArray<Single,String>("array", DataWriter.STRING) { + @Override + protected List<String> data(Single t) { + return t.getArray(); + } + }); - } + } }
\ No newline at end of file |