diff options
Diffstat (limited to 'testsuites')
25 files changed, 254 insertions, 187 deletions
diff --git a/testsuites/apex-pdp-stability/pom.xml b/testsuites/apex-pdp-stability/pom.xml index 8ab847cf3..7b40320b7 100644 --- a/testsuites/apex-pdp-stability/pom.xml +++ b/testsuites/apex-pdp-stability/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.apex-pdp.testsuites</groupId> <artifactId>apex-testsuites</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <groupId>org.onap.policy.apex-pdp.testsuites.stability</groupId> diff --git a/testsuites/integration/integration-common/pom.xml b/testsuites/integration/integration-common/pom.xml index 64db1b96f..8e567517f 100644 --- a/testsuites/integration/integration-common/pom.xml +++ b/testsuites/integration/integration-common/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> <artifactId>apex-integration</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>integration-common</artifactId> diff --git a/testsuites/integration/integration-context-test/pom.xml b/testsuites/integration/integration-context-test/pom.xml index 0a0154718..26c2b3a4d 100644 --- a/testsuites/integration/integration-context-test/pom.xml +++ b/testsuites/integration/integration-context-test/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> <artifactId>apex-integration</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>integration-context-test</artifactId> diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java index ca3c05744..ae56d15d9 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019,2022 Nordix Foundation. + * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,9 +22,9 @@ package org.onap.policy.apex.testsuites.integration.context.entities; +import jakarta.xml.bind.annotation.XmlElement; import java.util.Arrays; import java.util.List; -import javax.xml.bind.annotation.XmlElement; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java index a2d2fa305..0da996483 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019,2022 Nordix Foundation. + * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,9 +22,9 @@ package org.onap.policy.apex.testsuites.integration.context.entities; +import jakarta.xml.bind.annotation.XmlElement; import java.util.Arrays; import java.util.List; -import javax.xml.bind.annotation.XmlElement; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/testsuites/integration/integration-executor-test/pom.xml b/testsuites/integration/integration-executor-test/pom.xml index 679b596e6..0075f5119 100644 --- a/testsuites/integration/integration-executor-test/pom.xml +++ b/testsuites/integration/integration-executor-test/pom.xml @@ -19,17 +19,19 @@ ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> <artifactId>apex-integration</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>integration-executor-test</artifactId> <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] module to run executor tests using various executor script plugins</description> + <description>[${project.parent.artifactId}] module to run executor tests using various executor script plugins + </description> <dependencies> <dependency> @@ -68,10 +70,5 @@ <version>${project.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml index 1e1c6f7da..8f1207cca 100644 --- a/testsuites/integration/integration-uservice-test/pom.xml +++ b/testsuites/integration/integration-uservice-test/pom.xml @@ -22,12 +22,12 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> <artifactId>apex-integration</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>integration-uservice-test</artifactId> @@ -127,17 +127,6 @@ <artifactId>kafka-junit4</artifactId> <version>${version.kafka-junit4}</version> <scope>test</scope> - <exclusions> - <!-- The default netty version in kafka-junit4 has vulnerabilities --> - <exclusion> - <groupId>io.netty</groupId> - <artifactId>*</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> @@ -145,14 +134,10 @@ <version>${version.zookeeper}</version> <scope>test</scope> <exclusions> - <!-- The default netty version in kafka-junit4 has vulnerabilities --> - <exclusion> - <groupId>io.netty</groupId> - <artifactId>*</artifactId> - </exclusion> + <!-- The default netty version in kafka-junit4 has vulnerabilities --> <exclusion> <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> + <artifactId>slf4j-reload4j</artifactId> </exclusion> </exclusions> </dependency> @@ -162,33 +147,39 @@ <artifactId>netty-all</artifactId> </dependency> <dependency> - <groupId>org.apache.activemq.tooling</groupId> - <artifactId>activemq-junit</artifactId> - <version>${version.activemq}</version> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-core-client</artifactId> + <version>${version.artemis}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.activemq</groupId> - <artifactId>activemq-broker</artifactId> - <version>${version.activemq}</version> + <artifactId>artemis-jakarta-client</artifactId> + <version>${version.artemis}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.activemq</groupId> - <artifactId>activemq-jaas</artifactId> - <version>${version.activemq}</version> + <artifactId>artemis-server</artifactId> + <version>${version.artemis}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.awaitility</groupId> - <artifactId>awaitility</artifactId> + <groupId>jakarta.jms</groupId> + <artifactId>jakarta.jms-api</artifactId> + <version>${version.jms}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${version.jackson-databind}</version> + </dependency> </dependencies> <build> <plugins> - <!-- Copy required resources and examples --> + <!-- Copy required resources and examples --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@ -254,7 +245,7 @@ </goals> </pluginExecutionFilter> <action> - <ignore /> + <ignore/> </action> </pluginExecution> </pluginExecutions> diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java index a626ff520..119b306b0 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventProducer.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,15 +22,15 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.Topic; +import jakarta.jms.Connection; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import jakarta.jms.Topic; import lombok.Getter; -import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.apex.testsuites.integration.common.testclasses.PingTestClass; diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java index 2bdacb66e..7f0cd8751 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsEventSubscriber.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,17 +22,17 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; +import jakarta.jms.Connection; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.ObjectMessage; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; +import jakarta.jms.Topic; import lombok.Getter; -import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java new file mode 100644 index 000000000..02d913de4 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/JmsServerRunner.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2022-2023 Nordix Foundation. + * ================================================================================ + * 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.testsuites.integration.uservice.adapt.jms; + +import static org.awaitility.Awaitility.await; + +import java.util.concurrent.TimeUnit; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JmsServerRunner implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(JmsServerRunner.class); + + // Embedded JMS server + private EmbeddedActiveMQ embedded; + + // Thread to run the JMS server in + private Thread jmsServerRunnerThread; + + // Config fields + private final String serverName; + private final String serverUri; + + /** + * Create the JMS Server. + * + * @param serverName Name of the server + * @param serverUri URI for the server + * @throws Exception on errors + */ + public JmsServerRunner(String serverName, String serverUri) throws Exception { + this.serverName = serverName; + this.serverUri = serverUri; + + ConfigurationImpl config = new ConfigurationImpl(); + + config.addAcceptorConfiguration(serverName, serverUri); + config.setSecurityEnabled(false); + config.setJournalDirectory("target/artemisActiveMq/data/journal"); + config.setBindingsDirectory("target/artemisActiveMq/data/bindings"); + config.setLargeMessagesDirectory("target/artemisActiveMq/data/largemessages"); + config.setPagingDirectory("target/artemisActiveMq/data/paging"); + + embedded = new EmbeddedActiveMQ(); + embedded.setConfiguration(config); + + LOGGER.debug("starting JMS Server " + serverName + " on URI " + serverUri + " . . ."); + + jmsServerRunnerThread = new Thread(this); + jmsServerRunnerThread.start(); + + LOGGER.debug("requested start on JMS Server " + serverName + " on URI " + serverUri); + } + + @Override + public void run() { + try { + LOGGER.debug("starting JMS Server thread " + serverName + " on URI " + serverUri + " . . ."); + embedded.start(); + + await().atMost(30, TimeUnit.SECONDS).until(() -> embedded.getActiveMQServer().isActive()); + + LOGGER.debug("started JMS Server thread " + serverName + " on URI " + serverUri); + } catch (Exception e) { + LOGGER.warn("failed to start JMS Server thread " + serverName + " on URI " + serverUri, e); + } + } + + /** + * Stop the JMS server. + * + * @throws Exception on stop errors + */ + public void stop() throws Exception { + LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . ."); + + if (!embedded.getActiveMQServer().isActive()) { + LOGGER.debug("JMS Server " + serverName + " already stopped on URI " + serverUri + " . . ."); + return; + } + + embedded.stop(); + + LOGGER.debug("waiting on JMS Server " + serverName + " to stop on URI " + serverUri + " . . ."); + + await().atMost(30, TimeUnit.SECONDS) + .until(() -> !embedded.getActiveMQServer().isActive() && !jmsServerRunnerThread.isAlive()); + + LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . ."); + } +}
\ No newline at end of file diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java index 876981f71..f27162a65 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestContext.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +25,6 @@ import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.Tes import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_IN; import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_OUT; import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.PORT; -import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.connectionFactory; import java.util.HashMap; import java.util.Hashtable; @@ -37,7 +37,8 @@ import javax.naming.NameClassPair; import javax.naming.NameParser; import javax.naming.NamingEnumeration; import javax.naming.NamingException; -import org.apache.activemq.command.ActiveMQTopic; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; /** @@ -59,7 +60,7 @@ public class TestContext implements Context { final Map<String, Object> params = new HashMap<String, Object>(); params.put("host", HOST); params.put("port", PORT); - testProperties.put("ConnectionFactory", connectionFactory); + testProperties.put("ConnectionFactory", new ActiveMQConnectionFactory(TestJms2Jms.SERVER_URI)); testProperties.put(JMS_TOPIC_APEX_IN, new ActiveMQTopic(JMS_TOPIC_APEX_IN)); testProperties.put(JMS_TOPIC_APEX_OUT, new ActiveMQTopic(JMS_TOPIC_APEX_OUT)); } catch (final Exception e) { diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java index b060179cb..91417a57a 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,75 +25,49 @@ package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms; import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertEquals; +import jakarta.jms.JMSException; import java.io.IOException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.TimeUnit; -import javax.jms.JMSException; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerPlugin; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.security.AuthenticationUser; -import org.apache.activemq.security.SimpleAuthenticationPlugin; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.service.engine.main.ApexMain; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class TestJms2Jms. */ public class TestJms2Jms { - public static final String PORT = "5445"; - public static final String HOST = "localhost"; - public static final String JMS_TOPIC_APEX_IN = "jms/topic/apexIn"; - public static final String JMS_TOPIC_APEX_OUT = "jms/topic/apexOut"; + private static final Logger LOGGER = LoggerFactory.getLogger(TestJms2Jms.class); - private static final String GROUP_ROLE = "guests"; - private static final String PACKAGE_NAME = "org.onap.policy.apex.testsuites.integration.common.testclasses"; - private static final String USERNAME = "guest"; - private static final String PASSWORD = "IAmAGuest"; - private static final String URL = "tcp://" + HOST + ":" + PORT; - - private static final String DATA_PARENT_DIR = Paths.get("target", "activemq-data").toString(); - - private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestJms2Jms.class); + protected static final String SERVER_NAME = "JmsTestServer"; + protected static final String PORT = "5445"; + protected static final String HOST = "localhost"; + protected static final String JMS_TOPIC_APEX_IN = "jms/topic/apexIn"; + protected static final String JMS_TOPIC_APEX_OUT = "jms/topic/apexOut"; + protected static final String SERVER_URI = "tcp://" + HOST + ":" + PORT; private static final int EVENT_COUNT = 100; private static final int EVENT_INTERVAL = 20; - private static BrokerService broker; - - public static ActiveMQConnectionFactory connectionFactory; + // Embedded JMS server for testing + private static JmsServerRunner jmsServerRunner; /** - * Setup embedded jms server. + * Setup embedded JMS server. * * @throws Exception the exception */ @BeforeClass public static void setupEmbeddedJmsServer() throws Exception { - final ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>(); - final BrokerPlugin authenticationPlugin = getAuthenticationBrokerPlugin(); - plugins.add(authenticationPlugin); - - broker = new BrokerService(); - broker.setUseJmx(false); - broker.setPersistent(false); - broker.addConnector(URL); - broker.setDeleteAllMessagesOnStartup(true); - broker.setPlugins(plugins.toArray(new BrokerPlugin[0])); - broker.setDataDirectory(DATA_PARENT_DIR); - broker.start(); - broker.waitUntilStarted(); - connectionFactory = new ActiveMQConnectionFactory(URL); - connectionFactory.setTrustedPackages(Arrays.asList(PACKAGE_NAME)); + jmsServerRunner = new JmsServerRunner(SERVER_NAME, SERVER_URI); + + await().pollDelay(3L, TimeUnit.SECONDS).until(() -> new AtomicBoolean(true).get() == true); } /** @@ -105,18 +79,6 @@ public class TestJms2Jms { } /** - * Gets the authentication broker plugin. - * - * @return the authentication broker plugin - */ - private static BrokerPlugin getAuthenticationBrokerPlugin() { - final List<AuthenticationUser> users = new ArrayList<AuthenticationUser>(); - users.add(new AuthenticationUser(USERNAME, PASSWORD, GROUP_ROLE)); - final SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users); - return authenticationPlugin; - } - - /** * Shutdown embedded jms server. * * @throws IOException Signals that an I/O exception has occurred. @@ -124,8 +86,8 @@ public class TestJms2Jms { @AfterClass public static void shutdownEmbeddedJmsServer() throws IOException { try { - if (broker != null) { - broker.stop(); + if (jmsServerRunner != null) { + jmsServerRunner.stop(); } } catch (final Exception e) { LOGGER.warn("Failed to stop JMS server", e); @@ -141,7 +103,9 @@ public class TestJms2Jms { */ @Test public void testJmsObjectEvents() throws ApexException, JMSException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSObjectEvent.json"}; + final String[] args = { + "-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSObjectEvent.json" + }; testJmsEvents(args, true); } @@ -153,7 +117,9 @@ public class TestJms2Jms { */ @Test public void testJmsJsonEvents() throws ApexException, JMSException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSJsonEvent.json"}; + final String[] args = { + "-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSJsonEvent.json" + }; testJmsEvents(args, false); } @@ -167,10 +133,11 @@ public class TestJms2Jms { */ private void testJmsEvents(final String[] args, final Boolean sendObjects) throws ApexException, JMSException { final JmsEventSubscriber subscriber = - new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, connectionFactory, USERNAME, PASSWORD); + new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, new ActiveMQConnectionFactory(SERVER_URI), null, null); - final JmsEventProducer producer = new JmsEventProducer(JMS_TOPIC_APEX_IN, connectionFactory, USERNAME, PASSWORD, - EVENT_COUNT, sendObjects, EVENT_INTERVAL); + final JmsEventProducer producer = + new JmsEventProducer(JMS_TOPIC_APEX_IN, new ActiveMQConnectionFactory(SERVER_URI), null, null, + EVENT_COUNT, sendObjects, EVENT_INTERVAL); final ApexMain apexMain = new ApexMain(args); @@ -188,4 +155,4 @@ public class TestJms2Jms { assertEquals(EVENT_COUNT, producer.getEventsSentCount()); assertEquals(producer.getEventsSentCount(), subscriber.getEventsReceivedCount()); } -} +}
\ No newline at end of file diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java index d1488df86..593ddd03e 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java @@ -26,12 +26,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.core.Response; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.Response; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java index 5683b48b2..737065638 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java @@ -28,14 +28,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.core.Response; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.Response; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java index dc8d962dd..389545542 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRestClientEndpoint.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,14 +25,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; import java.util.Map; import java.util.Random; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; - /** * The Class TestRestClientEndpoint. diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java index 7f460bb15..8a506e16b 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -29,16 +29,16 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.core.Response; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Map; import java.util.Random; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.Response; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/RestClientEndpointForTaskParameters.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/RestClientEndpointForTaskParameters.java index f0b670008..35cd3ca5a 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/RestClientEndpointForTaskParameters.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/RestClientEndpointForTaskParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ package org.onap.policy.apex.testsuites.integration.uservice.taskparameters; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.core.Response; /** * The Class RestClientEndpointForTaskParameters. diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java index 655538349..f78fd12cd 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java @@ -24,10 +24,10 @@ package org.onap.policy.apex.testsuites.integration.uservice.taskparameters; import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.core.Response; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.Response; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/logback-test.xml b/testsuites/integration/integration-uservice-test/src/test/resources/logback-test.xml index 1fa56526f..ce77b7852 100644 --- a/testsuites/integration/integration-uservice-test/src/test/resources/logback-test.xml +++ b/testsuites/integration/integration-uservice-test/src/test/resources/logback-test.xml @@ -2,7 +2,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2016-2018 Ericsson. All rights reserved. - Modifications Copyright (C) 2020 Nordix Foundation. + Modifications Copyright (C) 2020, 2023 Nordix Foundation. Modifications Copyright (C) 2021 Bell Canada. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,13 +41,16 @@ <appender-ref ref="STDOUT" /> </logger> - <logger name="org.onap.policy.apex.core" level="INFO" additivity="false"> + <logger name="org.onap.policy.apex.core" level="DEBUG" additivity="false"> <appender-ref ref="STDOUT" /> </logger> - <logger name="org.onap.policy.apex.plugins.executor" level="INFO" additivity="false"> + <logger name="org.onap.policy.apex.plugins.executor" level="DEBUG" additivity="false"> <appender-ref ref="STDOUT" /> </logger> + <logger name="org.onap.policy.apex.testsuites.integration.uservice.adapt" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> </configuration> diff --git a/testsuites/integration/pom.xml b/testsuites/integration/pom.xml index a3ce0333c..98367ef3d 100644 --- a/testsuites/integration/pom.xml +++ b/testsuites/integration/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.apex-pdp.testsuites</groupId> <artifactId>apex-testsuites</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> diff --git a/testsuites/performance/performance-benchmark-test/pom.xml b/testsuites/performance/performance-benchmark-test/pom.xml index 96aa41909..09c8d125a 100644 --- a/testsuites/performance/performance-benchmark-test/pom.xml +++ b/testsuites/performance/performance-benchmark-test/pom.xml @@ -20,12 +20,12 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.apex-pdp.testsuites.performance</groupId> <artifactId>apex-performance</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>performance-benchmark-test</artifactId> @@ -39,6 +39,7 @@ <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-grizzly2-http</artifactId> + <version>${version.jersey}</version> </dependency> <dependency> <groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId> @@ -89,16 +90,11 @@ <version>${project.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> <plugins> - <!-- Copy required resources and examples --> + <!-- Copy required resources and examples --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@ -138,7 +134,7 @@ </build> <profiles> - <profile> + <profile> <id>only-eclipse</id> <activation> <property> @@ -164,7 +160,7 @@ </goals> </pluginExecutionFilter> <action> - <ignore /> + <ignore/> </action> </pluginExecution> </pluginExecutions> diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java index 53e57f295..8e8a699c6 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,14 +23,14 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import com.google.gson.Gson; +import jakarta.inject.Inject; +import jakarta.inject.Provider; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Inject; -import javax.inject.Provider; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java index 44a06ee54..75d6d65f3 100644 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpointTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +24,15 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import javax.inject.Provider; -import javax.ws.rs.core.Response; +import jakarta.inject.Provider; +import jakarta.ws.rs.core.Response; import org.glassfish.grizzly.http.server.Request; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent; @@ -38,6 +40,7 @@ import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.even * Test the EventGeneratorEndpoint class. * */ +@RunWith(MockitoJUnitRunner.class) public class EventGeneratorEndpointTest { @Mock private Provider<Request> httpRequestProviderMock; @@ -52,7 +55,6 @@ public class EventGeneratorEndpointTest { */ @Before public void initializeMocking() throws ApexException { - MockitoAnnotations.initMocks(this); Mockito.doReturn(httpRequestMock).when(httpRequestProviderMock).get(); diff --git a/testsuites/performance/pom.xml b/testsuites/performance/pom.xml index cca41e3fd..2f9acb48d 100644 --- a/testsuites/performance/pom.xml +++ b/testsuites/performance/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.apex-pdp.testsuites</groupId> <artifactId>apex-testsuites</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <groupId>org.onap.policy.apex-pdp.testsuites.performance</groupId> diff --git a/testsuites/pom.xml b/testsuites/pom.xml index 638b62b9f..2979d783d 100644 --- a/testsuites/pom.xml +++ b/testsuites/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.policy.apex-pdp</groupId> <artifactId>apex-pdp</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <groupId>org.onap.policy.apex-pdp.testsuites</groupId> |