diff options
author | liamfallon <liam.fallon@est.tech> | 2020-03-02 17:08:47 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-03-04 08:33:25 +0000 |
commit | 9e5c4b882728ebf3330568d068f109965d599410 (patch) | |
tree | 8ad948a28268b50b97946168b7a8ceab54872dc5 /testsuites/integration/integration-uservice-test/src/test/java | |
parent | 5922128637471bfa1897b8808561000988da733d (diff) |
Preparing integration tests for Graal Javascript
Graal enforces Javascript more strictly than Nashorn does. This review
changes the tests in apex-pdp to comply with the stricter -Javascript
checking, re-enabling the integration test module.
- All log calls must be passed as strings, using toString()
- Byte/Float/Long Java types not supported in Javascript
Disable integration tests so that other changes can be brought in.
JMS integration test is disabled for now, it will be re-enabled in a
review shortly.
Issue-ID: POLICY-2106
Change-Id: I14bdb930eff735e862b51802cf72e4793cec3699
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'testsuites/integration/integration-uservice-test/src/test/java')
4 files changed, 56 insertions, 40 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java index ca2d3ecc0..60b9711c9 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/jms/TestJms2Jms.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +39,7 @@ import org.apache.activemq.security.SimpleAuthenticationPlugin; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; @@ -141,8 +143,9 @@ public class TestJms2Jms { * @throws JMSException the JMS exception */ @Test + @Ignore public void testJmsObjectEvents() throws ApexException, JMSException { - final String[] args = { "-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSObjectEvent.json" }; + final String[] args = {"-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSObjectEvent.json"}; testJmsEvents(args, true); } @@ -154,7 +157,7 @@ public class TestJms2Jms { */ @Test public void testJmsJsonEvents() throws ApexException, JMSException { - final String[] args = { "-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSJsonEvent.json" }; + final String[] args = {"-rfr", "target", "-c", "target/examples/config/JMS/JMS2JMSJsonEvent.json"}; testJmsEvents(args, false); } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java index 6675d9f24..298a56be6 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,11 @@ import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; import java.io.PrintStream; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -87,8 +89,8 @@ public class TestExecutionPropertyRest { throw new IllegalStateException("port " + PORT + " is still in use"); } - server = HttpServletServerFactoryInstance.getServerFactory().build( - "TestExecutionPropertyRest", false, null, PORT, "/TestExecutionRest", false, false); + server = HttpServletServerFactoryInstance.getServerFactory().build("TestExecutionPropertyRest", false, null, + PORT, "/TestExecutionRest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -129,7 +131,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadUrl.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadUrl.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -142,7 +144,7 @@ public class TestExecutionPropertyRest { System.setErr(stderr); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); - assertTrue(outString.contains("no proper URL has been set for event sending on REST client")); + assertTrue(outString.contains("no URL has been set for event sending on RESTCLIENT")); } /** @@ -153,7 +155,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventNoValueSetForTag.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -166,8 +168,8 @@ public class TestExecutionPropertyRest { System.setErr(stderr); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); - assertTrue(outString.contains("key\"Number\"specified on url \"http://localhost:32801/TestExecutionRest/apex" - + "/event/{tagId}/{Number}\"not found in execution properties passed by the current policy")); + assertTrue(outString.contains("key \"Number\" specified on url \"http://localhost:32801/TestExecutionRest/apex" + + "/event/{tagId}/{Number}\" not found in execution properties passed by the current policy")); } /** @@ -178,7 +180,7 @@ public class TestExecutionPropertyRest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = { "src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTEventBadHttpCodeFilter.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(500); @@ -201,8 +203,7 @@ public class TestExecutionPropertyRest { public void testReplaceUrlTag() throws Exception { final Client client = ClientBuilder.newClient(); - final String[] args = - { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json" }; + final String[] args = {"src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1000); apexMain.shutdown(); @@ -226,8 +227,11 @@ public class TestExecutionPropertyRest { @Test public void testReplaceUrlMultiTag() throws Exception { final Client client = ClientBuilder.newClient(); - final String[] args = - { "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" }; + // @formatter:off + final String[] args = { + "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1500); apexMain.shutdown(); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java index 0ae8f703d..e433771f8 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Map; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; @@ -71,8 +72,8 @@ public class TestFile2Rest { */ @BeforeClass public static void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build( - "TestFile2Rest", false, null, PORT, "/TestFile2Rest", false, false); + server = HttpServletServerFactoryInstance.getServerFactory().build("TestFile2Rest", false, null, PORT, + "/TestFile2Rest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -115,8 +116,14 @@ public class TestFile2Rest { public void testFileEventsPost() throws MessagingException, ApexException, IOException { final Client client = ClientBuilder.newClient(); - final String[] args = - { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2RESTJsonEventPost.json" }; + // @formatter:off + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2RESTJsonEventPost.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); Response response = null; @@ -125,7 +132,7 @@ public class TestFile2Rest { for (int i = 0; i < 100; i++) { ThreadUtilities.sleep(100); response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); if (Response.Status.OK.getStatusCode() != response.getStatus()) { break; @@ -154,8 +161,14 @@ public class TestFile2Rest { */ @Test public void testFileEventsPut() throws MessagingException, ApexException, IOException { - final String[] args = - { "-rfr", "target", "-c", "target/examples/config/SampleDomain/File2RESTJsonEventPut.json" }; + // @formatter:off + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2RESTJsonEventPut.json" + }; + // @formatter:on final ApexMain apexMain = new ApexMain(args); final Client client = ClientBuilder.newClient(); @@ -166,7 +179,7 @@ public class TestFile2Rest { for (int i = 0; i < 20; i++) { ThreadUtilities.sleep(300); response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats") - .request("application/json").get(); + .request("application/json").get(); if (Response.Status.OK.getStatusCode() != response.getStatus()) { break; @@ -198,8 +211,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventNoURL.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventNoURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -211,7 +223,7 @@ public class TestFile2Rest { System.setErr(stderr); LOGGER.info("NoUrl-OUTSTRING=\n" + outString + "\nEnd-NoUrl"); - assertTrue(outString.contains(" no URL has been set for event sending on REST client")); + assertTrue(outString.contains(" no URL has been set for event sending on RESTCLIENT")); } /** @@ -226,8 +238,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventBadURL.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadURL.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -240,7 +251,7 @@ public class TestFile2Rest { LOGGER.info("BadUrl-OUTSTRING=\n" + outString + "\nEnd-BadUrl"); assertTrue(outString.contains( - "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" using HTTP \"POST\" failed with status code 404")); + "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" using HTTP \"POST\" failed with status code 404")); } /** @@ -255,8 +266,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(200); @@ -268,9 +278,9 @@ public class TestFile2Rest { System.setErr(stderr); LOGGER.info("BadHttpMethod-OUTSTRING=\n" + outString + "\nEnd-BadHttpMethod"); - assertTrue(outString.contains( - "specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " - + "are supproted for event sending on REST client producer")); + assertTrue(outString + .contains("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" " + + "are supported for event sending on REST client producer")); } /** @@ -285,8 +295,7 @@ public class TestFile2Rest { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); - final String[] args = - { "src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json" }; + final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json"}; final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(2000); @@ -299,7 +308,7 @@ public class TestFile2Rest { LOGGER.info("BadResponse-OUTSTRING=\n" + outString + "\nEnd-BadResponse"); assertTrue(outString.contains( - "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse\"" - + " using HTTP \"POST\" failed with status code 400")); + "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse\"" + + " using HTTP \"POST\" failed with status code 400")); } } diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java index e799f5973..3243cd772 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java @@ -180,7 +180,7 @@ public class TestRest2File { System.setOut(stdout); System.setErr(stderr); - checkRequiredString(outString, " no URL has been set for event sending on REST client"); + checkRequiredString(outString, " no URL has been set for event sending on RESTCLIENT"); } /** |