Update AAF Version 1.0.0
[aaf/authz.git] / authz-defOrg / src / test / java / com / 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 com.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 \r
38 import com.att.authz.env.AuthzEnv;\r
39 import com.att.authz.env.AuthzTrans;\r
40 import com.att.authz.local.AbsData.Reuse;\r
41 import com.osaaf.defOrg.Identities;\r
42 import com.osaaf.defOrg.Identities.Data;\r
43 \r
44 /**\r
45  *\r
46  */\r
47 public class JU_Identities {\r
48 \r
49         private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat";\r
50         private static File fids;\r
51         private static Identities ids;\r
52         private static AuthzEnv env;\r
53 \r
54         /**\r
55          * @throws java.lang.Exception\r
56          */\r
57         @BeforeClass\r
58         public static void setUpBeforeClass() throws Exception {\r
59                 env = new AuthzEnv();\r
60                 AuthzTrans trans = env.newTransNoAvg();\r
61                 // Note: utilize TimeTaken, from trans.start if you want to time.\r
62                 fids = new File(DATA_IDENTITIES);\r
63                 if(fids.exists()) {\r
64                         ids = new Identities(fids);\r
65                         ids.open(trans, 5000);\r
66                 } else {\r
67                         \r
68                         throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES \r
69                                         + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")");\r
70                 }\r
71         }\r
72 \r
73         /**\r
74          * @throws java.lang.Exception\r
75          */\r
76         @AfterClass\r
77         public static void tearDownAfterClass() throws Exception {\r
78                 AuthzTrans trans = env.newTransNoAvg();\r
79                 if(ids!=null) {\r
80                         ids.close(trans);\r
81                 }\r
82         }\r
83 \r
84         /**\r
85          * @throws java.lang.Exception\r
86          */\r
87         @Before\r
88         public void setUp() throws Exception {\r
89         }\r
90 \r
91         /**\r
92          * @throws java.lang.Exception\r
93          */\r
94         @After\r
95         public void tearDown() throws Exception {\r
96         }\r
97  \r
98         @Test\r
99         public void test() throws IOException {\r
100                 Reuse reuse = ids.reuse(); // this object can be reused within the same thread.\r
101                 Data id = ids.find("osaaf",reuse);\r
102                 Assert.assertNotNull(id);\r
103                 System.out.println(id);\r
104 \r
105                 id = ids.find("mmanager",reuse);\r
106                 Assert.assertNotNull(id);\r
107                 System.out.println(id);\r
108 \r
109                 //TODO Fill out JUnit with Tests of all Methods in "Data id"\r
110         }\r
111 \r
112 }\r