summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/apigateway/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/apigateway/provider/src/test')
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java87
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java93
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java114
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java62
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java63
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java58
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java206
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java41
-rw-r--r--sdnr/wt/apigateway/provider/src/test/resources/log4j.properties33
9 files changed, 0 insertions, 757 deletions
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
deleted file mode 100644
index 3436c36f2..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ============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
- *
- * 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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpAaiServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpEsServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
-
-public class TestAaiServlet extends HelpServletBase {
-
- private static final int PORT = 40001;
-
- public TestAaiServlet() {
- super("/aai", PORT);
- }
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile, true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent =
- "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=http://" + HOST + ":" + PORT + LR + "aaiHeaders=[]" + LR + "database=off" + LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpAaiServlet());
- // test disabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- 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);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
- if (tmpFile.exists())
- tmpFile.delete();
-
- }
-
- @Before
- public void init() throws IOException {
- HelpServletBase.initEsTestWebserver(PORT);
- }
-
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
deleted file mode 100644
index 45eac88cd..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ============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
- *
- * 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 org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpEsServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
-import java.io.*;
-import javax.servlet.ServletException;
-
-public class TestDatabaseServlet extends HelpServletBase {
-
- private static final int PORT = 40002;
-
- public TestDatabaseServlet() {
- super("/database", PORT);
- }
-
-
-
- final String LR = "\n";
-
-
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp1.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile, true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent =
- "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=http://" + HOST + ":" + PORT + LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpEsServlet());
- // test diabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- 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);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
-
-
- if (tmpFile.exists())
- tmpFile.delete();
-
-
- }
-
- @Before
- public void init() throws IOException {
- HelpServletBase.initEsTestWebserver(PORT);
- }
-
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
deleted file mode 100644
index 761afe20e..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * ============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
- *
- * 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 static org.junit.Assert.*;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-
-public class TestProperties {
-
- private static final boolean DEFAULT_CORSENABLED = false;
- private static final boolean DEFAULT_AAIOFF = true;
- private static final boolean DEFAULT_ESOFF = false;
- private static final boolean DEFAULT_TRUSTINSECURE = false;
- private static final String DEFAULT_AAIBASEURL = "off";
- private static Map<String, String> DEFAULT_AAIHEADERS = new HashMap<String, String>();
- private static final String DEFAULT_ESBASEURL = "http://sdnrdb:9200";
-
- private static final boolean CUSTOM_CORSENABLED = true;
- private static final boolean CUSTOM_AAIOFF = false;
- private static final boolean CUSTOM_ESOFF = false;
- private static final boolean CUSTOM_TRUSTINSECURE = true;
- private static final String CUSTOM_AAIBASEURL = "https://aai.tld:2214";
- private static Map<String, String> CUSTOM_AAIHEADERS = new HashMap<String, String>();
- private static final String CUSTOM_ESBASEURL = "http://localhost:9200";
-
- private static final String LR = "\n";
- final String tmpFilename = "tmp2.cfg";
-
- @Before
- @After
- public void init() {
- File f = new File(tmpFilename);
- if (f.exists()) {
- f.delete();
- }
- }
-
- @Test
- public void test() {
- DEFAULT_AAIHEADERS.put("X-FromAppId", "SDNR");
- DEFAULT_AAIHEADERS.put("Authorization", "Basic QUFJOkFBSQ==");
- CUSTOM_AAIHEADERS.put("X-FromAppId", "SDNC");
- CUSTOM_AAIHEADERS.put("Authorization", "Basic 1234");
- final String TESTPROPERTYFILECONTENT = "aai=" + CUSTOM_AAIBASEURL + LR + "aaiHeaders=[\"X-FromAppId:"
- + CUSTOM_AAIHEADERS.get("X-FromAppId") + "\",\"Authorization:" + CUSTOM_AAIHEADERS.get("Authorization")
- + "\"]" + LR + "database=" + CUSTOM_ESBASEURL + LR + "insecure=" + (CUSTOM_TRUSTINSECURE ? "1" : "0")
- + LR + "cors=" + (CUSTOM_CORSENABLED ? "1" : "0");
- File ftest = new File(tmpFilename);
- MyProperties prop = null;
- ftest = new File(tmpFilename);
- try {
- prop = MyProperties.Instantiate(ftest, true);
- } catch (Exception e) {
- fail("error instantiating properties");
- }
- assertNotNull("problem without exception instantiating properties", prop);
-
- assertEquals("default config file was not created", true, ftest.exists());
-
- // test default values
- assertEquals("default value is not correct", DEFAULT_CORSENABLED, prop.corsEnabled());
- assertEquals("default value is not correct", DEFAULT_AAIOFF, prop.isAAIOff());
- assertEquals("default value is not correct", DEFAULT_ESOFF, prop.isEsOff());
- assertEquals("default value is not correct", DEFAULT_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("default value is not correct", DEFAULT_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("default value is not correct", DEFAULT_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("default value is not correct", DEFAULT_ESBASEURL, prop.getEsBaseUrl());
-
- try {
- prop.load(new ByteArrayInputStream(TESTPROPERTYFILECONTENT.getBytes()));
- } catch (Exception e) {
- fail("error loading custom values into properties");
- }
-
- // test custom values
- assertEquals("custom value is not correct", CUSTOM_CORSENABLED, prop.corsEnabled());
- assertEquals("custom value is not correct", CUSTOM_AAIOFF, prop.isAAIOff());
- assertEquals("custom value is not correct", CUSTOM_ESOFF, prop.isEsOff());
- assertEquals("custom value is not correct", CUSTOM_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("custom value is not correct", CUSTOM_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("custom value is not correct", CUSTOM_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("custom value is not correct", CUSTOM_ESBASEURL, prop.getEsBaseUrl());
-
- // delete autogenerated testfile
- ftest.delete();
-
- }
-
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
deleted file mode 100644
index 5d4c8f507..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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=========================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.AaiServlet;
-
-public class HelpAaiServlet extends AaiServlet implements IPublicServlet {
-
- private static final long serialVersionUID = 1L;
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
deleted file mode 100644
index fe89c9fc4..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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=========================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
-
-public class HelpEsServlet extends EsServlet implements IPublicServlet {
-
- private static final long serialVersionUID = 6502905928958752573L;
-
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
deleted file mode 100644
index eeff762ac..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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=========================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
-
-public class HelpServlet extends EsServlet {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
deleted file mode 100644
index 4048012bb..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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=========================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.junit.After;
-import org.junit.Before;
-import org.onap.ccsdk.features.sdnr.wt.common.test.ServletInputStreamFromByteArrayInputStream;
-import org.onap.ccsdk.features.sdnr.wt.common.test.ServletOutputStreamToStringWriter;
-
-@SuppressWarnings("restriction")
-public class HelpServletBase {
-
- public static final String HTTPMETHOD_GET = "GET";
- public static final String HTTPMETHOD_POST = "POST";
- public static final String HTTPMETHOD_PUT = "PUT";
- public static final String HTTPMETHOD_DELETE = "DELETE";
- public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- private IPublicServlet servlet;
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
-
- public final String HOST = "localhost";
- protected static int testPort;
- private final String baseUri;
- protected static final String LR = "\n";
-
- public HelpServletBase(String baseuri, int port) {
- this.baseUri = baseuri;
- testPort = port;
- }
-
- public void setServlet(IPublicServlet s) {
- this.servlet = s;
- }
-
- protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
- this.testrequest("/mwtn/test", method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact) {
- this.testrequest(uri, method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact,
- Map<String, String> headersToCheck) {
-
- HttpServletRequest mockRequest = mock(HttpServletRequest.class);
- HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-
- ServletOutputStreamToStringWriter printOut = new ServletOutputStreamToStringWriter();
- ServletInputStreamFromByteArrayInputStream inputStream = new ServletInputStreamFromByteArrayInputStream(data.getBytes());
- Vector<String> headers = new Vector<String>();
- headers.addElement("Accept");
- headers.add("User-Agent");
- Enumeration<String> headerNames = headers.elements();
- try {
- when(mockRequest.getRequestURI()).thenReturn(this.baseUri + uri);
- when(mockRequest.getHeaderNames()).thenReturn(headerNames);
- when(mockRequest.getHeader("Accept")).thenReturn("application/json");
- when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
- when(mockRequest.getInputStream()).thenReturn(inputStream);
- when(mockResponse.getOutputStream()).thenReturn(printOut);
- System.out.println("do a " + method + " request");
- if (method == HTTPMETHOD_GET)
- this.servlet.doGet(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_POST)
- this.servlet.doPost(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_PUT)
- this.servlet.doPut(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_DELETE)
- this.servlet.doDelete(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_OPTIONS)
- this.servlet.doOptions(mockRequest, mockResponse);
- else
- fail("http request method " + method + " test not implemented");
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
-
- verify(mockResponse).setStatus(200);
- if (exact)
- assertEquals(expectedResponse, printOut.getStringWriter().toString());
- else
- assertTrue("response not for method " + method + "correct", printOut.getStringWriter().toString().contains(expectedResponse));
- // currently unable to check extra headers
- if (headersToCheck != null) {
-
- }
- }
-
- @Before
- private void init() throws IOException {
-
-
- initEsTestWebserver(testPort);
- }
-
- @After
- private void deinit() {
- stopTestWebserver();
- }
-
- public static void initEsTestWebserver(int port) throws IOException {
- initEsTestWebserver(port, "/mwtn/test");
- }
-
- public static void initEsTestWebserver(int port, String baseUri) throws IOException {
- server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- server.createContext(baseUri, new MyHandler());
- //server.createContext("/", new MyRootHandler());
- server.setExecutor(null); // creates a default executor
- server.start();
- System.out.println("http server started");
- }
-
- public static void stopTestWebserver() {
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped");
- }
- }
-
-
-
- public static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println(String.format("req received: %s %s", method, t.getRequestURI()));
- OutputStream os = null;
- try {
- if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_GET.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_GET.getBytes());
- } else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_POST.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_POST.getBytes());
- } else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_PUT.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_PUT.getBytes());
- } else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_DELETE.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_DELETE.getBytes());
- } else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_OPTIONS.length());
- //os = t.getResponseBody();
- //os.write(RESPONSE_OPTIONS.getBytes());
- } else {
- t.sendResponseHeaders(404, 0);
- }
- System.out.println("req handled successful");
-
- } catch (Exception e) {
- System.out.println(e.getMessage());
- } finally {
- if (os != null) {
- os.close();
- }
- }
- }
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
deleted file mode 100644
index bf7fc56f4..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * Copyright (C) 2017 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.
- * 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=========================================================
- */
-
-
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public interface IPublicServlet {
-
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties b/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties
deleted file mode 100644
index 2a2f8099e..000000000
--- a/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# ============LICENSE_START=======================================================
-# ONAP : ccsdk features
-# ================================================================================
-# Copyright (C) 2020 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.
-# 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=======================================================
-#
-#
-
-log4j.rootLogger=INFO, out
-
-log4j.logger.org.apache.camel.impl.converter=WARN
-log4j.logger.org.apache.camel.management=WARN
-log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
-log4j.logger.org.springframework=ERROR
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-