summaryrefslogtreecommitdiffstats
path: root/client/client-monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'client/client-monitoring')
-rw-r--r--client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java99
1 files changed, 46 insertions, 53 deletions
diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
index 71ca21d2e..f27a53adc 100644
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
+++ b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
@@ -6,15 +6,15 @@
* 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=========================================================
*/
@@ -40,8 +40,7 @@ public class MonitoringRestMainTest {
@Test
public void testMonitoringClientBad() {
try {
- final String[] eventArgs =
- { "-z" };
+ final String[] eventArgs = {"-z"};
ApexMonitoringRestMain.main(eventArgs);
} catch (Exception exc) {
@@ -52,8 +51,7 @@ public class MonitoringRestMainTest {
@Test
public void testMonitoringClientOk() {
try {
- final String[] eventArgs =
- { "-t", "1" };
+ final String[] eventArgs = {"-t", "1"};
ApexMonitoringRestMain.main(eventArgs);
} catch (Exception exc) {
@@ -63,8 +61,7 @@ public class MonitoringRestMainTest {
@Test
public void testMonitoringClientNoOptions() {
- final String[] eventArgs = new String[]
- {};
+ final String[] eventArgs = new String[] {};
final String outputString = testApexMonitoringRestMainConstructor(eventArgs);
@@ -74,121 +71,118 @@ public class MonitoringRestMainTest {
@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));
}
}
@@ -205,8 +199,7 @@ public class MonitoringRestMainTest {
@Test
public void testMonitoringOneSecStart() {
- final String[] eventArgs =
- { "-t", "1" };
+ final String[] eventArgs = {"-t", "1"};
try {
ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
@@ -220,12 +213,12 @@ public class MonitoringRestMainTest {
@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();
}
@@ -233,8 +226,8 @@ public class MonitoringRestMainTest {
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");
@@ -243,7 +236,7 @@ public class MonitoringRestMainTest {
/**
* Run the application.
- *
+ *
* @param eventArgs the command arguments
* @return a string containing the command output
*/