From 1296352d8eafee57f982a4342ad79ada4aa56d28 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Tue, 15 Oct 2019 08:19:50 -0500 Subject: Sonar Fixes, Formatting Issue-ID: AAF-1019 Change-Id: Ica49d9e7323aad9622ff9d95cc21b87430c22c54 Signed-off-by: Instrumental --- .../onap/aaf/misc/rosetta/JU_ParseException.java | 8 +- .../java/org/onap/aaf/misc/rosetta/env/Api.java | 146 ++++++++++---------- .../onap/aaf/misc/rosetta/env/JU_RosettaData.java | 152 ++++++++++----------- .../onap/aaf/misc/rosetta/env/JU_RosettaEnv.java | 12 +- .../aaf/misc/rosetta/marshal/JU_FieldBlob.java | 6 +- .../onap/aaf/misc/rosetta/test/JU_FromJSON.java | 38 +++--- .../org/onap/aaf/misc/rosetta/test/JU_FromXML.java | 40 +++--- .../org/onap/aaf/misc/rosetta/test/JU_JSON.java | 42 +++--- .../org/onap/aaf/misc/rosetta/test/JU_Ladder.java | 18 +-- .../org/onap/aaf/misc/rosetta/test/JU_Nulls.java | 8 +- .../onap/aaf/misc/rosetta/test/JU_RosettaDF.java | 26 ++-- .../org/onap/aaf/misc/rosetta/test/JU_Saved.java | 18 +-- .../onap/aaf/misc/rosetta/test/JU_Stream2Obj.java | 18 +-- .../org/onap/aaf/misc/rosetta/test/JU_Struct.java | 12 +- .../org/onap/aaf/misc/rosetta/test/JU_Types.java | 64 ++++----- .../org/onap/aaf/misc/rosetta/test/OutDump.java | 14 +- .../org/onap/aaf/misc/rosetta/test/Report.java | 14 +- .../aaf/misc/rosetta/test/obj/MultiMarshal.java | 4 +- .../aaf/misc/rosetta/test/obj/SingleMarshal.java | 12 +- 19 files changed, 326 insertions(+), 326 deletions(-) (limited to 'misc/rosetta/src/test/java') diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java index 1a31b0fb..83972f96 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java @@ -7,9 +7,9 @@ * 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. @@ -43,7 +43,7 @@ public class JU_ParseException { ParseException pe = new ParseException("exception",new NullPointerException("exception")); } - - + + } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java index 20744355..e7d07406 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java @@ -7,9 +7,9 @@ * 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. @@ -19,10 +19,10 @@ * */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2018.12.09 at 10:14:23 PM IST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.12.09 at 10:14:23 PM IST // @@ -39,9 +39,9 @@ import javax.xml.bind.annotation.XmlType; /** *

Java class for anonymous complex type. - * + * *

The following schema fragment specifies the expected content contained within this class. - * + * *

  * <complexType>
  *   <complexContent>
