diff options
Diffstat (limited to 'core/core-protocols/src/test')
5 files changed, 309 insertions, 0 deletions
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java new file mode 100644 index 000000000..d5cf2bcba --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.core.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class GetExecutionStatusTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class GetExecutionStatusTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(GetExecutionStatusTest.class); + + GetEngineStatus message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1"); + message = new GetEngineStatus(targetKey); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("UpdateModelTest")); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java new file mode 100644 index 000000000..97cc8d5b9 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.core.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class GetPolicyStatusTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class GetPolicyStatusTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(GetPolicyStatusTest.class); + + GetEngineStatus message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("PolicyStatusTest", "0.0.1"); + message = new GetEngineStatus(targetKey); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("PolicyStatusTest")); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java new file mode 100644 index 000000000..74def7cc0 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.core.protocols.engdep; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.Response; +import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class ResponseTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ResponseTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(ResponseTest.class); + + Response message = null; + + /** + * Test response. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testResponse() throws UnknownHostException { + final AxArtifactKey responseKey = new AxArtifactKey("ResponseTest", "0.0.1"); + final AxArtifactKey responseToKey = new AxArtifactKey("ResponseTestTO", "0.0.1"); + message = new Response(responseKey, false, new UpdateModel(responseToKey)); + logger.debug(message.toString()); + assertTrue(message.toString().contains("ResponseTest")); + assertFalse(message.isSuccessful()); + + message = new Response(responseKey, true, new UpdateModel(responseToKey)); + logger.debug(message.toString()); + assertTrue(message.toString().contains("ResponseTest")); + assertTrue(message.isSuccessful()); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java new file mode 100644 index 000000000..ca919c389 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.core.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class UpdateModelTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class UpdateModelTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(UpdateModelTest.class); + + UpdateModel message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1"); + message = new UpdateModel(targetKey, new String("Placeholder for Apex model XML"), false, false); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("Placeholder for Apex model XML")); + } +} diff --git a/core/core-protocols/src/test/resources/logback-test.xml b/core/core-protocols/src/test/resources/logback-test.xml new file mode 100644 index 000000000..034511335 --- /dev/null +++ b/core/core-protocols/src/test/resources/logback-test.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2016-2018 Ericsson. 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. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +<configuration> + + <contextName>Apex</contextName> + <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /> + <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" /> + + <!-- USE FOR STD OUT ONLY --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern> + </encoder> + </appender> + + <root level="INFO"> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.infinispan" level="INFO" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>${LOG_DIR}/apex.log</file> + <encoder> + <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level + %logger{26} - %msg %n %ex{full}</pattern> + </encoder> + </appender> + + <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender"> + <file>${LOG_DIR}/apex_ctxt.log</file> + <encoder> + <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level + %logger{26} - %msg %n %ex{full}</pattern> + </encoder> + </appender> + + <logger name="org.onap.policy.apex.core.context.impl.monitoring" level="TRACE" additivity="false"> + <appender-ref ref="CTXT_FILE" /> + </logger> + + <logger name="org.onap.policy.apex.core.context" level="INFO" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> +</configuration> |