diff options
author | Dan Timoney <dtimoney@att.com> | 2019-03-06 20:31:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-06 20:31:13 +0000 |
commit | 16f322b6f8d5ab0d0d7b55d2e626e18afcba53f1 (patch) | |
tree | c75fd916d42224cef96019b1d6cb5d613d22882e /sdnr/wt/apigateway/provider | |
parent | 02c5ac21fde242f7bd12525fc244bdbe64f1a4e6 (diff) | |
parent | 46b1c7615d317a74c2c159779f2a5a711292defd (diff) |
Merge "SDN-R apigateway add junit test"
Diffstat (limited to 'sdnr/wt/apigateway/provider')
3 files changed, 112 insertions, 122 deletions
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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- * ============LICENSE_START======================================================= - * ONAP : CCSDK.sdnr.wt.apigateway.provider * ================================================================================ - * Copyright (C) 2018 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 * - * 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========================================================= --> +<!-- * ============LICENSE_START======================================================= + * ONAP : CCSDK.sdnr.wt.apigateway.provider * ================================================================================ + * Copyright (C) 2018 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 * + * 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========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" - 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"> + 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"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> - <artifactId>sdnr-wt-apigateway-provider</artifactId> - <version>0.4.1-SNAPSHOT</version> - <name>ccsdk-features-sdnr-wt :: ${project.artifactId}</name> - <packaging>bundle</packaging> - <properties> - <checkstyle.skip>true</checkstyle.skip> - </properties> - <parent> - <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>binding-parent</artifactId> - <version>1.2.1-SNAPSHOT</version> - <relativePath /> - </parent> - <dependencies> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <version>1.7.25</version> - </dependency> - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - <version>20131018</version> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.23.4</version> - <scope>test</scope> - </dependency> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-apigateway-provider</artifactId> + <version>0.4.1-SNAPSHOT</version> + <name>ccsdk-features-sdnr-wt :: ${project.artifactId}</name> + <packaging>bundle</packaging> + <properties> + <checkstyle.skip>true</checkstyle.skip> + </properties> + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>binding-parent</artifactId> + <version>1.2.1-SNAPSHOT</version> + <relativePath /> + </parent> + <dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> - </dependencies> - <build> - <plugins> - <!-- fixed bug for sonarcube --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <useSystemClassLoader>false</useSystemClassLoader> - </configuration> - </plugin> - </plugins> - </build> + </dependencies> + <build> + <plugins> + <!-- fixed bug for sonarcube --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + </configuration> + </plugin> + </plugins> + </build> </project> 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 |