Update project structure to org.onap.aaf
[aaf/authz.git] / authz-defOrg / src / test / java / org / onap / aaf / osaaf / defOrg / JU_Identities.java
diff --git a/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java b/authz-defOrg/src/test/java/org/onap/aaf/osaaf/defOrg/JU_Identities.java
new file mode 100644 (file)
index 0000000..78551c0
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 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
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+/**\r
+ * \r
+ */\r
+package org.onap.aaf.osaaf.defOrg;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import org.junit.After;\r
+import org.junit.AfterClass;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.onap.aaf.authz.env.AuthzEnv;\r
+import org.onap.aaf.authz.env.AuthzTrans;\r
+import org.onap.aaf.authz.local.AbsData.Reuse;\r
+import org.onap.aaf.osaaf.defOrg.Identities;\r
+import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
+\r
+/**\r
+ *\r
+ */\r
+public class JU_Identities {\r
+\r
+       private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat";\r
+       private static File fids;\r
+       private static Identities ids;\r
+       private static AuthzEnv env;\r
+\r
+       /**\r
+        * @throws java.lang.Exception\r
+        */\r
+       @BeforeClass\r
+       public static void setUpBeforeClass() throws Exception {\r
+               env = new AuthzEnv();\r
+               AuthzTrans trans = env.newTransNoAvg();\r
+               // Note: utilize TimeTaken, from trans.start if you want to time.\r
+               fids = new File(DATA_IDENTITIES);\r
+               if(fids.exists()) {\r
+                       ids = new Identities(fids);\r
+                       ids.open(trans, 5000);\r
+               } else {\r
+                       \r
+                       throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES \r
+                                       + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @throws java.lang.Exception\r
+        */\r
+       @AfterClass\r
+       public static void tearDownAfterClass() throws Exception {\r
+               AuthzTrans trans = env.newTransNoAvg();\r
+               if(ids!=null) {\r
+                       ids.close(trans);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @throws java.lang.Exception\r
+        */\r
+       @Before\r
+       public void setUp() throws Exception {\r
+       }\r
+\r
+       /**\r
+        * @throws java.lang.Exception\r
+        */\r
+       @After\r
+       public void tearDown() throws Exception {\r
+       }\r
\r
+       @Test\r
+       public void test() throws IOException {\r
+               Reuse reuse = ids.reuse(); // this object can be reused within the same thread.\r
+               Data id = ids.find("osaaf",reuse);\r
+               Assert.assertNotNull(id);\r
+               System.out.println(id);\r
+\r
+               id = ids.find("mmanager",reuse);\r
+               Assert.assertNotNull(id);\r
+               System.out.println(id);\r
+\r
+               //TODO Fill out JUnit with Tests of all Methods in "Data id"\r
+       }\r
+\r
+}\r