a0847f4c41671a70ee424685543190c64cda762e
[aaf/authz.git] / misc / rosetta / src / test / java / org / onap / aaf / misc / rosetta / test / JU_Saved.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.misc.rosetta.test;
23
24 import java.io.Reader;
25 import java.io.StringReader;
26
27 import org.junit.Test;
28 import org.onap.aaf.misc.env.TimeTaken;
29 import org.onap.aaf.misc.env.Trans;
30 import org.onap.aaf.misc.env.impl.EnvFactory;
31 import org.onap.aaf.misc.env.util.StringBuilderWriter;
32 import org.onap.aaf.misc.rosetta.InJson;
33 import org.onap.aaf.misc.rosetta.JaxInfo;
34 import org.onap.aaf.misc.rosetta.OutJson;
35 import org.onap.aaf.misc.rosetta.OutXML;
36 import org.onap.aaf.misc.rosetta.Saved;
37
38 import s.xsd.LargerData;
39
40 public class JU_Saved<b> {
41     private static int ITERATIONS = 100000;
42
43     @Test
44     public void test() throws Exception {
45         InJson inJSON = new InJson();
46         OutDump dump = new OutDump();
47         JaxInfo ji = JaxInfo.build(LargerData.class);
48         OutXML xml = new OutXML(ji);;
49         OutJson json = new OutJson();
50         
51         Saved saved = new Saved();
52         
53         StringBuilderWriter sbw = new StringBuilderWriter(1024);
54         
55         Trans trans;
56         Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON");
57         do {
58             sbw.reset();
59             trans = EnvFactory.newTrans();
60             Reader sr = new StringReader(JU_FromJSON.str);
61             TimeTaken tt = trans.start("Parse Text, and Save", 1);
62             try {
63                 saved.load(sr, inJSON);
64             } finally {
65                 tt.done();
66             }
67
68 //            sbw.append("==== Start Direct Raw =====\n");
69 //            new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON);
70 //            
71 //            sbw.append("==== Start Raw from Saved =====\n");
72 //            new OutRaw().extract(null,sbw,saved);
73
74             sbw.append("==== Start Dump from Saved =====\n");
75             tt = trans.start("Dump", 2);
76             try {
77                 dump.extract(null,sbw,saved);
78             } finally {
79                 tt.done();
80             }
81             
82             sbw.append("\n==== Start XML =====\n");
83             tt = trans.start("XML", 3);
84             try {
85                 xml.extract(null,sbw,saved);
86             } finally {
87                 tt.done();
88             }
89             
90             sbw.append("\n==== Start JSON =====\n");
91             tt = trans.start("JSON", 4);
92             try {
93                 json.extract(null,sbw,saved);
94             } finally {
95                 tt.done();
96             }
97             report.glean(trans,1,2,3,4);
98         } while (report.go());
99         
100         report.report(sbw);
101         System.out.println(sbw.toString());
102
103     }
104 }