Adding more testcases to Misc xgen
[aaf/authz.git] / misc / xgen / src / test / java / org / onap / aaf / misc / xgen / xml / JU_XMLGenTest.java
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/xml/JU_XMLGenTest.java
new file mode 100644 (file)
index 0000000..2dbc422
--- /dev/null
@@ -0,0 +1,66 @@
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+\r
+package org.onap.aaf.misc.xgen.xml;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.times;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+\r
+public class JU_XMLGenTest {\r
+\r
+       @Mock\r
+       private Writer writer;\r
+\r
+       String XML_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";\r
+\r
+       Map<Character, Integer> map = new TreeMap<Character, Integer>();\r
+\r
+       @Before\r
+       public void setUp() throws Exception {\r
+               writer = mock(Writer.class);\r
+       }\r
+\r
+       @Test\r
+       public void testXMLGenWriter() throws IOException {\r
+               XMLGen xmlGen = new XMLGen(writer);\r
+\r
+               xmlGen.xml();\r
+\r
+               for (char ch : XML_TAG.toCharArray()) {\r
+                       Integer times = map.get(ch);\r
+                       map.put(ch, (times == null ? 0 : times) + 1);\r
+               }\r
+\r
+               for (char ch : map.keySet()) {\r
+                       verify(writer, times(map.get(ch))).write(ch);\r
+               }\r
+       }\r
+}
\ No newline at end of file