@Test
public void testDeploymentClientNoOptions() {
- final String[] eventArgs = new String[]
- {};
+ final String[] eventArgs = new String[] {};
assertThat(testApexDeploymentRestMainConstructor(eventArgs)).isEqualTo("*** StdOut ***\n\n*** StdErr ***\n");
}
@Test
public void testDeploymentClientBadOptions() {
- final String[] eventArgs =
- { "-zabbu" };
+ final String[] eventArgs = {"-zabbu"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
- assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
- + "parameter error, invalid command line arguments specified "
- + ": Unrecognized option: -zabbu");
+ assertThat(thrown).isInstanceOf(Exception.class)
+ .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu");
}
@Test
public void testDeploymentClientHelp() {
- final String[] eventArgs =
- { "-h" };
+ final String[] eventArgs = {"-h"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "usage: org.onap.policy.apex.client.deployment.rest.ApexDeploymentRestMain [options...]");
+ "usage: org.onap.policy.apex.client.deployment.rest.ApexDeploymentRestMain [options...]");
}
@Test
public void testDeploymentClientPortBad() {
- final String[] eventArgs =
- { "-p", "hello" };
+ final String[] eventArgs = {"-p", "hello"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
- assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
+ assertThat(thrown).isInstanceOf(Exception.class)
+ .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
}
@Test
public void testDeploymentClientPortNegative() {
- final String[] eventArgs =
- { "-p", "-1" };
+ final String[] eventArgs = {"-p", "-1"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
- + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536");
+ "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+ + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536");
}
@Test
public void testDeploymentClientTtlTooSmall() {
- final String[] eventArgs =
- { "-t", "-2" };
+ final String[] eventArgs = {"-t", "-2"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
- + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
- + "time to live must be greater than -1 (set to -1 to wait forever)");
+ "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+ + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+ + "time to live must be greater than -1 (set to -1 to wait forever)");
}
@Test
public void testDeploymentClientTooManyPars() {
- final String[] eventArgs =
- { "-t", "10", "-p", "12344", "aaa", "bbb" };
+ final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
- assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
- + "parameter error, too many command line arguments specified : [aaa, bbb]");
+ assertThat(thrown).isInstanceOf(Exception.class)
+ .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, too many command line arguments specified : [aaa, bbb]");
}
@Test
@Test
public void testDeploymentClientTtlNotNumber() {
- final String[] eventArgs =
- { "-t", "timetolive" };
+ final String[] eventArgs = {"-t", "timetolive"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
- assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"time-to-live\" :"
- + "For input string: \"timetolive\"");
+ assertThat(thrown).isInstanceOf(Exception.class)
+ .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"");
}
@Test
public void testDeploymentClientPortTooBig() {
- final String[] eventArgs =
- { "-p", "65536" };
+ final String[] eventArgs = {"-p", "65536"};
Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
- + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536");
+ "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+ + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536");
}
@Test
public void testDeploymentOneSecStart() {
- final String[] eventArgs =
- { "-t", "1" };
+ final String[] eventArgs = {"-t", "1"};
assertThatCode(() -> {
ApexDeploymentRestMain monRestMain = new ApexDeploymentRestMain(eventArgs, System.out);
@Test
public void testDeploymentForeverStart() {
- final String[] eventArgs =
- { "-t", "-1" };
+ final String[] eventArgs = {"-t", "-1"};
ApexDeploymentRestMain monRestMain = new ApexDeploymentRestMain(eventArgs, System.out);
assertThatCode(() -> {
monThread.start();
- await().atMost(2, TimeUnit.SECONDS).until(
- () -> monRestMain.getState().equals(ApexDeploymentRestMain.ServicesState.RUNNING));
+ await().atMost(2, TimeUnit.SECONDS)
+ .until(() -> monRestMain.getState().equals(ApexDeploymentRestMain.ServicesState.RUNNING));
monRestMain.shutdown();
}).doesNotThrowAnyException();
}
@Test
public void testServicesClientNoOptions() {
- final String[] eventArgs = new String[]
- {};
+ final String[] eventArgs = new String[] {};
assertThat(testApexServicesRestMainConstructor(eventArgs)).isEqualTo("*** StdOut ***\n\n*** StdErr ***\n");
-
}
@Test
public void testServicesClientBadOptions() {
- final String[] eventArgs =
- { "-zabbu" };
+ final String[] eventArgs = {"-zabbu"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
- assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
- + "parameter error, invalid command line arguments specified "
- + ": Unrecognized option: -zabbu");
+ assertThat(thrown).isInstanceOf(Exception.class)
+ .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu");
}
@Test
public void testServicesClientHelp() {
- final String[] eventArgs =
- { "-h" };
+ final String[] eventArgs = {"-h"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class)
- .hasMessageContaining("usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]");
+ .hasMessageContaining("usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]");
}
@Test
public void testServicesClientPortBad() {
- final String[] eventArgs =
- { "-p", "hello" };
+ final String[] eventArgs = {"-p", "hello"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
+ .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
}
@Test
public void testServicesClientPortNegative() {
- final String[] eventArgs =
- { "-p", "-1" };
+ final String[] eventArgs = {"-p", "-1"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
- + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536");
+ "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+ + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536");
}
@Test
public void testServicesClientTtlTooSmall() {
- final String[] eventArgs =
- { "-t", "-2" };
+ final String[] eventArgs = {"-t", "-2"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
- + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
- + "time to live must be greater than -1 (set to -1 to wait forever)");
+ "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+ + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+ + "time to live must be greater than -1 (set to -1 to wait forever)");
}
@Test
public void testServicesClientTooManyPars() {
- final String[] eventArgs =
- { "-t", "10", "-p", "12344", "aaa", "bbb" };
+ final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
- + "parameter error, too many command line arguments specified : [aaa, bbb]");
+ .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, too many command line arguments specified : [aaa, bbb]");
}
-
@Test
public void testServicesClientTtlNotNumber() {
- final String[] eventArgs =
- { "-t", "timetolive" };
+ final String[] eventArgs = {"-t", "timetolive"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class)
- .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"time-to-live\" :"
- + "For input string: \"timetolive\"");
+ .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"");
}
@Test
@Test
public void testServicesClientPortTooBig() {
- final String[] eventArgs =
- { "-p", "65536" };
+ final String[] eventArgs = {"-p", "65536"};
Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
- "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
- + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536");
+ "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+ + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536");
}
@Test
assertThatCode(() -> {
monThread.start();
- await().atMost(6, TimeUnit.SECONDS).until(
- () -> monRestMain.getState().equals(ApexServicesRestMain.EditorState.RUNNING));
+ await().atMost(6, TimeUnit.SECONDS)
+ .until(() -> monRestMain.getState().equals(ApexServicesRestMain.EditorState.RUNNING));
monRestMain.shutdown();
}).doesNotThrowAnyException();
}
* 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=========================================================
*/
@Test
public void testMonitoringClientBad() {
try {
- final String[] eventArgs =
- { "-z" };
+ final String[] eventArgs = {"-z"};
ApexMonitoringRestMain.main(eventArgs);
} catch (Exception exc) {
@Test
public void testMonitoringClientOk() {
try {
- final String[] eventArgs =
- { "-t", "1" };
+ final String[] eventArgs = {"-t", "1"};
ApexMonitoringRestMain.main(eventArgs);
} catch (Exception exc) {
@Test
public void testMonitoringClientNoOptions() {
- final String[] eventArgs = new String[]
- {};
+ final String[] eventArgs = new String[] {};
final String outputString = testApexMonitoringRestMainConstructor(eventArgs);
@Test
public void testMonitoringClientBadOptions() {
- final String[] eventArgs =
- { "-zabbu" };
+ final String[] eventArgs = {"-zabbu"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
- assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
- + "parameter error, invalid command line arguments specified "
- + ": Unrecognized option: -zabbu", ex.getMessage().substring(0, 170));
+ assertEquals(
+ "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu",
+ ex.getMessage().substring(0, 170));
}
}
@Test
public void testMonitoringClientHelp() {
- final String[] eventArgs =
- { "-h" };
+ final String[] eventArgs = {"-h"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("usage: org.onap.policy.apex.client.monitoring.rest.ApexMonitoringRestMain [options...]",
- ex.getMessage().substring(0, 86));
+ ex.getMessage().substring(0, 86));
}
}
@Test
public void testMonitoringClientPortBad() {
- final String[] eventArgs =
- { "-p", "hello" };
+ final String[] eventArgs = {"-p", "hello"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
- assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"port\" :For input string: \"hello\"",
- ex.getMessage().substring(0, 156));
+ assertEquals(
+ "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"port\" :For input string: \"hello\"",
+ ex.getMessage().substring(0, 156));
}
}
@Test
public void testMonitoringClientPortNegative() {
- final String[] eventArgs =
- { "-p", "-1" };
+ final String[] eventArgs = {"-p", "-1"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
- + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 227));
+ + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 227));
}
}
@Test
public void testMonitoringClientTtlTooSmall() {
- final String[] eventArgs =
- { "-t", "-2" };
+ final String[] eventArgs = {"-t", "-2"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
- assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
- + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
- + "time to live must be greater than -1 (set to -1 to wait forever)",
- ex.getMessage().substring(0, 244));
+ assertEquals(
+ "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
+ + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+ + "time to live must be greater than -1 (set to -1 to wait forever)",
+ ex.getMessage().substring(0, 244));
}
}
@Test
public void testMonitoringClientTooManyPars() {
- final String[] eventArgs =
- { "-t", "10", "-p", "12344", "aaa", "bbb" };
+ final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
- assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
- + "parameter error, too many command line arguments specified : [aaa, bbb]",
- ex.getMessage().substring(0, 154));
+ assertEquals(
+ "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, too many command line arguments specified : [aaa, bbb]",
+ ex.getMessage().substring(0, 154));
}
}
@Test
public void testMonitoringClientTtlNotNumber() {
- final String[] eventArgs =
- { "-t", "timetolive" };
+ final String[] eventArgs = {"-t", "timetolive"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
- assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
- + "parameter error, error parsing argument \"time-to-live\" :"
- + "For input string: \"timetolive\"", ex.getMessage().substring(0, 169));
+ assertEquals(
+ "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+ + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"",
+ ex.getMessage().substring(0, 169));
}
}
@Test
public void testMonitoringClientPortTooBig() {
- final String[] eventArgs =
- { "-p", "65536" };
+ final String[] eventArgs = {"-p", "65536"};
try {
new ApexMonitoringRestMain(eventArgs, System.out);
fail("test should throw an exception");
} catch (Exception ex) {
assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
- + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
- + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 230));
+ + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+ + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 230));
}
}
@Test
public void testMonitoringOneSecStart() {
- final String[] eventArgs =
- { "-t", "1" };
+ final String[] eventArgs = {"-t", "1"};
try {
ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
@Test
public void testMonitoringForeverStart() {
- final String[] eventArgs =
- { "-t", "-1" };
+ final String[] eventArgs = {"-t", "-1"};
ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
Thread monThread = new Thread() {
+ @Override
public void run() {
monRestMain.init();
}
try {
monThread.start();
- await().atMost(6, TimeUnit.SECONDS).until(
- () -> monRestMain.getState().equals(ApexMonitoringRestMain.ServicesState.RUNNING));
+ await().atMost(6, TimeUnit.SECONDS)
+ .until(() -> monRestMain.getState().equals(ApexMonitoringRestMain.ServicesState.RUNNING));
monRestMain.shutdown();
} catch (Exception ex) {
fail("test should not throw an exception");
/**
* Run the application.
- *
+ *
* @param eventArgs the command arguments
* @return a string containing the command output
*/
package org.onap.policy.apex.core.deployment;
+import static org.awaitility.Awaitility.await;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.common.utils.resources.TextFileUtils;
-import static org.awaitility.Awaitility.await;
-
/**
* Dummy deployment client.
*/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.concurrent.TimeUnit;
+
import org.junit.Test;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import java.util.concurrent.TimeUnit;
-
/**
* The Class EndToEndMessagingTest.
*
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import java.util.concurrent.CountDownLatch;
-
/**
* The Class ThreadingTestThread.
*
private String threadName;
- private CountDownLatch latch = new CountDownLatch(1);
-
- /**
+ /**
* {@inheritDoc}.
*/
@Override
if (logger.isDebugEnabled()) {
logger.debug("in threading test thread \"" + threadName + "\", counter=" + counter + " . . .");
}
- if(!ThreadUtilities.sleep(50)) {
+ if (!ThreadUtilities.sleep(50)) {
interrupted = true;
}
}
package org.onap.policy.apex.examples.aadm;
+import static org.awaitility.Awaitility.await;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.core.engine.engine.EnEventListener;
import org.onap.policy.apex.core.engine.event.EnEvent;
-import static org.awaitility.Awaitility.await;
/**
* The listener interface for receiving testApexAction events. The class that is interested in processing a
package org.onap.policy.apex.examples.adaptive;
+import static org.awaitility.Awaitility.await;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.core.engine.engine.EnEventListener;
import org.onap.policy.apex.core.engine.event.EnEvent;
-import static org.awaitility.Awaitility.await;
-
/**
* The listener interface for receiving testApexAction events. The class that is interested in processing a
* testApexAction event implements this interface, and the object created with that class is registered with a component
assertTrue(stats.equals(stats));
assertTrue(stats.equals(clonedStats));
assertFalse(stats.equals(null));
- assertFalse(stats.equals("Hello"));
+
+ Object helloObject = "Hello";
+ assertFalse(stats.equals(helloObject));
assertFalse(stats.equals(new AxEngineStats(new AxReferenceKey())));
assertEquals(0, stats.compareTo(stats));
package org.onap.policy.apex.plugins.event.carrier.kafka;
-import java.util.EnumMap;
-import java.util.Map;
import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Kick off the Kafka producer
kafkaProducer = new KafkaProducer<>(kafkaProducerProperties.getKafkaProducerProperties());
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("event producer " + this.name + " is ready to send to topics: "
- + kafkaProducerProperties.getProducerTopic());
+ LOGGER.debug("event producer {} is ready to send to topics: {}", this.name,
+ kafkaProducerProperties.getProducerTopic());
}
}
// We have not set the URL, this test should not receive any events
arcc.start();
await().atMost(400, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
- .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
+ .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
}
// We have not set the URL, this test should not receive any events
arcc.start();
await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
- .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
+ .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
// We have not set the URL, this test should not receive any events
arcc.start();
- await().atMost(400, TimeUnit.MILLISECONDS).until(
- () -> incomingEventReceiver.getLastEvent().equals("This is an event"));
+ await().atMost(400, TimeUnit.MILLISECONDS)
+ .until(() -> incomingEventReceiver.getLastEvent().equals("This is an event"));
arcc.stop();
}
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Level;
/**
* Test the ApexRestClientProducer class.
*
*/
public class ApexRestClientProducerTest {
- private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestClientProducer.class);
-
@Mock
private Client httpClientMock;
public void testApexRestClientProducerPostEventCacheTrace() throws ApexEventException {
MockitoAnnotations.initMocks(this);
- ch.qos.logback.classic.Logger classicLogger = (ch.qos.logback.classic.Logger) LOGGER;
- classicLogger.setLevel(Level.TRACE);
-
ApexRestClientProducer arcp = new ApexRestClientProducer();
assertNotNull(arcp);
package org.onap.policy.apex.plugins.event.carrier.websocket;
-import java.util.EnumMap;
-import java.util.Map;
import java.util.Properties;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexWebSocketProducer extends ApexPluginsEventProducer implements WsStringMessageListener {
+public class ApexWebSocketProducer extends ApexPluginsEventProducer implements WsStringMessageListener {
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class);
@Override
public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
final Object event) {
- super.sendEvent(executionId, executionProperties, eventName, event );
+ super.sendEvent(executionId, executionProperties, eventName, event);
wsStringMessager.sendString((String) event);
}
package org.onap.policy.apex.service.engine.event;
-import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-
import java.util.EnumMap;
import java.util.Map;
import java.util.Properties;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+
public abstract class ApexPluginsEventProducer implements ApexEventProducer {
// The name for this producer
protected String name = null;
// The peer references for this event handler
- protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+ protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
+ new EnumMap<>(EventHandlerPeeredMode.class);
/**
* {@inheritDoc}.
*/
@Override
public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
- final Object event) {
+ final Object event) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import java.util.EnumMap;
-import java.util.Map;
import java.util.Properties;
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.ApexPluginsEventProducer;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
+import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* {@inheritDoc}.
*/
@Override
- public void init(final String producerName, final EventHandlerParameters producerParameters) throws ApexEventException {
+ public void init(final String producerName, final EventHandlerParameters producerParameters)
+ throws ApexEventException {
this.name = producerName;
// Get and check the Apex parameters from the parameter service
} catch (final IOException e) {
final String errorMessage = "ApexFileProducer \"" + producerName + "\" failed to open file for writing: \""
+ fileCarrierTechnologyParameters.getFileName() + "\"";
- LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
try {
stringEvent = (String) event;
} catch (final Exception e) {
- final String errorMessage = "error in ApexFileProducer \"" + name + "\" while transferring event \""
- + event + "\" to the output stream";
- LOGGER.debug(errorMessage, e);
+ final String errorMessage = "error in ApexFileProducer \"" + name + "\" while transferring event \"" + event
+ + "\" to the output stream";
throw new ApexEventRuntimeException(errorMessage, e);
}
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
- <version>3.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>