From 042a8f5ec583a7431971847995f1aabd9bc48366 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 6 Jul 2020 09:31:18 +0100 Subject: Fix URL checking on REST plugins The URL parameter must always be provided on the REST client carrier plugin The URL parameter must always be provided on the REST requestor consumer The URL parameter is not required on the REST requestor producer This patch fixes the implementation to always checks the URL for existence on the REST Client plugin. The current checks on the REST Requestor are correct for the REST requestor plugin consumer and producer classes, so the checks are not required in the REST Requestor parameters. Issue-ID: POLICY-2692 Change-Id: I4e1534202002cf4a03bd159ac97b2a4f5b1746ab Signed-off-by: liamfallon --- .../restclient/TestExecutionPropertyRest.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'testsuites') 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 e483597d0..71c8833be 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 @@ -63,8 +63,7 @@ public class TestExecutionPropertyRest { @BeforeClass public static void compilePolicy() { // @formatter:off - final String[] cliArgs = { - "-c", + final String[] cliArgs = { "-c", "src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex", "-l", "target/ExecutionPropertiesRestTestPolicyModel.log", @@ -88,7 +87,7 @@ public class TestExecutionPropertyRest { } server = HttpServletServerFactoryInstance.getServerFactory().build("TestExecutionPropertyRest", false, null, - PORT, "/TestExecutionRest", false, false); + PORT, "/TestExecutionRest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -129,7 +128,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 +141,8 @@ public class TestExecutionPropertyRest { System.setErr(stderr); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); - assertTrue(outString.contains("no URL has been set for event sending on RESTCLIENT")); + assertTrue(outString.contains("invalid URL http://localhost:32801/TestExecutionRest/apex/event/tagId}" + + " has been set for event sending on RESTCLIENT")); } /** @@ -153,7 +153,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); @@ -167,7 +167,7 @@ public class TestExecutionPropertyRest { 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")); + + "/event/{tagId}/{Number}\" not found in execution properties passed by the current policy")); } /** @@ -178,7 +178,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,7 +201,8 @@ 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(); @@ -212,7 +213,7 @@ public class TestExecutionPropertyRest { Response response = null; response = client.target("http://localhost:32801/TestExecutionRest/apex/event/GetProperUrl") - .request("application/json").get(); + .request("application/json").get(); LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outString + "\nEnd-TagUrl"); final String responseEntity = response.readEntity(String.class); @@ -227,8 +228,7 @@ public class TestExecutionPropertyRest { final Client client = ClientBuilder.newClient(); // @formatter:off final String[] args = { - "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" - }; + "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToMultiTagUrlOK.json" }; // @formatter:on final ApexMain apexMain = new ApexMain(args); ThreadUtilities.sleep(1500); @@ -238,7 +238,7 @@ public class TestExecutionPropertyRest { System.setErr(stderr); Response response = null; response = client.target("http://localhost:32801/TestExecutionRest/apex/event/GetProperUrl") - .request("application/json").get(); + .request("application/json").get(); final String responseEntity = response.readEntity(String.class); LOGGER.info("testReplaceUrlMultiTag-OUTSTRING=\n" + responseEntity + "\nEnd-MultiTagUrl"); assertTrue(responseEntity.contains("\"PostProperUrl\": 3")); -- cgit 1.2.3-korg