AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / authz-defOrg / src / test / java / org / onap / aaf / osaaf / defOrg / JU_Identities.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * ===========================================================================\r
7  * * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * * you may not use this file except in compliance with the License.\r
9  * * You may obtain a copy of the License at\r
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \r
13  *  * Unless required by applicable law or agreed to in writing, software\r
14  * * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * * See the License for the specific language governing permissions and\r
17  * * limitations under the License.\r
18  * * ============LICENSE_END====================================================\r
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 /**\r
24  * \r
25  */\r
26 package org.onap.aaf.osaaf.defOrg;\r
27 \r
28 import java.io.File;\r
29 import java.io.IOException;\r
30 \r
31 import org.junit.After;\r
32 import org.junit.AfterClass;\r
33 import org.junit.Assert;\r
34 import org.junit.Before;\r
35 import org.junit.BeforeClass;\r
36 import org.junit.Test;\r
37 import org.onap.aaf.authz.env.AuthzEnv;\r
38 import org.onap.aaf.authz.env.AuthzTrans;\r
39 import org.onap.aaf.authz.local.AbsData.Reuse;\r
40 import org.onap.aaf.osaaf.defOrg.Identities;\r
41 import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
42 \r
43 /**\r
44  *\r
45  */\r
46 public class JU_Identities {\r
47 \r
48         private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat";\r
49         private static File fids;\r
50         private static Identities ids;\r
51         private static AuthzEnv env;\r
52 \r
53         /**\r
54          * @throws java.lang.Exception\r
55          */\r
56         @BeforeClass\r
57         public static void setUpBeforeClass() throws Exception {\r
58                 env = new AuthzEnv();\r
59                 AuthzTrans trans = env.newTransNoAvg();\r
60                 // Note: utilize TimeTaken, from trans.start if you want to time.\r
61                 fids = new File(DATA_IDENTITIES);\r
62                 if(fids.exists()) {\r
63                         ids = new Identities(fids);\r
64                         ids.open(trans, 5000);\r
65                 } else {\r
66                         \r
67                         throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES \r
68                                         + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")");\r
69                 }\r
70         }\r
71 \r
72         /**\r
73          * @throws java.lang.Exception\r
74          */\r
75         @AfterClass\r
76         public static void tearDownAfterClass() throws Exception {\r
77                 AuthzTrans trans = env.newTransNoAvg();\r
78                 if(ids!=null) {\r
79                         ids.close(trans);\r
80                 }\r
81         }\r
82 \r
83         /**\r
84          * @throws java.lang.Exception\r
85          */\r
86         @Before\r
87         public void setUp() throws Exception {\r
88         }\r
89 \r
90         /**\r
91          * @throws java.lang.Exception\r
92          */\r
93         @After\r
94         public void tearDown() throws Exception {\r
95         }\r
96  \r
97         @Test\r
98         public void test() throws IOException {\r
99                 Reuse reuse = ids.reuse(); // this object can be reused within the same thread.\r
100                 Data id = ids.find("osaaf",reuse);\r
101                 Assert.assertNotNull(id);\r
102                 System.out.println(id);\r
103 \r
104                 id = ids.find("mmanager",reuse);\r
105                 Assert.assertNotNull(id);\r
106                 System.out.println(id);\r
107 \r
108                 //TODO Fill out JUnit with Tests of all Methods in "Data id"\r
109         }\r
110 \r
111 }\r