c1d68760d1c39a14a0e7c1052ac1e7de146185ca
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.plugins.executor.test.script.engine;
22
23 import java.io.IOException;
24
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
29 import org.onap.policy.apex.context.parameters.ContextParameterConstants;
30 import org.onap.policy.apex.context.parameters.ContextParameters;
31 import org.onap.policy.apex.context.parameters.SchemaParameters;
32 import org.onap.policy.apex.core.engine.EngineParameters;
33 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
34 import org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters;
35 import org.onap.policy.common.parameters.ParameterService;
36
37 /**
38  * The Class TestApexEngine_Java.
39  *
40  * @author Liam Fallon (liam.fallon@ericsson.com)
41  */
42 public class TestApexEngineJava {
43     private SchemaParameters schemaParameters;
44     private ContextParameters contextParameters;
45     private EngineParameters engineParameters;
46
47     @Before
48     public void beforeTest() {
49         schemaParameters = new SchemaParameters();
50         
51         schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
52         schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
53
54         ParameterService.register(schemaParameters);
55         
56         contextParameters = new ContextParameters();
57
58         contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
59         contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
60         contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
61         contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
62
63         ParameterService.register(contextParameters);
64         ParameterService.register(contextParameters.getDistributorParameters());
65         ParameterService.register(contextParameters.getLockManagerParameters());
66         ParameterService.register(contextParameters.getPersistorParameters());
67         
68         engineParameters = new EngineParameters();
69         engineParameters.getExecutorParameterMap().put("JAVA", new JavaExecutorParameters());
70         ParameterService.register(engineParameters);
71     }
72
73     @After
74     public void afterTest() {
75         ParameterService.deregister(engineParameters);
76         
77         ParameterService.deregister(contextParameters.getDistributorParameters());
78         ParameterService.deregister(contextParameters.getLockManagerParameters());
79         ParameterService.deregister(contextParameters.getPersistorParameters());
80         ParameterService.deregister(contextParameters);
81
82         ParameterService.deregister(schemaParameters);
83     }
84
85     /**
86      * Test apex engine.
87      *
88      * @throws InterruptedException the interrupted exception
89      * @throws IOException Signals that an I/O exception has occurred.
90      * @throws ApexException the apex exception
91      */
92     @Test
93     public void testApexEngineJava() throws InterruptedException, IOException, ApexException {
94         new TestApexEngine("JAVA", engineParameters);
95         new TestApexEngine("JAVA", engineParameters);
96     }
97 }