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 public class JU_AAF_FS {
58 private static final String testDir = "src/test/resources/logs";
59 private ByteArrayOutputStream outStream;
60 private ByteArrayOutputStream errStream;
64 public void setUp() throws APIException, IOException, CadiException {
65 outStream = new ByteArrayOutputStream();
66 errStream = new ByteArrayOutputStream();
67 System.setOut(new PrintStream(outStream));
68 System.setErr(new PrintStream(errStream));
69 value = System.setProperty(Config.CADI_LOGDIR, testDir);
70 System.setProperty(Config.CADI_ETCDIR, testDir);
71 System.out.println(ClassLoader.getSystemResource("org.osaaf.aaf.log4j.props"));
72 d = new File(testDir);
74 fService = new File(d +"/fs-serviceTEST.log");
75 fService.createNewFile();
76 fEtc = new File(d + "/org.osaaf.aaf.log4j.props");
79 aEnv = new AuthzEnv();
80 aEnv.staticSlot("test");
81 aEnv.access().setProperty("aaf_public_dir", "test");
82 aEnv.access().setProperty(Config.AAF_COMPONENT, "aaf_com:1.1");
83 Server serverMock = mock(Server.class);
84 JettyServiceStarter<AuthzEnv,AuthzTrans> jssMock = mock(JettyServiceStarter.class);
85 aafFs = new AAF_FS(aEnv);
86 aEnv.access().setProperty(Config.AAF_LOCATE_URL, "aaf_loc:ate.url");
87 aafFs = new AAF_FS(aEnv);
91 public void testRegistrants() throws CadiException, LocatorException {
93 aEnv.access().setProperty(Config.AAF_URL, "www.google.com");
94 aEnv.access().setProperty(Config.CADI_LATITUDE, "38.550674");
95 aEnv.access().setProperty(Config.CADI_LONGITUDE, "-90.146942");
96 aEnv.access().setProperty(Config.AAF_LOCATE_URL, "testLocateUrl");
97 aEnv.access().setProperty(Config.HOSTNAME, "testHost");
99 // Doesn't work within Jenkins
100 // aafFs.registrants(port);
104 public void testFilters() throws CadiException, LocatorException {
109 public void testMain() {
110 System.setProperty("cadi_exitOnFailure", "false");
112 String[] strArr = {"aaf_component=aaf_com:po.nent"};
114 //AAF_FS.main(strArr); //Timeout caused in Jenkins but not in local
115 } catch(Exception e) {
116 //Failure expected until we understand how code is.
121 public void cleanUp() {
122 for(File f : d.listFiles()) {
126 System.setErr(System.err);
127 System.setOut(System.out);