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