changed to unmaintained
[aaf/authz.git] / cadi / aaf / src / test / java / org / onap / aaf / cadi / cm / test / JU_CmAgent.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
4  * * ===========================================================================
5  * * Copyright © 2017 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
23 package org.onap.aaf.cadi.cm.test;
24
25 import java.io.ByteArrayInputStream;
26 import java.io.File;
27
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.aaf.cadi.configure.Agent;
32
33 public class JU_CmAgent {
34
35     private static final String resourceDirString = "src/test/resources";
36     private static final String aafDir = resourceDirString + "/aaf";
37
38     private ByteArrayInputStream inStream;
39
40     @Before
41     public void setup() {
42         System.setProperty("user.home", aafDir);
43
44         // Simulate user input
45         inStream = new ByteArrayInputStream("test\nhttp://example.com\nhttp://example.com".getBytes());
46         System.setIn(inStream);
47     }
48
49     @After
50     public void tearDown() {
51         recursiveDelete(new File(aafDir));
52     }
53
54     @Test
55     public void test() {
56         String[] args;
57         args = new String[] {
58                 "-login",
59                 "-noExit",
60         };
61         Agent.main(args);
62
63         inStream.reset();
64         args = new String[] {
65                 "-noExit",
66         };
67         Agent.main(args);
68
69         inStream.reset();
70         args = new String[] {
71                 "place",
72                 "-noExit",
73         };
74         // Can't do actual connections on JUnit
75 //        Agent.main(args);
76
77         inStream.reset();
78         args = new String[] {
79                 "-noExit",
80                 "create"
81         };
82         Agent.main(args);
83
84         inStream.reset();
85         args = new String[] {
86                 "-noExit",
87                 "read"
88         };
89 //        Agent.main(args);
90
91         inStream.reset();
92         args = new String[] {
93                 "-noExit",
94                 "copy"
95         };
96 //        Agent.main(args);
97
98         inStream.reset();
99         args = new String[] {
100                 "-noExit",
101                 "update"
102         };
103 //        Agent.main(args);
104
105         inStream.reset();
106         args = new String[] {
107                 "-noExit",
108                 "delete"
109         };
110 //        Agent.main(args);
111
112         inStream.reset();
113         args = new String[] {
114                 "-noExit",
115                 "showpass"
116         };
117 //        Agent.main(args);
118
119     }
120
121     private void recursiveDelete(File file) {
122         for (File f : file.listFiles()) {
123             if (f.isDirectory()) {
124                 recursiveDelete(f);
125             }
126             f.delete();
127         }
128         file.delete();
129     }
130
131 }