Mass removal of all Tabs (Style Warnings)
[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         Agent.main(args);
75
76         inStream.reset();
77         args = new String[] {
78                 "-noExit",
79                 "create"
80         };
81         Agent.main(args);
82
83         inStream.reset();
84         args = new String[] {
85                 "-noExit",
86                 "read"
87         };
88         Agent.main(args);
89
90         inStream.reset();
91         args = new String[] {
92                 "-noExit",
93                 "copy"
94         };
95         Agent.main(args);
96
97         inStream.reset();
98         args = new String[] {
99                 "-noExit",
100                 "update"
101         };
102         Agent.main(args);
103
104         inStream.reset();
105         args = new String[] {
106                 "-noExit",
107                 "delete"
108         };
109         Agent.main(args);
110
111         inStream.reset();
112         args = new String[] {
113                 "-noExit",
114                 "showpass"
115         };
116         Agent.main(args);
117
118     }
119
120     private void recursiveDelete(File file) {
121         for (File f : file.listFiles()) {
122             if (f.isDirectory()) {
123                 recursiveDelete(f);
124             }
125             f.delete();
126         }
127         file.delete();
128     }
129
130 }