From f0fd964e343fe5a9cc2044d417fadf6cdd1ef0d1 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 11 Feb 2022 00:43:14 +0000 Subject: Remove apex-pdp unused core modules This is the final review in the refactoring of the model code in apex-pdp. The core-messaging and core-infrastructure modules are unused in apex-pdp except for websocket communication. Websocket communication is also not used in any deployment. This review: - removes the core-mesaging module, which had an apex-specific websocket implementation, except for the MessageException class, which is moved to the base core module - removes the core-infrastructure module, except for the ThreadUtils class, which is moved to the base core module - removes the websocket event protocol, which used core-messaging but is not used in any deployment - collapses all three "core" submodules into a single module - Updates dependencies where needed Issue-ID: POLICY-1820 Change-Id: Ieae30063e99570e61943372d3fa23b77a211462c Signed-off-by: liamfallon --- .../uservice/adapt/websocket/TestWs2WsClient.java | 81 ---------- .../uservice/adapt/websocket/TestWs2WsServer.java | 104 ------------- .../websocket/WebSocketEventProducerClient.java | 171 --------------------- .../websocket/WebSocketEventProducerServer.java | 167 -------------------- .../websocket/WebSocketEventSubscriberClient.java | 99 ------------ .../websocket/WebSocketEventSubscriberServer.java | 100 ------------ 6 files changed, 722 deletions(-) delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsClient.java delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsServer.java delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerClient.java delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerServer.java delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberClient.java delete mode 100644 testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberServer.java (limited to 'testsuites/integration/integration-uservice-test/src/test') diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsClient.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsClient.java deleted file mode 100644 index 96f31e98d..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Bell Canada. 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.testsuites.integration.uservice.adapt.websocket; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.service.engine.main.ApexMain; - -public class TestWs2WsClient { - private static final long MAX_TEST_LENGTH = 10000; - - private static final int EVENT_COUNT = 100; - private static final int EVENT_INTERVAL = 20; - - /** - * Clear relative file root environment variable. - */ - @Before - public void clearRelativeFileRoot() { - System.clearProperty("APEX_RELATIVE_FILE_ROOT"); - } - - @Test - public void testJsonWsEvents() throws MessagingException, ApexException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/Ws2WsClientJsonEvent.json"}; - testWsEvents(args, false); - } - - @Test - public void testXmlWsEvents() throws MessagingException, ApexException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/Ws2WsClientXMLEvent.json"}; - testWsEvents(args, true); - } - - private void testWsEvents(final String[] args, final Boolean xmlEvents) throws MessagingException, ApexException { - final WebSocketEventSubscriberServer subServer = new WebSocketEventSubscriberServer(42453); - final WebSocketEventProducerServer prodServer = - new WebSocketEventProducerServer(42451, EVENT_COUNT, xmlEvents, EVENT_INTERVAL); - - final ApexMain apexMain = new ApexMain(args); - - prodServer.sendEvents(); - - final long testStartTime = System.currentTimeMillis(); - - while (System.currentTimeMillis() < testStartTime + MAX_TEST_LENGTH - && subServer.getEventsReceivedCount() < EVENT_COUNT) { - ThreadUtilities.sleep(EVENT_INTERVAL); - } - - assertEquals(prodServer.getEventsSentCount(), subServer.getEventsReceivedCount()); - - apexMain.shutdown(); - prodServer.shutdown(); - subServer.shutdown(); - } -} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsServer.java deleted file mode 100644 index 870eb9ec7..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/TestWs2WsServer.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Bell Canada. 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.testsuites.integration.uservice.adapt.websocket; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.service.engine.main.ApexMain; - -/** - * The Class TestWs2WsServer. - */ -public class TestWs2WsServer { - private static final long MAX_TEST_LENGTH = 10000; - - private static final int EVENT_COUNT = 100; - private static final int EVENT_INTERVAL = 20; - - /** - * Clear relative file root environment variable. - */ - @Before - public void clearRelativeFileRoot() { - System.clearProperty("APEX_RELATIVE_FILE_ROOT"); - } - - /** - * Test json ws events. - * - * @throws MessagingException the messaging exception - * @throws ApexException the apex exception - */ - @Test - public void testJsonWsEvents() throws MessagingException, ApexException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/Ws2WsServerJsonEvent.json"}; - testWsEvents(args, false); - } - - /** - * Test xml ws events. - * - * @throws MessagingException the messaging exception - * @throws ApexException the apex exception - */ - @Test - public void testXmlWsEvents() throws MessagingException, ApexException { - final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/Ws2WsServerXMLEvent.json"}; - testWsEvents(args, true); - } - - /** - * Test ws events. - * - * @param args the args - * @param xmlEvents the xml events - * @throws MessagingException the messaging exception - * @throws ApexException the apex exception - */ - public void testWsEvents(final String[] args, final boolean xmlEvents) throws MessagingException, ApexException { - final ApexMain apexMain = new ApexMain(args); - - final WebSocketEventSubscriberClient subClient = new WebSocketEventSubscriberClient("localhost", 42452); - final WebSocketEventProducerClient prodClient = - new WebSocketEventProducerClient("localhost", 42450, EVENT_COUNT, xmlEvents, EVENT_INTERVAL); - - prodClient.sendEvents(); - - final long testStartTime = System.currentTimeMillis(); - - while (System.currentTimeMillis() < testStartTime + MAX_TEST_LENGTH - && subClient.getEventsReceivedCount() < EVENT_COUNT) { - ThreadUtilities.sleep(EVENT_INTERVAL); - } - - assertEquals(subClient.getEventsReceivedCount(), prodClient.getEventsSentCount()); - - prodClient.shutdown(); - subClient.shutdown(); - apexMain.shutdown(); - } -} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerClient.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerClient.java deleted file mode 100644 index 6ffdeeaf2..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerClient.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.integration.uservice.adapt.websocket; - -import lombok.Getter; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.testsuites.integration.uservice.adapt.events.EventGenerator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class WebSocketEventProducerClient. - */ -public class WebSocketEventProducerClient implements WsStringMessageListener { - private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketEventProducerClient.class); - - private final String host; - private final int port; - private final int eventCount; - private final boolean xmlEvents; - private final long eventInterval; - @Getter - private long eventsSentCount = 0; - - WsStringMessageClient client; - - /** - * Instantiates a new web socket event producer client. - * - * @param host the host - * @param port the port - * @param eventCount the event count - * @param xmlEvents the xml events - * @param eventInterval the event interval - * @throws MessagingException the messaging exception - */ - public WebSocketEventProducerClient(final String host, final int port, final int eventCount, - final boolean xmlEvents, final long eventInterval) throws MessagingException { - this.host = host; - this.port = port; - this.eventCount = eventCount; - this.xmlEvents = xmlEvents; - this.eventInterval = eventInterval; - - client = new WsStringMessageClient(host, port); - client.start(this); - - LOGGER.debug("{}: host {}, port {}, event count {}, xmlEvents {}", WebSocketEventProducerClient.class.getName(), - host, port, eventCount, xmlEvents); - } - - /** - * Send events. - */ - public void sendEvents() { - LOGGER.debug("{}: sending events on host {}, port {}, event count {}, xmlEvents {}", - WebSocketEventProducerClient.class.getName(), host, port, eventCount, xmlEvents); - - for (int i = 0; i < eventCount; i++) { - LOGGER.debug("{}: waiting {} milliseconds before sending next event", - WebSocketEventProducerClient.class.getName(), eventInterval); - ThreadUtilities.sleep(eventInterval); - - String eventString = null; - if (xmlEvents) { - eventString = EventGenerator.xmlEvent(); - } else { - eventString = EventGenerator.jsonEvent(); - } - client.sendString(eventString); - eventsSentCount++; - LOGGER.debug("{}: host {}, port {}, sent event {}", WebSocketEventProducerClient.class.getName(), host, - port, eventString); - } - LOGGER.debug("{}: completed", WebSocketEventProducerClient.class.getName()); - } - - /** - * Shutdown. - */ - public void shutdown() { - client.stop(); - LOGGER.debug("{}: stopped", WebSocketEventProducerClient.class.getName()); - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - LOGGER.debug("{}: host {}, port {}, received event {}", WebSocketEventProducerServer.class.getName(), host, - port, eventString); - } - - /** - * The main method. - * - * @param args the arguments - * @throws MessagingException the messaging exception - */ - public static void main(final String[] args) throws MessagingException { - if (args.length != 5) { - LOGGER.error("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); - return; - } - - int port = 0; - try { - port = Integer.parseInt(args[1]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - int eventCount = 0; - try { - eventCount = Integer.parseInt(args[2]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - long eventInterval = 0; - try { - eventInterval = Long.parseLong(args[4]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - boolean xmlEvents = false; - if (args[3].equalsIgnoreCase("XML")) { - xmlEvents = true; - } else if (!args[3].equalsIgnoreCase("JSON")) { - LOGGER.error("usage WebSocketEventProducerClient host port #events XML|JSON eventInterval"); - return; - } - - final WebSocketEventProducerClient client = new WebSocketEventProducerClient(args[0], port, eventCount, - xmlEvents, eventInterval); - - client.sendEvents(); - client.shutdown(); - } -} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerServer.java deleted file mode 100644 index 1bdb56ec3..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventProducerServer.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.integration.uservice.adapt.websocket; - -import lombok.Getter; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.testsuites.integration.uservice.adapt.events.EventGenerator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class WebSocketEventProducerServer. - */ -public class WebSocketEventProducerServer implements WsStringMessageListener { - private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketEventProducerServer.class); - - private final int port; - private final int eventCount; - private final boolean xmlEvents; - private final long eventInterval; - @Getter - private long eventsSentCount = 0; - - WsStringMessageServer server; - - /** - * Instantiates a new web socket event producer server. - * - * @param port the port - * @param eventCount the event count - * @param xmlEvents the xml events - * @param eventInterval the event interval - * @throws MessagingException the messaging exception - */ - public WebSocketEventProducerServer(final int port, final int eventCount, final boolean xmlEvents, - final long eventInterval) throws MessagingException { - this.port = port; - this.eventCount = eventCount; - this.xmlEvents = xmlEvents; - this.eventInterval = eventInterval; - - server = new WsStringMessageServer(port); - server.start(this); - - LOGGER.debug("{}: port {}, event count {}, xmlEvents {}", WebSocketEventProducerServer.class.getName(), port, - eventCount, xmlEvents); - } - - /** - * Send events. - */ - public void sendEvents() { - LOGGER.debug("{}: sending events on port {}, event count {}, xmlEvents {}", - WebSocketEventProducerServer.class.getName(), port, eventCount, xmlEvents); - - for (int i = 0; i < eventCount; i++) { - LOGGER.debug("{}: waiting {} milliseconds before sending next event", - WebSocketEventProducerServer.class.getName(), eventInterval); - ThreadUtilities.sleep(eventInterval); - - String eventString = null; - if (xmlEvents) { - eventString = EventGenerator.xmlEvent(); - } else { - eventString = EventGenerator.jsonEvent(); - } - server.sendString(eventString); - eventsSentCount++; - LOGGER.debug("{}: port {}, sent event {}", WebSocketEventProducerServer.class.getName(), port, eventString); - } - - LOGGER.debug("{}: event sending completed", WebSocketEventProducerServer.class.getName()); - } - - /** - * Shutdown. - */ - public void shutdown() { - server.stop(); - LOGGER.debug("{}: stopped", WebSocketEventProducerServer.class.getName()); - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - LOGGER.debug("{}: port {}, received event {}", WebSocketEventProducerServer.class.getName(), port, eventString); - } - - /** - * The main method. - * - * @param args the arguments - * @throws MessagingException the messaging exception - */ - public static void main(final String[] args) throws MessagingException { - if (args.length != 4) { - LOGGER.error("usage WebSocketEventProducerServer port #events XML|JSON eventInterval"); - return; - } - - int port = 0; - try { - port = Integer.parseInt(args[0]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerServer port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - int eventCount = 0; - try { - eventCount = Integer.parseInt(args[1]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerServer port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - long eventInterval = 0; - try { - eventInterval = Long.parseLong(args[3]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventProducerServer port #events XML|JSON eventInterval"); - e.printStackTrace(); - return; - } - - boolean xmlEvents = false; - if (args[2].equalsIgnoreCase("XML")) { - xmlEvents = true; - } else if (!args[2].equalsIgnoreCase("JSON")) { - LOGGER.error("usage WebSocketEventProducerServer port #events XML|JSON startDelay eventInterval"); - return; - } - - final WebSocketEventProducerServer server = new WebSocketEventProducerServer(port, eventCount, xmlEvents, - eventInterval); - - server.sendEvents(); - server.shutdown(); - } -} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberClient.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberClient.java deleted file mode 100644 index 23d32e252..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberClient.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.integration.uservice.adapt.websocket; - -import lombok.Getter; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class WebSocketEventSubscriberClient. - */ -public class WebSocketEventSubscriberClient implements WsStringMessageListener { - private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketEventSubscriberClient.class); - - private final int port; - @Getter - private long eventsReceivedCount = 0; - - private final WsStringMessageClient client; - - /** - * Instantiates a new web socket event subscriber client. - * - * @param host the host - * @param port the port - * @throws MessagingException the messaging exception - */ - public WebSocketEventSubscriberClient(final String host, final int port) throws MessagingException { - this.port = port; - - client = new WsStringMessageClient(host, port); - client.start(this); - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberClient.class.getName(), port, - eventString); - eventsReceivedCount++; - } - - /** - * Shutdown. - */ - public void shutdown() { - client.stop(); - LOGGER.debug("{}: stopped", WebSocketEventSubscriberServer.class.getName()); - } - - /** - * The main method. - * - * @param args the arguments - * @throws MessagingException the messaging exception - */ - public static void main(final String[] args) throws MessagingException { - if (args.length != 2) { - LOGGER.error("usage WebSocketEventSubscriberClient host port"); - return; - } - - int port = 0; - try { - port = Integer.parseInt(args[0]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventSubscriberClient port"); - e.printStackTrace(); - return; - } - - new WebSocketEventSubscriberClient(args[0], port); - } -} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberServer.java deleted file mode 100644 index 41291a467..000000000 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/websocket/WebSocketEventSubscriberServer.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2021 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.integration.uservice.adapt.websocket; - -import lombok.Getter; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingException; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class WebSocketEventSubscriberServer. - */ -public class WebSocketEventSubscriberServer implements WsStringMessageListener { - private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketEventSubscriberServer.class); - - private final int port; - @Getter - private long eventsReceivedCount = 0; - - private final WsStringMessageServer server; - - /** - * Instantiates a new web socket event subscriber server. - * - * @param port the port - * @throws MessagingException the messaging exception - */ - public WebSocketEventSubscriberServer(final int port) throws MessagingException { - this.port = port; - - server = new WsStringMessageServer(port); - server.start(this); - - LOGGER.debug("{}: port {}, waiting for events", WebSocketEventSubscriberServer.class.getName(), port); - } - - /** - * {@inheritDoc}. - */ - @Override - public void receiveString(final String eventString) { - LOGGER.debug("{}: port {}, received event {}", WebSocketEventSubscriberServer.class.getName(), port, - eventString); - eventsReceivedCount++; - } - - /** - * Shutdown. - */ - public void shutdown() { - server.stop(); - LOGGER.debug("{} : stopped", WebSocketEventSubscriberServer.class.getName()); - } - - /** - * The main method. - * - * @param args the arguments - * @throws MessagingException the messaging exception - */ - public static void main(final String[] args) throws MessagingException { - if (args.length != 1) { - LOGGER.error("usage WebSocketEventSubscriberClient port"); - return; - } - - int port = 0; - try { - port = Integer.parseInt(args[0]); - } catch (final Exception e) { - LOGGER.error("usage WebSocketEventSubscriberClient port"); - e.printStackTrace(); - return; - } - - new WebSocketEventSubscriberServer(port); - } -} -- cgit 1.2.3-korg