From 82efa7f7b2f4b1079d01d0f9c0a2b4ca43e9a24d Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 26 Mar 2018 11:37:12 -0700 Subject: Remove Code from inno, it is now in authz Issue-ID: AAF-193 Change-Id: I5b80daa8344559bc86c82cbaa85c29e0eea54ebb Signed-off-by: Instrumental --- .../src/test/java/com/data/test/JU_FromJSON.java | 269 ------------------ .../src/test/java/com/data/test/JU_FromXML.java | 260 ------------------ rosetta/src/test/java/com/data/test/JU_JSON.java | 136 --------- rosetta/src/test/java/com/data/test/JU_Ladder.java | 79 ------ rosetta/src/test/java/com/data/test/JU_Nulls.java | 70 ----- .../src/test/java/com/data/test/JU_RosettaDF.java | 163 ----------- rosetta/src/test/java/com/data/test/JU_Saved.java | 105 ------- .../src/test/java/com/data/test/JU_Stream2Obj.java | 124 --------- rosetta/src/test/java/com/data/test/JU_Struct.java | 74 ----- rosetta/src/test/java/com/data/test/JU_Types.java | 303 --------------------- rosetta/src/test/java/com/data/test/OutDump.java | 92 ------- rosetta/src/test/java/com/data/test/Report.java | 68 ----- .../test/java/com/data/test/obj/MultiMarshal.java | 42 --- .../test/java/com/data/test/obj/SingleMarshal.java | 92 ------- 14 files changed, 1877 deletions(-) delete mode 100644 rosetta/src/test/java/com/data/test/JU_FromJSON.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_FromXML.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_JSON.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Ladder.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Nulls.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_RosettaDF.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Saved.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Stream2Obj.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Struct.java delete mode 100644 rosetta/src/test/java/com/data/test/JU_Types.java delete mode 100644 rosetta/src/test/java/com/data/test/OutDump.java delete mode 100644 rosetta/src/test/java/com/data/test/Report.java delete mode 100644 rosetta/src/test/java/com/data/test/obj/MultiMarshal.java delete mode 100644 rosetta/src/test/java/com/data/test/obj/SingleMarshal.java (limited to 'rosetta/src/test/java/com/data') diff --git a/rosetta/src/test/java/com/data/test/JU_FromJSON.java b/rosetta/src/test/java/com/data/test/JU_FromJSON.java deleted file mode 100644 index fd13f78..0000000 --- a/rosetta/src/test/java/com/data/test/JU_FromJSON.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.Reader; -import java.io.StringReader; - -import org.junit.Test; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.LogTarget; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.impl.EnvFactory; -import org.onap.aaf.inno.env.jaxb.JAXBmar; -import org.onap.aaf.inno.env.util.IndentPrintWriter; -import org.onap.aaf.inno.env.util.StringBuilderWriter; -import org.onap.aaf.rosetta.InJson; -import org.onap.aaf.rosetta.Out; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutRaw; -import org.onap.aaf.rosetta.OutXML; - -import junit.framework.Assert; -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(); - - @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); - - 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); - - 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); - - 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); - - 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 ***"); - - 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()); - } -} diff --git a/rosetta/src/test/java/com/data/test/JU_FromXML.java b/rosetta/src/test/java/com/data/test/JU_FromXML.java deleted file mode 100644 index 97209ff..0000000 --- a/rosetta/src/test/java/com/data/test/JU_FromXML.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.Reader; -import java.io.StringReader; - -import org.junit.Test; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.LogTarget; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.Trans.Metric; -import org.onap.aaf.inno.env.impl.EnvFactory; -import org.onap.aaf.inno.env.jaxb.JAXBmar; -import org.onap.aaf.inno.env.jaxb.JAXBumar; -import org.onap.aaf.inno.env.util.StringBuilderWriter; -import org.onap.aaf.rosetta.InXML; -import org.onap.aaf.rosetta.Out; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutRaw; -import org.onap.aaf.rosetta.OutXML; - -import s.xsd.LargerData; - -public class JU_FromXML { - private static int ITERATIONS = 1; - ; - - private final static String xml = - "\n" + - "\n" + - " \n" + - " sd object 1\n" + - " 1346765355134\n" + - " Item 1.1\n" + - " Item 1.2\n" + - " \n" + - " \n" + - " sd object 2\n" + - " 1346765355134\n" + - " Item 2.1\n" + - " Item 2.2\n" + - " \n" + - " MyFluff\n" + - "\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); - - 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); - - 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 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;i20) { - 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/rosetta/src/test/java/com/data/test/JU_JSON.java b/rosetta/src/test/java/com/data/test/JU_JSON.java deleted file mode 100644 index ffaf429..0000000 --- a/rosetta/src/test/java/com/data/test/JU_JSON.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; - -import org.junit.Test; -import org.onap.aaf.rosetta.InJson; -import org.onap.aaf.rosetta.Out; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutRaw; -import org.onap.aaf.rosetta.Parse; -import org.onap.aaf.rosetta.ParseException; - -import junit.framework.Assert; - -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}"); - - go(jin,jout, "{\"userid\":\"ab1234\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}"); - //go() - //"ab12341353082669667"); - - // 3/11/2015 jcg 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\":\"com.att.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}" - + ",\"role\":\"com.att.myns.myrole\"}"); - - // 3/12/2015 jcg Kurt Schurenberg noticed an issue of object names in an array. This is valid code. - go(jin,jout, "{\"role\":[{\"name\":\"com.att.myns.myrole\",\"perms\":[{\"type\":\"com.att.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"com.att.myns.mytype\",\"instance\":\"myOtherAction\"}]}" - + ",{\"name\":\"com.att.myns.myOtherRole\",\"perms\":[{\"type\":\"com.att.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"com.att.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 jcg AAF-703 Ron Gallagher, this response is ok - go(jin,jout, "{\"perm\":[{\"type\":\"com.att.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}"); - // but when description:"" causes extra comma at end - go(jin,jout, "{\"perm\":[{\"type\":\"com.att.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"com.att.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\":\"com.att.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"com.att.myns.myPerm\",\"description\":\"something\"}]}"); - - go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}"); - - go(jin, jout, "{\"name\":\"\\\\\"}"); - - go(jin, jout, "{\"role\":\"com.att.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"com.att.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}"); - - - } - - - private void go(Parse in, Out out, String str) throws IOException, ParseException { - go(in,out,str,str); - } - - - private void go(Parse 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/rosetta/src/test/java/com/data/test/JU_Ladder.java b/rosetta/src/test/java/com/data/test/JU_Ladder.java deleted file mode 100644 index 77165b8..0000000 --- a/rosetta/src/test/java/com/data/test/JU_Ladder.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.aaf.rosetta.Ladder; - -import static org.junit.Assert.*; - -public class JU_Ladder { - - @Test - public void test() { - Ladder ladder = new Ladder(); - - for(int i=0;i<30;++i) { - for(int j=0;j 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 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/rosetta/src/test/java/com/data/test/JU_RosettaDF.java b/rosetta/src/test/java/com/data/test/JU_RosettaDF.java deleted file mode 100644 index 5c26afe..0000000 --- a/rosetta/src/test/java/com/data/test/JU_RosettaDF.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.StringReader; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.Data.TYPE; -import org.onap.aaf.inno.env.impl.EnvFactory; -import org.onap.aaf.inno.env.jaxb.JAXBmar; -import org.onap.aaf.inno.env.util.StringBuilderWriter; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaData; -import org.onap.aaf.rosetta.env.RosettaEnv; - -import s.xsd.LargerData; -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 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 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 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 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 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/rosetta/src/test/java/com/data/test/JU_Saved.java b/rosetta/src/test/java/com/data/test/JU_Saved.java deleted file mode 100644 index 1d43f88..0000000 --- a/rosetta/src/test/java/com/data/test/JU_Saved.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.Reader; -import java.io.StringReader; - -import org.junit.Test; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.impl.EnvFactory; -import org.onap.aaf.inno.env.util.StringBuilderWriter; -import org.onap.aaf.rosetta.InJson; -import org.onap.aaf.rosetta.JaxInfo; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutXML; -import org.onap.aaf.rosetta.Saved; - -import s.xsd.LargerData; - -public class JU_Saved { - 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(); - } - -// 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()); - - } -} diff --git a/rosetta/src/test/java/com/data/test/JU_Stream2Obj.java b/rosetta/src/test/java/com/data/test/JU_Stream2Obj.java deleted file mode 100644 index 4ca3328..0000000 --- a/rosetta/src/test/java/com/data/test/JU_Stream2Obj.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; - -import org.junit.Test; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.DataFactory; -import org.onap.aaf.inno.env.EnvJAXB; -import org.onap.aaf.inno.env.impl.BasicEnv; -import org.onap.aaf.rosetta.InJson; -import org.onap.aaf.rosetta.InXML; -import org.onap.aaf.rosetta.Out; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutRaw; -import org.onap.aaf.rosetta.OutXML; -import org.onap.aaf.rosetta.Parse; -import org.onap.aaf.rosetta.ParseException; - -import inherit.DerivedA; -import inherit.Root; - -public class JU_Stream2Obj { - - /* - - - - myDerivedA_1 - 1432 - mda_1 - value_1 - value_2 - - - - {"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 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 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/rosetta/src/test/java/com/data/test/JU_Struct.java b/rosetta/src/test/java/com/data/test/JU_Struct.java deleted file mode 100644 index cb65f24..0000000 --- a/rosetta/src/test/java/com/data/test/JU_Struct.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import org.junit.Test; -import org.onap.aaf.rosetta.JaxInfo; - -import s.xsd.LargerData; - -public class JU_Struct { - public final static String XML ="\n" + - "\n" + - "sd object 1\n" + - "1346439215932\n" + - "Item 1.1\n" + - "Item 1.2\n" + - "\n" + - "\n" + - "sd object 2\n" + - "1346439215932\n" + - "Item 2.1\n" + - "Item 2.2\n" + - "\n" + - "MyFluff\n" + - "\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 inObj = new InObj(SampleData.class); -// -// JaxSet jaxSet = JaxSet.get(SampleData.class); -// Setter setter = jaxSet.setter("id"); -// setter.set(sd, "Your ID"); -// -// for(Entry> 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/rosetta/src/test/java/com/data/test/JU_Types.java b/rosetta/src/test/java/com/data/test/JU_Types.java deleted file mode 100644 index 3fef743..0000000 --- a/rosetta/src/test/java/com/data/test/JU_Types.java +++ /dev/null @@ -1,303 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.StringWriter; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import org.junit.Test; -import org.onap.aaf.inno.env.Data; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.Data.TYPE; -import org.onap.aaf.inno.env.Trans.Metric; -import org.onap.aaf.inno.env.jaxb.JAXBmar; -import org.onap.aaf.inno.env.jaxb.JAXBumar; -import org.onap.aaf.inno.env.util.Chrono; -import org.onap.aaf.inno.env.util.StringBuilderWriter; -import org.onap.aaf.rosetta.OutJson; -import org.onap.aaf.rosetta.OutRaw; -import org.onap.aaf.rosetta.OutXML; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaData; -import org.onap.aaf.rosetta.env.RosettaEnv; -import org.onap.aaf.rosetta.marshal.DocMarshal; - -import com.data.test.obj.MultiMarshal; -import com.data.test.obj.SingleMarshal; - -import types.xsd.Multi; -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); - - 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===== 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 = "" - + "\n" - + "\nMyString" - + "\n2147483647" - + "\n9223372036854775807" - + "\n2015-05-27-05:00" - + "\n2015-05-27T07:05:04.234-05:00" - + "\nFF00FF0E082507807F" - + "\nString 1" - + "\nString 2" - + "\n"; - System.out.println(sample); - news = jumar.unmarshal(env.info(), sample); - - 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"); - - 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"); - - Multi multi = new Multi(); - DocMarshal 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 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 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 jin = new InJson(); -// Out jout = new OutJson(); -// -//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); -// -// } - - - /* - private void go(Parse 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(); - - } - */ -} diff --git a/rosetta/src/test/java/com/data/test/OutDump.java b/rosetta/src/test/java/com/data/test/OutDump.java deleted file mode 100644 index b4f477f..0000000 --- a/rosetta/src/test/java/com/data/test/OutDump.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.IOException; -import java.io.Writer; - -import org.onap.aaf.inno.env.util.IndentPrintWriter; -import org.onap.aaf.rosetta.Out; -import org.onap.aaf.rosetta.Parse; -import org.onap.aaf.rosetta.ParseException; -import org.onap.aaf.rosetta.Parsed; - -public class OutDump extends Out{ - - @Override - public void extract(IN in, Writer writer, Parse prs, boolean ... options) throws IOException, ParseException { - IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); - - Parsed 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"; - } - -} diff --git a/rosetta/src/test/java/com/data/test/Report.java b/rosetta/src/test/java/com/data/test/Report.java deleted file mode 100644 index 7179245..0000000 --- a/rosetta/src/test/java/com/data/test/Report.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test; - -import java.io.IOException; -import java.io.Writer; - -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.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 { - public MultiMarshal() { - add(new ObjArray("single",new SingleMarshal()) { - @Override - protected List data(Multi t) { - return t.getSingle(); - } - }); - } -} diff --git a/rosetta/src/test/java/com/data/test/obj/SingleMarshal.java b/rosetta/src/test/java/com/data/test/obj/SingleMarshal.java deleted file mode 100644 index d524516..0000000 --- a/rosetta/src/test/java/com/data/test/obj/SingleMarshal.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * * =========================================================================== - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * ============LICENSE_END==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.data.test.obj; - -import java.util.List; - -import javax.xml.datatype.XMLGregorianCalendar; - -import org.onap.aaf.rosetta.marshal.DataWriter; -import org.onap.aaf.rosetta.marshal.FieldArray; -import org.onap.aaf.rosetta.marshal.FieldDate; -import org.onap.aaf.rosetta.marshal.FieldDateTime; -import org.onap.aaf.rosetta.marshal.FieldHexBinary; -import org.onap.aaf.rosetta.marshal.FieldNumeric; -import org.onap.aaf.rosetta.marshal.FieldString; -import org.onap.aaf.rosetta.marshal.ObjMarshal; - -import types.xsd.Multi.Single; - -public class SingleMarshal extends ObjMarshal { - public SingleMarshal() { - add(new FieldString("str") { - @Override - protected String data(Single t) { - return t.getStr(); - } - }); - - add(new FieldNumeric("int") { - @Override - protected Integer data(Single t) { - return t.getInt(); - } - }); - - add(new FieldNumeric("long") { - @Override - protected Long data(Single t) { - return t.getLong(); - } - }); - - add(new FieldDate("date") { - @Override - protected XMLGregorianCalendar data(Single t) { - return t.getDate(); - } - }); - - add(new FieldDateTime("datetime") { - @Override - protected XMLGregorianCalendar data(Single t) { - return t.getDate(); - } - }); - - add(new FieldHexBinary("binary") { - @Override - protected byte[] data(Single t) { - return t.getBinary(); - } - }); - - add(new FieldArray("array", DataWriter.STRING) { - @Override - protected List data(Single t) { - return t.getArray(); - } - }); - - } -} -- cgit 1.2.3-korg