aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java4
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java6
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java31
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlTaggedEventConsumerTest.java286
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java4
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java6
6 files changed, 117 insertions, 220 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
index fafde8b98..20d6feb5b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
@@ -36,9 +37,11 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
@@ -47,6 +50,7 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
* This class tests the ApexRestClientConusmer class.
*
*/
+@RunWith(MockitoJUnitRunner.class)
public class ApexRestClientConusmerTest {
private final PrintStream stdout = System.out;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
index ac8271309..ac35081f2 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 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.
@@ -31,9 +32,11 @@ import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
@@ -45,6 +48,7 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo
* Test the ApexRestClientProducer class.
*
*/
+@RunWith(MockitoJUnitRunner.class)
public class ApexRestClientProducerTest {
@Mock
private Client httpClientMock;
@@ -293,4 +297,4 @@ public class ApexRestClientProducerTest {
.hasMessageContaining("send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" "
+ "failed with status code 400");
}
-} \ No newline at end of file
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
index fdf094f54..d5268b14c 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParametersTest.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * 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.
@@ -41,35 +42,29 @@ public class RestRequestorCarrierTechnologyParametersTest {
@Test
public void testRestRequestorCarrierTechnologyParametersBadList() {
- ApexCommandLineArguments arguments = new ApexCommandLineArguments();
- arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderBadList.json");
- arguments.setRelativeFileRoot(".");
-
- assertThatThrownBy(() -> {
- new ApexParameterHandler().getParameters(arguments);
- }).hasMessageContaining("HTTP header array entry is null\n parameter");
+ verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderBadList.json",
+ "HTTP header array entry is null\n parameter");
}
@Test
public void testRestRequestorCarrierTechnologyParametersNotKvPairs() {
- ApexCommandLineArguments arguments = new ApexCommandLineArguments();
- arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNotKvPairs.json");
- arguments.setRelativeFileRoot(".");
-
- assertThatThrownBy(() -> {
- new ApexParameterHandler().getParameters(arguments);
- }).hasMessageContaining("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]");
+ verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNotKvPairs.json",
+ "HTTP header array entries must have one key and one value: [aaa, bbb, ccc]");
}
@Test
public void testRestRequestorCarrierTechnologyParametersNulls() {
+ verifyException("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNulls.json",
+ "HTTP header key is null or blank: [null, bbb]");
+ }
+
+ private void verifyException(String fileName, String expectedMsg) {
ApexCommandLineArguments arguments = new ApexCommandLineArguments();
- arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTRequestorWithHTTPHeaderNulls.json");
+ arguments.setToscaPolicyFilePath(fileName);
arguments.setRelativeFileRoot(".");
- assertThatThrownBy(() -> {
- new ApexParameterHandler().getParameters(arguments);
- }).hasMessageContaining("HTTP header key is null or blank: [null, bbb]");
+ assertThatThrownBy(() -> new ApexParameterHandler().getParameters(arguments)).describedAs(fileName)
+ .hasMessageContaining(expectedMsg);
}
@Test
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlTaggedEventConsumerTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlTaggedEventConsumerTest.java
index 52b84bc5b..320d7ba22 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlTaggedEventConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlTaggedEventConsumerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
@@ -44,14 +45,7 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testGarbageTextLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream("hello there".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertNull(textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyNull("testGarbageTextLine", "hello there");
}
/**
@@ -61,15 +55,7 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testPartialEventLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "1469781869268</TestTimestamp></MainTag>".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertNull(textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyNull("testPartialEventLine", "1469781869268</TestTimestamp></MainTag>");
}
/**
@@ -79,15 +65,8 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>", textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventLine", "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>",
+ "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>");
}
/**
@@ -97,14 +76,8 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventGarbageBeforeLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testFullEventGarbageBeforeLine",
+ "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>");
}
/**
@@ -114,15 +87,8 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventGarbageBeforeAfterLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish"
- .getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testFullEventGarbageBeforeAfterLine",
+ "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish");
}
/**
@@ -132,16 +98,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventGarbageAfterLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventGarbageAfterLine",
+ "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish",
+ "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>Rubbish");
}
/**
@@ -151,13 +110,7 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testGarbageTextMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream("hello\nthere".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testGarbageTextMultiLine", "hello\nthere");
}
/**
@@ -167,14 +120,7 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testPartialEventMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "1469781869268\n</TestTimestamp>\n</MainTag>".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testPartialEventMultiLine", "1469781869268\n</TestTimestamp>\n</MainTag>");
}
/**
@@ -184,16 +130,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventMultiLine",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
}
/**
@@ -203,17 +142,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventGarbageBeforeMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n"
- .getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventGarbageBeforeMultiLine",
+ "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n\n",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
}
/**
@@ -225,15 +156,9 @@ public class XmlTaggedEventConsumerTest {
public void testFullEventGarbageBeforeAfterMultiLine() throws IOException {
String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>"
+ "\n</MainTag>\nRubbish\n\n";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventsGarbageAfterLine", garbageString,
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
}
/**
@@ -243,17 +168,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventGarbageAfterMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"
- .getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventGarbageAfterMultiLine",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
}
/**
@@ -263,15 +180,8 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testPartialEventsLine() throws IOException {
- String garbageString = "1469781869268</TestTimestamp></MainTag><?xml><MainTag>"
- + "<TestTimestamp>1469781869268</TestTimestamp>";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testPartialEventsLine", "1469781869268</TestTimestamp></MainTag><?xml><MainTag>"
+ + "<TestTimestamp>1469781869268</TestTimestamp>");
}
/**
@@ -281,15 +191,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventsGarbageBeforeLine() throws IOException {
- String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>"
- + "<?xml><MainTag><TestTimestamp>";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testPartialEventsLine",
+ "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp></MainTag>"
+ + "<?xml><MainTag><TestTimestamp>");
}
/**
@@ -299,15 +203,8 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventsGarbageBeforeAfterLine() throws IOException {
- String garbageString = "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
- + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertTrue(textBlock.isEndOfText());
+ verifyEnd("testFullEventGarbageBeforeLine", "Garbage<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
+ + "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>\nRefuse");
}
/**
@@ -319,14 +216,8 @@ public class XmlTaggedEventConsumerTest {
public void testFullEventsGarbageAfterLine() throws IOException {
String garbageString = "<?xml><MainTag><TestTimestamp>1469781869268</TestTimestamp>"
+ "</MainTag>Rubbish<?xml><MainTag><TestTimestamp>Refuse";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals(textBlock.getText(), garbageString);
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testFullEventsGarbageAfterLine", garbageString, garbageString);
}
/**
@@ -336,15 +227,9 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testPartialEventsMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>".getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>", textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLine("testPartialEventsMultiLine",
+ "1469781869268\n</TestTimestamp>\n</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>",
+ "<?xml>\n<MainTag>\n<TestTimestamp>");
}
/**
@@ -356,20 +241,10 @@ public class XmlTaggedEventConsumerTest {
public void testFullEventsMultiLine() throws IOException {
String garbageString = "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ "</MainTag>\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertFalse(textBlock.isEndOfText());
- textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLines("testFullEventsMultiLine", garbageString,
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
}
/**
@@ -381,20 +256,10 @@ public class XmlTaggedEventConsumerTest {
public void testFullEventsGarbageBeforeMultiLine() throws IOException {
String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ "</MainTag>\n\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\n";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
-
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertFalse(textBlock.isEndOfText());
- textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLines("testFullEventsGarbageBeforeMultiLine", garbageString,
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>");
}
/**
@@ -407,20 +272,10 @@ public class XmlTaggedEventConsumerTest {
String garbageString = "Garbage\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ "</MainTag>\nRubbish\n<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n"
+ "</MainTag>\nRefuse\n";
- final InputStream xmlInputStream = new ByteArrayInputStream(garbageString.getBytes());
- final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
- xmlTaggedReader.init(xmlInputStream);
-
- TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
- textBlock.getText());
- assertFalse(textBlock.isEndOfText());
-
- textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ verifyLines("testFullEventsGarbageBeforeAfterMultiLine", garbageString,
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRefuse");
}
/**
@@ -430,16 +285,55 @@ public class XmlTaggedEventConsumerTest {
*/
@Test
public void testFullEventsGarbageAfterMultiLine() throws IOException {
- final InputStream xmlInputStream = new ByteArrayInputStream(
- "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish"
- .getBytes());
+ verifyLine("testFullEventsGarbageAfterMultiLine",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
+ "<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish");
+ }
+
+ private void verifyNull(String testName, String xml) throws IOException {
+ final InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
+
+ final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
+ xmlTaggedReader.init(xmlInputStream);
+
+ final TextBlock textBlock = xmlTaggedReader.readTextBlock();
+ assertNull(testName, textBlock.getText());
+ assertTrue(testName, textBlock.isEndOfText());
+ }
+
+ private void verifyLine(String testName, String xml, String expected) throws IOException {
+ final InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
+
+ final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
+ xmlTaggedReader.init(xmlInputStream);
+
+ final TextBlock textBlock = xmlTaggedReader.readTextBlock();
+ assertEquals(testName, expected, textBlock.getText());
+ assertTrue(testName, textBlock.isEndOfText());
+ }
+
+ private void verifyLines(String testName, String xml, String expected, String expected2) throws IOException {
+ final InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
+
+ final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
+ xmlTaggedReader.init(xmlInputStream);
+
+ TextBlock textBlock = xmlTaggedReader.readTextBlock();
+ assertEquals(testName, expected, textBlock.getText());
+ assertFalse(testName, textBlock.isEndOfText());
+
+ textBlock = xmlTaggedReader.readTextBlock();
+ assertEquals(testName, expected2, textBlock.getText());
+ assertTrue(testName, textBlock.isEndOfText());
+ }
+
+ private void verifyEnd(String testName, String xml) throws IOException {
+ final InputStream xmlInputStream = new ByteArrayInputStream(xml.getBytes());
final HeaderDelimitedTextBlockReader xmlTaggedReader = new HeaderDelimitedTextBlockReader("<?xml", null, true);
xmlTaggedReader.init(xmlInputStream);
final TextBlock textBlock = xmlTaggedReader.readTextBlock();
- assertEquals("<?xml>\n<MainTag>\n<TestTimestamp>1469781869268</TestTimestamp>\n</MainTag>\nRubbish",
- textBlock.getText());
- assertTrue(textBlock.isEndOfText());
+ assertTrue(testName, textBlock.isEndOfText());
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
index 0577be703..ab911499a 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/YamlPluginStabilityTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -21,11 +22,8 @@
package org.onap.policy.apex.plugins.event.protocol.yaml;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
index 031d605e1..991c89bcb 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskExecutorTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 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.
@@ -117,8 +118,9 @@ public class JavascriptTaskExecutorTest {
task.getTaskLogic().setLogic("var x = 5;");
jte.prepare();
+ Properties props = new Properties();
assertThatThrownBy(() -> {
- jte.execute(-1, new Properties(), null);
+ jte.execute(-1, props, null);
}).isInstanceOf(NullPointerException.class);
jte.cleanUp();
@@ -128,7 +130,7 @@ public class JavascriptTaskExecutorTest {
assertThatThrownBy(() -> {
jte.prepare();
- jte.execute(-1, new Properties(), incomingParameters);
+ jte.execute(-1, props, incomingParameters);
}).hasMessage("execute-post: task logic execution failure on task \"TestTask\" in model NULL:0.0.0");
jte.cleanUp();