summaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr')
-rwxr-xr-xsdnr/wt/apigateway/installer/pom.xml4
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java17
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java73
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java (renamed from sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTilesServlet.java)45
-rw-r--r--sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml19
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java9
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java12
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTilesServlet.java85
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTopologyServlet.java84
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java5
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java6
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java23
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTopologyServlet.java57
13 files changed, 173 insertions, 266 deletions
diff --git a/sdnr/wt/apigateway/installer/pom.xml b/sdnr/wt/apigateway/installer/pom.xml
index 0f206bf68..3ee6e27a9 100755
--- a/sdnr/wt/apigateway/installer/pom.xml
+++ b/sdnr/wt/apigateway/installer/pom.xml
@@ -45,7 +45,7 @@
<dependencies>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>${application.name}-feature</artifactId>
<version>${project.version}</version>
<type>xml</type>
@@ -58,7 +58,7 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>${application.name}-provider</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
index c518cff81..66cbd02e9 100644
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
@@ -46,6 +46,9 @@ public class MyProperties {
private static final String DEFAULT_URL_OFF = "off";
private static final String DEFAULT_TILES = "${TILEURL}";
private static final String DEFAULT_TOPOLOGY = "${TOPOURL}";
+ private static final String DEFAULT_SITEDOC = "${SITEDOCURL}";
+ private static final String DEFAULT_TERRAIN = "${TERRAINURL}";
+
private static MyProperties mObj;
private static final String ENVVARIABLE = "${";
private static final String REGEXENVVARIABLE = "(\\$\\{[A-Z0-9_-]+\\})";
@@ -57,9 +60,10 @@ public class MyProperties {
private String esBase;
private String tilesBase;
private String topologyBase;
+ private String sitedocBase;
+ private String terrainBase;
private boolean trustInsecure;
-
private boolean corsEnabled;
public boolean isAAIOff() {
@@ -93,6 +97,13 @@ public class MyProperties {
public String getTopologyBaseUrl() {
return this.topologyBase;
}
+ public String getSitedocBaseUrl() {
+ return this.sitedocBase;
+ }
+
+ public String getTerrainBaseUrl() {
+ return this.terrainBase;
+ }
public Map<String, String> getAAIHeaders() {
return this.aaiHeaders;
@@ -143,6 +154,8 @@ public class MyProperties {
this.esBase = getProperty(defaultProps,"database", DEFAULT_ESDATABASE);
this.tilesBase = getProperty(defaultProps,"tiles", DEFAULT_TILES, DEFAULT_URL_OFF);
this.topologyBase = getProperty(defaultProps,"topology", DEFAULT_TOPOLOGY, DEFAULT_URL_OFF);
+ this.sitedocBase = getProperty(defaultProps,"sitedoc", DEFAULT_SITEDOC, DEFAULT_URL_OFF);
+ this.terrainBase = getProperty(defaultProps,"terrain", DEFAULT_TERRAIN, DEFAULT_URL_OFF);
this.trustInsecure = Integer.parseInt(getProperty(defaultProps,"insecure", DEFAULT_TRUSTINSECURE)) == 1;
this.corsEnabled = Integer.parseInt(getProperty(defaultProps,"cors", DEFAULT_CORSENABLED)) == 1;
}
@@ -207,6 +220,7 @@ public class MyProperties {
sb.append("database=" + DEFAULT_ESDATABASE + LR);
sb.append("tiles=" + DEFAULT_TILES + LR);
sb.append("topology=" + DEFAULT_TOPOLOGY + LR);
+ sb.append("terrain=" + DEFAULT_TERRAIN + LR);
sb.append("insecure=" + DEFAULT_TRUSTINSECURE + LR);
sb.append("cors=" + DEFAULT_CORSENABLED);
try {
@@ -229,4 +243,5 @@ public class MyProperties {
+ ", trustInsecure=" + trustInsecure + ", corsEnabled=" + corsEnabled + "]";
}
+
}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java
new file mode 100644
index 000000000..347dbb0d3
--- /dev/null
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java
@@ -0,0 +1,73 @@
+/*
+ * ============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;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class SitedocServlet extends BaseServlet {
+
+ private static final long serialVersionUID = 5946205120796162644L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "Topology interface is offline";
+ private static final String BASEURL = "/sitedoc";
+ private static final String SITEDOC_SUBPATH = "/topology/stadok";
+ private static boolean trustAll = false;
+
+ public SitedocServlet() {
+ super();
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
+
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
+
+ @Override
+ protected boolean isOff() {
+ return MyProperties.getInstance().isTopologyOff();
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+
+ if (uri != null && uri.length() > 0) {
+ uri = uri.substring(BASEURL.length());
+ }
+ return MyProperties.getInstance().getSitedocBaseUrl() + SITEDOC_SUBPATH + uri;
+ }
+
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
+}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTilesServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java
index cae5d93b9..12954c647 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTilesServlet.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : CCSDK.apps.sdnr.wt.apigateway
* ================================================================================
- * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,40 +18,55 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
+package org.onap.ccsdk.features.sdnr.wt.apigateway;
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.TilesServlet;
-public class HelpTilesServlet extends TilesServlet implements IPublicServlet {
+public class TerrainServlet extends BaseServlet {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 5946205120796162644L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "Terrain interface is offline";
+ private static final String BASEURL = "/terrain";
+ private static boolean trustAll = false;
+
+ public TerrainServlet() {
+ super();
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
}
@Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
+ protected boolean isOff() {
+ return MyProperties.getInstance().isTopologyOff();
}
@Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
+ protected String getRemoteUrl(String uri) {
+
+ if (uri != null && uri.length() > 0) {
+ uri = uri.substring(BASEURL.length());
+ }
+ return MyProperties.getInstance().getTerrainBaseUrl() + uri;
}
@Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
+ protected boolean doTrustAll() {
+ return trustAll;
}
@Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
}
}
diff --git a/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml b/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml
index cd325e4dc..37fa4ee9c 100644
--- a/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml
+++ b/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml
@@ -62,4 +62,23 @@
</service-properties>
</service>
+ <bean id="sitedocServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.apigateway.SitedocServlet">
+ </bean>
+
+ <service interface="javax.servlet.http.HttpServlet" ref="sitedocServlet">
+ <service-properties>
+ <entry key="alias" value="/sitedoc"/>
+ </service-properties>
+ </service>
+
+ <bean id="terrainServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.apigateway.TerrainServlet">
+ </bean>
+
+ <service interface="javax.servlet.http.HttpServlet" ref="terrainServlet">
+ <service-properties>
+ <entry key="alias" value="/terrain"/>
+ </service-properties>
+ </service>
</blueprint>
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
index 200949ec2..3436c36f2 100644
--- 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
@@ -29,6 +29,7 @@ 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 {
@@ -63,10 +64,10 @@ public class TestAaiServlet extends HelpServletBase {
// initEsTestWebserver(port);
properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, RESPONSE_DELETE, true);
+ 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())
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
index 7067bbeef..45eac88cd 100644
--- 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
@@ -37,8 +37,12 @@ public class TestDatabaseServlet extends HelpServletBase {
super("/database", PORT);
}
+
+
final String LR = "\n";
+
+
@Test
public void test() throws ServletException, IOException {
@@ -63,10 +67,10 @@ public class TestDatabaseServlet extends HelpServletBase {
// initEsTestWebserver(port);
properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, RESPONSE_DELETE, true);
+ 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();
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTilesServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTilesServlet.java
deleted file mode 100644
index 30ec53d4d..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTilesServlet.java
+++ /dev/null
@@ -1,85 +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.HelpServletBase;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpTilesServlet;
-
-public class TestTilesServlet extends HelpServletBase {
-
- private static final int PORT = 40001;
-
- public TestTilesServlet() {
- super("/tiles", 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 + "tiles=off" + LR
- + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR
- + "tiles=http://" + HOST + ":" + PORT + LR + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpTilesServlet());
- // 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, RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, 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/TestTopologyServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTopologyServlet.java
deleted file mode 100644
index 9b9692388..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestTopologyServlet.java
+++ /dev/null
@@ -1,84 +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.HelpServletBase;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpTopologyServlet;
-
-public class TestTopologyServlet extends HelpServletBase {
-
- private static final int PORT = 40001;
-
- public TestTopologyServlet() {
- super("/topology", 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 + "tiles=off" + LR
- + "topology=off" + LR + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "tiles=off" + LR
- + "topology=http://" + HOST + ":" + PORT + LR + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpTopologyServlet());
- // 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, RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, 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/helper/HelpAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
index 513fe0e57..5d4c8f507 100644
--- 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
@@ -29,6 +29,11 @@ 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 {
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
index 8e031e9a9..fe89c9fc4 100644
--- 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
@@ -30,6 +30,12 @@ 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);
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
index f0247c031..4048012bb 100644
--- 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
@@ -52,11 +52,6 @@ public class HelpServletBase {
public static final String HTTPMETHOD_PUT = "PUT";
public static final String HTTPMETHOD_DELETE = "DELETE";
public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- 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";
private IPublicServlet servlet;
private static HttpServer server;
private static ExecutorService httpThreadPool;
@@ -175,23 +170,23 @@ public class HelpServletBase {
OutputStream os = null;
try {
if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, RESPONSE_GET.length());
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_GET.length());
os = t.getResponseBody();
- os.write(RESPONSE_GET.getBytes());
+ os.write(HelpEsServlet.RESPONSE_GET.getBytes());
} else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, RESPONSE_POST.length());
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_POST.length());
os = t.getResponseBody();
- os.write(RESPONSE_POST.getBytes());
+ os.write(HelpEsServlet.RESPONSE_POST.getBytes());
} else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, RESPONSE_PUT.length());
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_PUT.length());
os = t.getResponseBody();
- os.write(RESPONSE_PUT.getBytes());
+ os.write(HelpEsServlet.RESPONSE_PUT.getBytes());
} else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, RESPONSE_DELETE.length());
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_DELETE.length());
os = t.getResponseBody();
- os.write(RESPONSE_DELETE.getBytes());
+ os.write(HelpEsServlet.RESPONSE_DELETE.getBytes());
} else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, RESPONSE_OPTIONS.length());
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_OPTIONS.length());
//os = t.getResponseBody();
//os.write(RESPONSE_OPTIONS.getBytes());
} else {
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTopologyServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTopologyServlet.java
deleted file mode 100644
index 18c6d9ffe..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpTopologyServlet.java
+++ /dev/null
@@ -1,57 +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.TopologyServlet;
-
-public class HelpTopologyServlet extends TopologyServlet implements IPublicServlet {
-
- 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);
- }
-}