2c2cf5204048aedf605fa559f8f48488f070c289
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
5  *  Modifications Copyright (C) 2020 Nordix Foundation.
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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.apex.domains.onap.vcpe;
24
25 import static org.awaitility.Awaitility.await;
26
27 import java.util.concurrent.TimeUnit;
28 import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
29 import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
30 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
31 import org.onap.policy.apex.service.engine.main.ApexMain;
32
33 /**
34  * Test the ONAP vCPE use case.
35  */
36 public class OnapVcpeRunner {
37
38     private OnapVcpeRunner() throws ApexException {
39
40         // @formatter:off
41         final String[] cliArgs = new String[] {
42             "-c",
43             "src/main/resources/policy/ONAPvCPEPolicyModel.apex",
44             "-l",
45             "target/ONAPvCPEPolicyModel.log",
46             "-ac",
47             "src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim.json",
48             "-t",
49             "src/main/resources/tosca/ToscaTemplate.json",
50             "-ot",
51             "target/classes/ONAPvCPEPolicy.json"
52         };
53         // @formatter:on
54
55         new ApexCliToscaEditorMain(cliArgs);
56
57         // @formatter:off
58         final String[] apexArgs = {
59             "-rfr",
60             "target/classes",
61             "-p",
62             "target/classes/ONAPvCPEPolicy.json"
63         };
64         // @formatter:on
65
66         final ApexMain apexMain = new ApexMain(apexArgs);
67
68         await().atMost(5000, TimeUnit.MILLISECONDS).until(() -> apexMain.isAlive());
69
70         // This test should be amended to start and shutdown the simulator as part of the test and not separately as
71         // is done in the gRPC test.
72         ThreadUtilities.sleep(1000000);
73         apexMain.shutdown();
74     }
75
76     public static void main(String[] args) throws ApexException {
77         new OnapVcpeRunner();
78     }
79 }