From 46b1c7615d317a74c2c159779f2a5a711292defd Mon Sep 17 00:00:00 2001 From: Herbert Eiselt Date: Thu, 28 Feb 2019 19:12:14 +0100 Subject: SDN-R apigateway add junit test SDN-R apigateway add junit test Change-Id: I81d278cff48e122cf43d81107d0a221e21232e76 Issue-ID: SDNC-682 Signed-off-by: Herbert Eiselt --- sdnr/wt/apigateway/feature/pom.xml | 2 +- sdnr/wt/apigateway/installer/pom.xml | 1 + sdnr/wt/apigateway/pom.xml | 65 +++++++---- sdnr/wt/apigateway/provider/pom.xml | 125 ++++++++++----------- .../apigateway/test/TestMediatorServerServlet.java | 104 +++++++++-------- sdnr/wt/apigateway/provider/tmp3.cfg | 5 - 6 files changed, 158 insertions(+), 144 deletions(-) delete mode 100644 sdnr/wt/apigateway/provider/tmp3.cfg diff --git a/sdnr/wt/apigateway/feature/pom.xml b/sdnr/wt/apigateway/feature/pom.xml index f8ec8b23d..9cde0962e 100644 --- a/sdnr/wt/apigateway/feature/pom.xml +++ b/sdnr/wt/apigateway/feature/pom.xml @@ -51,7 +51,7 @@ org.opendaylight.controller mdsal-artifacts - 1.8.1 + ${odl.controller.mdsal.version} pom import diff --git a/sdnr/wt/apigateway/installer/pom.xml b/sdnr/wt/apigateway/installer/pom.xml index 1d1802691..7ab192b91 100755 --- a/sdnr/wt/apigateway/installer/pom.xml +++ b/sdnr/wt/apigateway/installer/pom.xml @@ -13,6 +13,7 @@ org.onap.ccsdk.parent odlparent-lite 1.2.1-SNAPSHOT + diff --git a/sdnr/wt/apigateway/pom.xml b/sdnr/wt/apigateway/pom.xml index 33ce77264..e59e17cbd 100755 --- a/sdnr/wt/apigateway/pom.xml +++ b/sdnr/wt/apigateway/pom.xml @@ -1,28 +1,51 @@ - - 4.0.0 + + + 4.0.0 - - feature - provider - installer - + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-apigateway-top + 0.4.1-SNAPSHOT + pom + ccsdk-features-sdnr-wt :: ${project.artifactId} - - sdnr-wt-apigateway - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + + + + feature + provider + installer + + + + sdnr-wt-apigateway + diff --git a/sdnr/wt/apigateway/provider/pom.xml b/sdnr/wt/apigateway/provider/pom.xml index d375ee5cd..5f53dbb48 100644 --- a/sdnr/wt/apigateway/provider/pom.xml +++ b/sdnr/wt/apigateway/provider/pom.xml @@ -1,70 +1,67 @@ - + + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - 4.0.0 + 4.0.0 - org.onap.ccsdk.features.sdnr.wt - sdnr-wt-apigateway-provider - 0.4.1-SNAPSHOT - ccsdk-features-sdnr-wt :: ${project.artifactId} - bundle - - true - - - org.onap.ccsdk.parent - binding-parent - 1.2.1-SNAPSHOT - - - - - javax.servlet - servlet-api - 2.5 - - - org.slf4j - slf4j-simple - 1.7.25 - - - org.json - json - 20131018 - - - org.mockito - mockito-core - 2.23.4 - test - + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-apigateway-provider + 0.4.1-SNAPSHOT + ccsdk-features-sdnr-wt :: ${project.artifactId} + bundle + + true + + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + + + + javax.servlet + servlet-api + 2.5 + + + org.slf4j + slf4j-simple + + + org.json + json + + + org.mockito + mockito-core + test + - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestMediatorServerServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestMediatorServerServlet.java index d4197c6db..7fa20f788 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestMediatorServerServlet.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestMediatorServerServlet.java @@ -1,71 +1,69 @@ /* - * ============LICENSE_START======================================================= - * ONAP : CCSDK.apps.sdnr.wt.apigateway - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH 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. - * You may obtain a copy of the License at + * ============LICENSE_START======================================================= ONAP : + * CCSDK.apps.sdnr.wt.apigateway + * ================================================================================ Copyright (C) + * 2019 highstreet technologies GmbH 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. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. - * ============LICENSE_END========================================================= + * 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. ============LICENSE_END========================================================= */ package org.onap.ccsdk.features.sdnr.wt.apigateway.test; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; - import javax.servlet.ServletException; - import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties; import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpMsServlet; import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase; -public class TestMediatorServerServlet extends HelpServletBase{ +public class TestMediatorServerServlet extends HelpServletBase { + + private static final int PORT = 40004; + + public TestMediatorServerServlet() { + super("/ms", PORT); + } + + @Test + public void test() throws ServletException, IOException { + + String tmpFilename = "tmp3.cfg"; + File tmpFile = new File(tmpFilename); + if (tmpFile.exists()) { + tmpFile.delete(); + } + MyProperties.Instantiate(tmpFile, true); + String query = "{\"query\":{\"match_all\":{}}}"; + HelpMsServlet servlet = new HelpMsServlet(); + this.setServlet(servlet); + // test diabled message + servlet.setOfflineStatus(true); + servlet.setBaseUrl("http://localhost:" + PORT); + String expectedResponse = "offline"; + testrequest(HTTPMETHOD_GET, query, expectedResponse, false); + testrequest(HTTPMETHOD_POST, query, expectedResponse, false); + testrequest(HTTPMETHOD_PUT, query, expectedResponse, false); + testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false); + + servlet.setOfflineStatus(false); + testrequest(HTTPMETHOD_GET, query, HelpMsServlet.RESPONSE_GET, true); + testrequest(HTTPMETHOD_POST, query, HelpMsServlet.RESPONSE_POST, true); + testrequest(HTTPMETHOD_PUT, query, HelpMsServlet.RESPONSE_PUT, true); + testrequest(HTTPMETHOD_DELETE, query, HelpMsServlet.RESPONSE_DELETE, true); + testrequest(HTTPMETHOD_OPTIONS, query, "", false); - private static final int PORT = 40004; + if (tmpFile.exists()) { + tmpFile.delete(); + } - public TestMediatorServerServlet() { - super("/ms",PORT); - } - - @Test - public void test() throws ServletException, IOException { - - String tmpFilename = "tmp3.cfg"; - File tmpFile = new File(tmpFilename); - if (tmpFile.exists()) - tmpFile.delete(); - MyProperties.Instantiate(tmpFile,true); - String query = "{\"query\":{\"match_all\":{}}}"; - HelpMsServlet servlet = new HelpMsServlet(); - this.setServlet(servlet); - // test diabled message - servlet.setOfflineStatus(true); - servlet.setBaseUrl("http://localhost:"+PORT); - String expectedResponse = "offline"; - testrequest(HTTPMETHOD_GET, query, expectedResponse, false); - testrequest(HTTPMETHOD_POST, query, expectedResponse, false); - testrequest(HTTPMETHOD_PUT, query, expectedResponse, false); - testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false); - - servlet.setOfflineStatus(false); - testrequest(HTTPMETHOD_GET, query, HelpMsServlet.RESPONSE_GET, true); - testrequest(HTTPMETHOD_POST, query, HelpMsServlet.RESPONSE_POST, true); - testrequest(HTTPMETHOD_PUT, query, HelpMsServlet.RESPONSE_PUT, true); - testrequest(HTTPMETHOD_DELETE, query, HelpMsServlet.RESPONSE_DELETE, true); - testrequest(HTTPMETHOD_OPTIONS, query, "", false); - - } + } } diff --git a/sdnr/wt/apigateway/provider/tmp3.cfg b/sdnr/wt/apigateway/provider/tmp3.cfg deleted file mode 100644 index c8f5897b7..000000000 --- a/sdnr/wt/apigateway/provider/tmp3.cfg +++ /dev/null @@ -1,5 +0,0 @@ -aai=off -aaiHeaders=["X-FromAppId:SDNR","Authorization:Basic QUFJOkFBSQ=="] -database=http://localhost:9200 -insecure=0 -cors=0 \ No newline at end of file -- cgit 1.2.3-korg