2 * ============LICENSE_START====================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
22 package org.onap.aaf.auth.fs.test;
24 import static org.junit.Assert.*;
26 import org.onap.aaf.auth.env.AuthzEnv;
27 import org.onap.aaf.auth.env.AuthzTrans;
28 import org.onap.aaf.auth.fs.AAF_FS;
29 import org.onap.aaf.auth.rserv.CachingFileAccess;
30 import org.onap.aaf.auth.server.JettyServiceStarter;
31 import org.onap.aaf.cadi.Access;
32 import org.onap.aaf.cadi.CadiException;
33 import org.onap.aaf.cadi.LocatorException;
34 import org.onap.aaf.cadi.config.Config;
35 import org.onap.aaf.misc.env.APIException;
36 import org.onap.aaf.misc.env.Slot;
37 import org.onap.aaf.misc.env.StaticSlot;
38 import org.eclipse.jetty.server.Server;
39 import org.junit.After;
40 import org.junit.Before;
41 import org.junit.Test;
42 import org.mockito.Mock;
43 import org.mockito.Mockito;
44 import static org.mockito.Mockito.*;
46 import java.io.ByteArrayOutputStream;
48 import java.io.IOException;
49 import java.io.PrintStream;
51 import org.junit.Test;
53 public class JU_AAF_FS {
60 private static final String testDir = "src/test/resources/logs";
61 private ByteArrayOutputStream outStream;
62 private ByteArrayOutputStream errStream;
66 public void setUp() throws APIException, IOException, CadiException {
67 outStream = new ByteArrayOutputStream();
68 errStream = new ByteArrayOutputStream();
69 System.setOut(new PrintStream(outStream));
70 System.setErr(new PrintStream(errStream));
71 value = System.setProperty(Config.CADI_LOGDIR, testDir);
72 System.setProperty(Config.CADI_ETCDIR, testDir);
73 System.out.println(ClassLoader.getSystemResource("org.osaaf.log4j.props"));
74 d = new File(testDir);
76 fService = new File(d +"/fs-serviceTEST.log");
77 fService.createNewFile();
78 fEtc = new File(d + "/org.osaaf.log4j.props");
81 aEnv = new AuthzEnv();
82 aEnv.staticSlot("test");
83 aEnv.access().setProperty("aaf_public_dir", "test");
84 aEnv.access().setProperty(Config.AAF_COMPONENT, "aaf_com:1.1");
85 Server serverMock = mock(Server.class);
86 JettyServiceStarter<AuthzEnv,AuthzTrans> jssMock = mock(JettyServiceStarter.class);
87 aafFs = new AAF_FS(aEnv);
88 aEnv.access().setProperty(Config.AAF_LOCATE_URL, "aaf_loc:ate.url");
89 aafFs = new AAF_FS(aEnv);
93 public void testRegistrants() throws CadiException, LocatorException {
95 aEnv.access().setProperty(Config.AAF_URL, "www.google.com");
96 aEnv.access().setProperty(Config.CADI_LATITUDE, "38.550674");
97 aEnv.access().setProperty(Config.CADI_LONGITUDE, "-90.146942");
98 aEnv.access().setProperty(Config.AAF_LOCATE_URL, "testLocateUrl");
99 aEnv.access().setProperty(Config.HOSTNAME, "testHost");
101 aafFs.registrants(port);
105 public void testFilters() throws CadiException, LocatorException {
110 public void testMain() {
111 System.setProperty("cadi_exitOnFailure", "false");
113 String[] strArr = {"aaf_component=aaf_com:po.nent"};
115 //AAF_FS.main(strArr); //Timeout caused in Jenkins but not in local
116 } catch(Exception e) {
117 //Failure expected until we understand how code is.
122 public void cleanUp() {
123 for(File f : d.listFiles()) {
127 System.setErr(System.err);
128 System.setOut(System.out);