9368d4d776bd78b11e3328f4caf6f8402d35b946
[aaf/authz.git] / auth / auth-fs / src / test / java / org / onap / aaf / auth / fs / test / JU_AAF_FS.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.auth.fs.test;
23
24 import static org.junit.Assert.*;
25
26 import org.onap.aaf.auth.env.AuthzEnv;
27 import org.onap.aaf.auth.fs.AAF_FS;
28 import org.onap.aaf.auth.rserv.CachingFileAccess;
29 import org.onap.aaf.cadi.Access;
30 import org.onap.aaf.cadi.CadiException;
31 import org.onap.aaf.cadi.config.Config;
32 import org.onap.aaf.misc.env.APIException;
33 import org.onap.aaf.misc.env.Slot;
34 import org.onap.aaf.misc.env.StaticSlot;
35 import org.junit.After;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.mockito.Mock;
39 import org.mockito.Mockito;
40 import static org.mockito.Mockito.*;
41
42 import java.io.File;
43 import java.io.IOException;
44
45 import org.junit.Test;
46
47 public class JU_AAF_FS {
48         AuthzEnv aEnv;
49         AAF_FS aafFs;
50         File fService;
51         File fEtc;
52         String value;
53         File d;
54         private static final String testDir = "src/test/resources/logs";
55         
56         @Before
57         public void setUp() throws APIException, IOException, CadiException {
58                 value = System.setProperty(Config.CADI_LOGDIR, testDir);
59                 System.setProperty(Config.CADI_ETCDIR, testDir);
60                 System.out.println(ClassLoader.getSystemResource("org.osaaf.log4j.props"));
61                 d = new File(testDir);
62                 d.mkdirs();
63                 fService = new File(d +"/fs-serviceTEST.log");
64                 fService.createNewFile();
65                 fEtc = new File(d + "/org.osaaf.log4j.props");
66                 fEtc.createNewFile();
67                 
68                 aEnv = new AuthzEnv();
69                 aEnv.staticSlot("test");
70                 aEnv.access().setProperty("aaf_public_dir", "test");
71                 aEnv.access().setProperty(Config.AAF_COMPONENT, "aaf_com:po.nent");
72                 aafFs = new AAF_FS(aEnv);
73                 
74         }
75
76         @Test
77         public void testMain() {
78                 String[] strArr = {"AAF_LOG4J_PREFIX"};
79                 
80                 aafFs.main(strArr);
81         }
82         
83         @After
84         public void cleanUp() {
85                 for(File f : d.listFiles()) {
86                         f.delete();
87                 }
88                 d.delete();
89         }
90
91 }