diff options
Diffstat (limited to 'controlloop/common/feature-controlloop-utils/src')
5 files changed, 212 insertions, 0 deletions
diff --git a/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml b/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml new file mode 100644 index 000000000..26e6676b7 --- /dev/null +++ b/controlloop/common/feature-controlloop-utils/src/assembly/assemble_zip.xml @@ -0,0 +1,75 @@ +<!-- + ============LICENSE_START======================================================= + ONAP + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!-- Defines how we build the .zip file which is our distribution. --> + +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>feature-controlloop-utils-package</id> + <formats> + <format>zip</format> + </formats> + + <includeBaseDirectory>false</includeBaseDirectory> + + <fileSets> + <fileSet> + <directory>target</directory> + <outputDirectory>lib/feature</outputDirectory> + <includes> + <include>feature-controlloop-utils-${project.version}.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>target/assembly/lib</directory> + <outputDirectory>lib/dependencies</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>src/main/feature/config</directory> + <outputDirectory>config</outputDirectory> + <fileMode>0644</fileMode> + <excludes/> + </fileSet> + <fileSet> + <directory>src/main/feature/bin</directory> + <outputDirectory>bin</outputDirectory> + <fileMode>0744</fileMode> + <excludes/> + </fileSet> + <fileSet> + <directory>src/main/feature/db</directory> + <outputDirectory>db</outputDirectory> + <fileMode>0744</fileMode> + <excludes/> + </fileSet> + <fileSet> + <directory>src/main/feature/install</directory> + <outputDirectory>install</outputDirectory> + <fileMode>0744</fileMode> + <excludes/> + </fileSet> + </fileSets> + +</assembly> diff --git a/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment new file mode 100644 index 000000000..daa98799c --- /dev/null +++ b/controlloop/common/feature-controlloop-utils/src/main/feature/config/simulators.properties.environment @@ -0,0 +1,26 @@ +### +# ============LICENSE_START======================================================= +# ONAP +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# Environment file (.environment) for the simulator for control loop applications + +aai.url=http://localhost:6666 +so.url=http://localhost:6667 +vfc.url=http://localhost:6668 + diff --git a/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java new file mode 100644 index 000000000..50876311c --- /dev/null +++ b/controlloop/common/feature-controlloop-utils/src/main/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeature.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.drools.apps.controlloop.feature.utils; + +import java.io.IOException; + +import org.onap.policy.drools.features.PolicyEngineFeatureAPI; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.simulators.Util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * PDP-D feature for lab environments that provides Server simulation capabilities for AAI, SO, and + * VFC + * + */ +public class ControlLoopUtilsFeature implements PolicyEngineFeatureAPI { + + /** + * Logger + */ + private static Logger logger = LoggerFactory.getLogger(ControlLoopUtilsFeature.class); + + @Override + public boolean afterStart(PolicyEngine engine) { + try { + Util.buildAaiSim(); + Util.buildSoSim(); + Util.buildVfcSim(); + } catch (final InterruptedException e) { + logger.error("{}: initialization aborted", ControlLoopUtilsFeature.class.getName(), e); + Thread.currentThread().interrupt(); + } catch (final IOException e) { + logger.error("{}: a simulator cannot be built because of {}", + ControlLoopUtilsFeature.class.getName(), e.getMessage(), e); + } + return false; + } + + @Override + public int getSequenceNumber() { + return 100000; + } + +} diff --git a/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI b/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI new file mode 100644 index 000000000..b5a71b8b2 --- /dev/null +++ b/controlloop/common/feature-controlloop-utils/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureAPI @@ -0,0 +1 @@ +org.onap.policy.drools.apps.controlloop.feature.utils.ControlLoopUtilsFeature diff --git a/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java new file mode 100644 index 000000000..5ba375847 --- /dev/null +++ b/controlloop/common/feature-controlloop-utils/src/test/java/org/onap/policy/drools/apps/controlloop/feature/utils/ControlLoopUtilsFeatureTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.drools.apps.controlloop.feature.utils; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.drools.utils.LoggerUtil; +import org.onap.policy.simulators.Util; + +/** + * ControlLoopUtilsFeature JUnit Tests + */ +public class ControlLoopUtilsFeatureTest { + + @Test + public void simulate() { + LoggerUtil.setLevel("ROOT", "INFO"); + LoggerUtil.setLevel("org.eclipse.jetty", "WARN"); + final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature(); + feature.afterStart(PolicyEngine.manager); + assertNotNull(HttpServletServer.factory.get(Util.AAISIM_SERVER_PORT)); + assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT)); + assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT)); + } + +} |