@@ -70,8 +70,8 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * + * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -84,25 +84,25 @@ public class Api { /** * Gets the value of the route property. - * - *

+ * + * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the route property. - * - *

+ * + * * For example, to add a new item, do as follows: *

      *    getRoute().add(newItem);
      * 
- * - * - *

+ * + * + * * Objects of the following type(s) are allowed in the list * {@link Api.Route } - * - * + * + * */ public List getRoute() { if (route == null) { @@ -114,9 +114,9 @@ public class Api { /** *

Java class for anonymous complex type. - * + * *

The following schema fragment specifies the expected content contained within this class. - * + * *

      * <complexType>
      *   <complexContent>
@@ -135,8 +135,8 @@ public class Api {
      *   </complexContent>
      * </complexType>
      * 
- * - * + * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -166,11 +166,11 @@ public class Api { /** * Gets the value of the meth property. - * + * * @return * possible object is * {@link String } - * + * */ public String getMeth() { return meth; @@ -178,11 +178,11 @@ public class Api { /** * Sets the value of the meth property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setMeth(String value) { this.meth = value; @@ -190,11 +190,11 @@ public class Api { /** * Gets the value of the path property. - * + * * @return * possible object is * {@link String } - * + * */ public String getPath() { return path; @@ -202,11 +202,11 @@ public class Api { /** * Sets the value of the path property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setPath(String value) { this.path = value; @@ -214,25 +214,25 @@ public class Api { /** * Gets the value of the param property. - * - *

+ * + * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the param property. - * - *

+ * + * * For example, to add a new item, do as follows: *

          *    getParam().add(newItem);
          * 
- * - * - *

+ * + * + * * Objects of the following type(s) are allowed in the list * {@link String } - * - * + * + * */ public List getParam() { if (param == null) { @@ -243,11 +243,11 @@ public class Api { /** * Gets the value of the desc property. - * + * * @return * possible object is * {@link String } - * + * */ public String getDesc() { return desc; @@ -255,11 +255,11 @@ public class Api { /** * Sets the value of the desc property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setDesc(String value) { this.desc = value; @@ -267,25 +267,25 @@ public class Api { /** * Gets the value of the comments property. - * - *

+ * + * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the comments property. - * - *

+ * + * * For example, to add a new item, do as follows: *

          *    getComments().add(newItem);
          * 
- * - * - *

+ * + * + * * Objects of the following type(s) are allowed in the list * {@link String } - * - * + * + * */ public List getComments() { if (comments == null) { @@ -296,25 +296,25 @@ public class Api { /** * Gets the value of the contentType property. - * - *

+ * + * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the contentType property. - * - *

+ * + * * For example, to add a new item, do as follows: *

          *    getContentType().add(newItem);
          * 
- * - * - *

+ * + * + * * Objects of the following type(s) are allowed in the list * {@link String } - * - * + * + * */ public List getContentType() { if (contentType == null) { @@ -325,7 +325,7 @@ public class Api { /** * Gets the value of the expected property. - * + * */ public int getExpected() { return expected; @@ -333,7 +333,7 @@ public class Api { /** * Sets the value of the expected property. - * + * */ public void setExpected(int value) { this.expected = value; @@ -341,25 +341,25 @@ public class Api { /** * Gets the value of the explicitErr property. - * - *

+ * + * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the explicitErr property. - * - *

+ * + * * For example, to add a new item, do as follows: *

          *    getExplicitErr().add(newItem);
          * 
- * - * - *

+ * + * + * * Objects of the following type(s) are allowed in the list * {@link Integer } - * - * + * + * */ public List getExplicitErr() { if (explicitErr == null) { diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java index 9ab3b258..0d942e09 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java @@ -7,9 +7,9 @@ * 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. @@ -58,21 +58,21 @@ public class JU_RosettaData { @Mock Env env; - + @Mock RosettaDF df; - + @Mock JAXBmar bmar; - + @Mock Saved saved; - + @Before public void setUp() { initMocks(this); } - + @Test public void testLoad() { RosettaData rosettaObj = new RosettaData(env, df); @@ -84,14 +84,14 @@ public class JU_RosettaData { Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(sr,(Writer)null,inxml); - + rosettaObj = rosettaObj.load(sr); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testLoadException() { RosettaData rosettaObj = new RosettaData(env, df); @@ -105,7 +105,7 @@ public class JU_RosettaData { assertTrue(e.getMessage().contains("NullPointerException")); } } - + @Test public void testLoadIs() { RosettaData rosettaObj = new RosettaData(env, df); @@ -117,14 +117,14 @@ public class JU_RosettaData { Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new InputStreamReader(sr),(Writer)null,inxml); - + rosettaObj = rosettaObj.load(sr); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testLoadIsException() { RosettaData rosettaObj = new RosettaData(env, df); @@ -138,7 +138,7 @@ public class JU_RosettaData { assertTrue(e.getMessage().contains("NullPointerException")); } } - + @Test public void testLoadStr() { RosettaData rosettaObj = new RosettaData(env, df); @@ -149,7 +149,7 @@ public class JU_RosettaData { Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block @@ -166,7 +166,7 @@ public class JU_RosettaData { Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block @@ -186,7 +186,7 @@ public class JU_RosettaData { assertTrue(e.getMessage().contains("NullPointerException")); } } - + @Test public void testLoadT() { RosettaData rosettaObj = new RosettaData(env, df); @@ -198,7 +198,7 @@ public class JU_RosettaData { df.jaxMar = Mockito.mock(JAXBmar.class); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load(bmar); df.marshal = null; rosettaObj = rosettaObj.load(bmar); @@ -207,7 +207,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testLoadTMarshalNull() { RosettaData rosettaObj = new RosettaData(env, df); @@ -226,7 +226,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testLoadTException() { RosettaData rosettaObj = new RosettaData(env, df); @@ -240,14 +240,14 @@ public class JU_RosettaData { assertTrue(e.getMessage().contains("NullPointerException")); } } - + @Test public void testGetEvents() { RosettaData rosettaObj = new RosettaData(env, df); Saved saved = rosettaObj.getEvents(); assertEquals("Rosetta Saved", saved.logName()); } - + @Test public void testAsObject() { RosettaData rosettaObj = new RosettaData(env, df); @@ -265,15 +265,15 @@ public class JU_RosettaData { Mockito.doReturn( lt).when(env).debug(); Mockito.doNothing().when(saved).extract(null,new StringWriter(),saved); Mockito.doReturn(bmar).when(df.jaxUmar).unmarshal(lt,""); - + bmar = rosettaObj.asObject(); - + } catch (APIException | IOException | ParseException | JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testAsObjectException() { RosettaData rosettaObj = new RosettaData(env, df); @@ -291,9 +291,9 @@ public class JU_RosettaData { Mockito.doReturn( lt).when(env).debug(); Mockito.doThrow(new IOException("test Exception")).when(saved).extract(null,new StringWriter(),saved); Mockito.doThrow(new JAXBException("test Exception")).when(df.jaxUmar).unmarshal(lt,""); - + bmar = rosettaObj.asObject(); - + } catch (APIException | IOException | ParseException | JAXBException e) { assertTrue(e.getMessage().contains("test Exception")); } @@ -308,12 +308,12 @@ public class JU_RosettaData { rosettaObj.setSaved(saved); try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - + String retVal = rosettaObj.asString(); assertTrue("".equals(retVal)); } catch (APIException e) { @@ -321,7 +321,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testAsStringJson() { TYPE type = TYPE.JSON; @@ -331,12 +331,12 @@ public class JU_RosettaData { rosettaObj.setSaved(saved); try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); - + String retVal = rosettaObj.asString(); assertTrue("".equals(retVal)); } catch (APIException e) { @@ -351,34 +351,34 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.XML); rosettaObj.setSaved(saved); - + try { InXML inxml = Mockito.mock(InXML.class); Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); RosettaData retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testToJson() { TYPE type = TYPE.JSON; @@ -386,34 +386,34 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.JSON); rosettaObj.setSaved(saved); - + try { InXML inxml = Mockito.mock(InXML.class); Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); RosettaData retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testTo() { TYPE type = TYPE.XML; @@ -421,22 +421,22 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.XML); rosettaObj.setSaved(saved); - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); RosettaData retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testToWriterXml() { TYPE type = TYPE.XML; @@ -444,34 +444,34 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.XML); rosettaObj.setSaved(saved); - + try { InXML inxml = Mockito.mock(InXML.class); Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); RosettaData retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testToWriterJson() { TYPE type = TYPE.JSON; @@ -479,34 +479,34 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.JSON); rosettaObj.setSaved(saved); - + try { InXML inxml = Mockito.mock(InXML.class); Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - + rosettaObj = rosettaObj.load("test"); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); RosettaData retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testToWriter() { TYPE type = TYPE.XML; @@ -514,28 +514,28 @@ public class JU_RosettaData { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj = rosettaObj.in(Data.TYPE.XML); rosettaObj.setSaved(saved); - + try { Out outxml = Mockito.mock(OutXML.class); - + Mockito.doReturn(outxml).when(df).getOut(type); Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); RosettaData retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - + } catch (APIException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + @Test public void testGetTypeClass() { RosettaData rosettaObj = new RosettaData(env, df); rosettaObj.getTypeClass(); } - + @Test public void testDirect() { TYPE type = TYPE.XML; @@ -553,7 +553,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testDirectException() { TYPE type = TYPE.XML; @@ -561,11 +561,11 @@ public class JU_RosettaData { Mockito.doReturn(type).when(df).getInType(); RosettaData rosettaObj = new RosettaData(env, df); InXML inxml = null; - + inxml = Mockito.mock(InXML.class); Mockito.doReturn(inxml).when(df).getIn(type); - - + + StringReader is = Mockito.mock(StringReader.class); StringWriter os= Mockito.mock(StringWriter.class); try { @@ -575,14 +575,14 @@ public class JU_RosettaData { Mockito.doReturn("test").when(outxml).logName(); Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); Mockito.doThrow( new IOException("testException")).when(outxml).extract(is, os, inxml, true); - + rosettaObj.direct(is,os, true); } catch (APIException | IOException | ParseException e) { // TODO Auto-generated catch block assertTrue(e.getMessage().contains("testException")); } } - + @Test public void testDirectT() { TYPE type = TYPE.XML; @@ -599,7 +599,7 @@ public class JU_RosettaData { LogTarget lt = Mockito.mock(LogTarget.class); Mockito.doReturn( lt).when(env).debug(); Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - + rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); df.marshal =Mockito.mock(Marshal.class);; rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); @@ -608,7 +608,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testDirectTOS() { TYPE type = TYPE.XML; @@ -625,7 +625,7 @@ public class JU_RosettaData { LogTarget lt = Mockito.mock(LogTarget.class); Mockito.doReturn( lt).when(env).debug(); Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - + rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); df.marshal =Mockito.mock(Marshal.class);; rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); @@ -634,7 +634,7 @@ public class JU_RosettaData { e.printStackTrace(); } } - + @Test public void testDirectTOSJson() { TYPE type = TYPE.JSON; @@ -651,13 +651,13 @@ public class JU_RosettaData { LogTarget lt = Mockito.mock(LogTarget.class); Mockito.doReturn( lt).when(env).debug(); Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - + rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); } catch (APIException | IOException | JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } } - + } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java index c8771519..631abc00 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java @@ -7,9 +7,9 @@ * 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. @@ -45,7 +45,7 @@ public class JU_RosettaEnv { public void setUp() { initMocks(this); } - + @Test public void testNewDataFactoryClass() { RosettaEnv rosettaObj = new RosettaEnv(); @@ -57,7 +57,7 @@ public class JU_RosettaEnv { e.printStackTrace(); } } - + @Test public void testNewDataFactorySchema() { RosettaEnv rosettaObj = new RosettaEnv(Mockito.mock(Applet.class),"test"); @@ -69,7 +69,7 @@ public class JU_RosettaEnv { e.printStackTrace(); } } - + @Test public void testNewDataFactoryQname() { RosettaEnv rosettaObj = new RosettaEnv(new String[] {"test"}); @@ -82,7 +82,7 @@ public class JU_RosettaEnv { e.printStackTrace(); } } - + @Test public void testNewDataFactoryQnameSchema() { RosettaEnv rosettaObj = new RosettaEnv("test", new String[] {"test"}); diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java index 5b7875f7..a7f8f115 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java @@ -7,9 +7,9 @@ * 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. @@ -38,7 +38,7 @@ public class JU_FieldBlob { // TODO Auto-generated method stub return null; } - + } @Test public void testData() { 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 67565122..d36862e8 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 @@ -7,9 +7,9 @@ * 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. @@ -58,18 +58,18 @@ public class JU_FromJSON { 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 ***"); @@ -91,21 +91,21 @@ public class JU_FromJSON { } 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"); @@ -121,7 +121,7 @@ public class JU_FromJSON { } report.glean(trans,Env.JSON); } while (report.go()); - + report.report(sbw); System.out.println(sbw.toString()); } @@ -132,7 +132,7 @@ public class JU_FromJSON { 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"); @@ -148,7 +148,7 @@ public class JU_FromJSON { } report.glean(trans,Env.JSON); } while (report.go()); - + report.report(sbw); System.out.println(sbw.toString()); } @@ -160,7 +160,7 @@ public class JU_FromJSON { 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"); @@ -176,12 +176,12 @@ public class JU_FromJSON { } 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 ***"); @@ -200,7 +200,7 @@ public class JU_FromJSON { 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); @@ -219,7 +219,7 @@ public class JU_FromJSON { } report.glean(trans,Env.XML); } while (report.go()); - + report.report(sbw); System.out.println(sbw.toString()); } @@ -242,7 +242,7 @@ public class JU_FromJSON { 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); 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 4fefe622..1a10779b 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 @@ -7,9 +7,9 @@ * 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. @@ -45,8 +45,8 @@ import s.xsd.LargerData; public class JU_FromXML { private static int ITERATIONS = 1; ; - - private final static String xml = + + private final static String xml = "\n" + "\n" + " \n" + @@ -63,21 +63,21 @@ public class JU_FromXML { " \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 { @@ -86,7 +86,7 @@ public class JU_FromXML { InXML inXML = new InXML(LargerData.class); StringBuilderWriter sbw = new StringBuilderWriter(1024); - + Trans trans; Report report = new Report(ITERATIONS,"XML"); do { @@ -101,7 +101,7 @@ public class JU_FromXML { } report.glean(trans,Env.XML); } while (report.go()); - + report.report(sbw); System.out.println(sbw.toString()); } @@ -113,7 +113,7 @@ public class JU_FromXML { InXML inXML = new InXML(LargerData.class); StringBuilderWriter sbw = new StringBuilderWriter(1024); - + Trans trans; Report report = new Report(ITERATIONS,"XML"); do { @@ -128,23 +128,23 @@ public class JU_FromXML { } 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; @@ -171,7 +171,7 @@ public class JU_FromXML { } report.glean(trans,Env.XML); } while (report.go()); - + report.report(sbw); System.out.println(sbw.toString()); } @@ -210,7 +210,7 @@ public class JU_FromXML { } report.glean(trans,Env.XML); } 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_JSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java index af58ea57..4e9bfdc5 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 @@ -7,9 +7,9 @@ * 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. @@ -44,7 +44,7 @@ public class JU_JSON { 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}"); @@ -52,16 +52,16 @@ public class JU_JSON { "{\"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() //"xk32331353082669667"); - + // 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\"}"); @@ -74,8 +74,8 @@ public class JU_JSON { 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\"]}"); - + + ",\"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 @@ -87,8 +87,8 @@ public class JU_JSON { ),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 + + // 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\"}]}"); @@ -96,33 +96,33 @@ public class JU_JSON { 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 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); 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 fd6142b1..335d87ad 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 @@ -7,9 +7,9 @@ * 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. @@ -31,7 +31,7 @@ public class JU_Ladder { @Test public void test() { Ladder ladder = new Ladder(); - + for (int i=0;i<30;++i) { for (int j=0;j { 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 { @@ -67,7 +67,7 @@ public class JU_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); @@ -78,7 +78,7 @@ public class JU_Saved { } finally { tt.done(); } - + sbw.append("\n==== Start XML =====\n"); tt = trans.start("XML", 3); try { @@ -86,7 +86,7 @@ public class JU_Saved { } finally { tt.done(); } - + sbw.append("\n==== Start JSON =====\n"); tt = trans.start("JSON", 4); try { @@ -96,7 +96,7 @@ public class JU_Saved { } 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 b0fc29a2..a3c4f181 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 @@ -7,9 +7,9 @@ * 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. @@ -57,7 +57,7 @@ public class JU_Stream2Obj { value_2 - + {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]} */ @@ -69,7 +69,7 @@ public class JU_Stream2Obj { da.setShortName("mda_1"); da.getValue().add("value_1"); da.getValue().add("value_2"); - + Root root = new Root(); root.getBase().add(da); @@ -80,10 +80,10 @@ public class JU_Stream2Obj { 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); @@ -95,21 +95,21 @@ public class JU_Stream2Obj { 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(); 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 40c41596..1a366fa0 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 @@ -7,9 +7,9 @@ * 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. @@ -42,7 +42,7 @@ public class JU_Struct { "\n" + "MyFluff\n" + "\n"; - + // @Test // public void test2() throws Exception { // @@ -50,20 +50,20 @@ public class JU_Struct { // 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); 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 2aca5f52..550e2566 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 @@ -7,9 +7,9 @@ * 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. @@ -55,18 +55,18 @@ public class JU_Types { 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); @@ -92,7 +92,7 @@ public class JU_Types { // xml.extract(single, sw, psingle, true); news = jumar.unmarshal(env.info(), sw.toString()); System.out.println(sw.toString()); - + String sample = "" + "\n" + "\nMyString" @@ -110,7 +110,7 @@ public class JU_Types { System.out.println(news.getDatetime()); } - + @Test public void multi() throws Exception { OutRaw raw = new OutRaw(); @@ -119,7 +119,7 @@ public class JU_Types { Multi multi = new Multi(); MultiMarshal pmulti = new MultiMarshal(); - + for (int i=0;i<10;++i) { System.out.println("===== Multi Iteration " + i + " ====="); if (i>0) { @@ -127,16 +127,16 @@ public class JU_Types { } 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); } @@ -150,7 +150,7 @@ public class JU_Types { 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) { @@ -158,16 +158,16 @@ public class JU_Types { } 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); } @@ -179,16 +179,16 @@ public class JU_Types { // 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(); @@ -199,7 +199,7 @@ public class JU_Types { } trans = env.newTrans(); data = df.newData(trans); - + int iters = 10000; for (int i=0;i 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); 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 7e230822..e5035dbf 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 @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,7 @@ public class OutDump extends Out{ 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: @@ -45,7 +45,7 @@ public class OutDump extends Out{ ipw.append(p.name); ipw.inc(); break; - case Parse.END_OBJ: + case Parse.END_OBJ: printData(ipw,p); ipw.dec(); ipw.append("End Object "); @@ -57,7 +57,7 @@ public class OutDump extends Out{ ipw.append(p.name); ipw.append('\n'); break; - case Parse.END_ARRAY: + case Parse.END_ARRAY: printData(ipw,p); ipw.dec(); ipw.append("End Array "); @@ -69,13 +69,13 @@ public class OutDump extends Out{ } } } - + private void printData(IndentPrintWriter ipw, Parsed parsed) { if (parsed.hasData()) { ipw.append("Data:["); if (parsed.hasName()) { ipw.append(parsed.name); - ipw.append(" : "); + ipw.append(" : "); } ipw.append(parsed.sb); ipw.append("]"); 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 acb33010..dc07ae63 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 @@ -7,9 +7,9 @@ * 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. @@ -33,7 +33,7 @@ public class Report { String[] names; private int iterations; private int count; - + public Report(int iters, String ... names) { iterations = iters; buckets = new float[names.length]; @@ -41,7 +41,7 @@ public class Report { total=0; count = 0; } - + public void glean(Trans trans, int ... type) { Metric m = trans.auditTrail(0, null, type); total+=m.total; @@ -50,12 +50,12 @@ public class Report { buckets[b]+=m.buckets[b]; } } - + public boolean go() { return ++count { 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) { @@ -72,14 +72,14 @@ public class SingleMarshal extends ObjMarshal { 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) { -- cgit 1.2.3-korg