From 7ce54d65de834d2901285e152c42044e8136c473 Mon Sep 17 00:00:00 2001 From: herbert Date: Sat, 14 Dec 2019 00:22:47 +0100 Subject: update old version of apigateway common data-provider helpserver websocketmanager2 Issue-ID: SDNC-1005 Signed-off-by: herbert Change-Id: I13990aa4329810bb7a7dd815e6149e9890617d07 Signed-off-by: herbert --- sdnr/wt/apigateway/feature/pom.xml | 67 +++-- sdnr/wt/apigateway/installer/pom.xml | 208 +++++++------- sdnr/wt/apigateway/pom.xml | 13 +- sdnr/wt/apigateway/provider/pom.xml | 22 +- .../features/sdnr/wt/apigateway/MsServlet.java | 21 +- .../features/sdnr/wt/apigateway/MyProperties.java | 2 +- .../apigateway/database/DatabaseEntryProvider.java | 3 + .../wt/apigateway/database/DatabaseHttpClient.java | 6 +- .../apigateway/database/http/BaseHTTPClient.java | 307 +++++++++++---------- .../wt/apigateway/test/TestDatabaseHttpClient.java | 17 ++ .../sdnr/wt/apigateway/test/TestHttpClient.java | 17 ++ .../sdnr/wt/apigateway/test/TestProperties.java | 19 +- .../sdnr/wt/apigateway/test/TestQueryCallback.java | 17 ++ 13 files changed, 399 insertions(+), 320 deletions(-) (limited to 'sdnr/wt/apigateway') diff --git a/sdnr/wt/apigateway/feature/pom.xml b/sdnr/wt/apigateway/feature/pom.xml index 88ccad411..cb83b169e 100644 --- a/sdnr/wt/apigateway/feature/pom.xml +++ b/sdnr/wt/apigateway/feature/pom.xml @@ -22,41 +22,40 @@ --> - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.features.sdnr.wt - sdnr-wt-apigateway-feature - 0.7.0-SNAPSHOT - feature - - ccsdk-features-sdnr-wt :: ${project.artifactId} :: feature - - - - - - org.opendaylight.controller - mdsal-artifacts - ${odl.controller.mdsal.version} - pom - import - - - + 4.0.0 + + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-apigateway-feature + 0.7.0-SNAPSHOT + feature + ccsdk-features-sdnr-wt :: ${project.artifactId} :: feature + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + + + org.opendaylight.controller + mdsal-artifacts + ${odl.controller.mdsal.version} + pom + import + + + - - ${project.groupId} - sdnr-wt-apigateway-provider - ${project.version} - + - + + ${project.groupId} + sdnr-wt-apigateway-provider + ${project.version} + + + diff --git a/sdnr/wt/apigateway/installer/pom.xml b/sdnr/wt/apigateway/installer/pom.xml index cee4f7d1c..96888e243 100755 --- a/sdnr/wt/apigateway/installer/pom.xml +++ b/sdnr/wt/apigateway/installer/pom.xml @@ -1,115 +1,115 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-apigateway-installer + 0.7.0-SNAPSHOT + pom + ccsdk-features-sdnr-wt :: ${project.artifactId} - org.onap.ccsdk.features.sdnr.wt - sdnr-wt-apigateway-installer - 0.7.0-SNAPSHOT - pom + + org.onap.ccsdk.parent + odlparent-lite + 1.5.1-SNAPSHOT + + - ccsdk-features-sdnr-wt :: ${project.artifactId} + + sdnr-wt-apigateway + false + - - sdnr-wt-apigateway - false - + - + + org.onap.ccsdk.features.sdnr.wt + ${application.name}-feature + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.features.sdnr.wt + ${application.name}-provider + ${project.version} + - - org.onap.ccsdk.features.sdnr.wt - ${application.name}-feature - ${project.version} - xml - features - - - * - * - - - - - org.onap.ccsdk.features.sdnr.wt - ${application.name}-provider - ${project.version} - - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - - - - - - - - - - - - - - - - - - - copy-nested-dependencies - - copy-dependencies - - prepare-package - - true - ${project.build.directory}/assembly/system - false - true - true - true - false - false - - - - - - - - + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + + + + + + + + + + + + + + + + + + + + copy-nested-dependencies + + copy-dependencies + + prepare-package + + true + ${project.build.directory}/assembly/system + false + true + true + true + false + false + + + + + + + + diff --git a/sdnr/wt/apigateway/pom.xml b/sdnr/wt/apigateway/pom.xml index 8efdbc0c0..8189a2ce8 100755 --- a/sdnr/wt/apigateway/pom.xml +++ b/sdnr/wt/apigateway/pom.xml @@ -24,6 +24,12 @@ 4.0.0 + org.onap.ccsdk.features.sdnr.wt + sdnr-wt-apigateway-top + 0.7.0-SNAPSHOT + pom + ccsdk-features-sdnr-wt :: ${project.artifactId} + org.onap.ccsdk.parent odlparent-lite @@ -31,13 +37,6 @@ - org.onap.ccsdk.features.sdnr.wt - sdnr-wt-apigateway-top - 0.7.0-SNAPSHOT - pom - - ccsdk-features-sdnr-wt :: ${project.artifactId} - feature provider diff --git a/sdnr/wt/apigateway/provider/pom.xml b/sdnr/wt/apigateway/provider/pom.xml index b4bbe1e56..a989874f8 100644 --- a/sdnr/wt/apigateway/provider/pom.xml +++ b/sdnr/wt/apigateway/provider/pom.xml @@ -11,27 +11,24 @@ 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========================================================= --> - - 4.0.0 + - - org.onap.ccsdk.parent - binding-parent - 1.5.1-SNAPSHOT - - + 4.0.0 org.onap.ccsdk.features.sdnr.wt sdnr-wt-apigateway-provider 0.7.0-SNAPSHOT - bundle - ccsdk-features-sdnr-wt :: ${project.artifactId} - + bundle true - + + org.onap.ccsdk.parent + binding-parent + 1.5.1-SNAPSHOT + + javax.servlet @@ -52,7 +49,6 @@ - diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MsServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MsServlet.java index c0b6c99a2..aee7a3b09 100644 --- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MsServlet.java +++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MsServlet.java @@ -38,14 +38,25 @@ public class MsServlet extends BaseServlet { private static Logger LOG = LoggerFactory.getLogger(MsServlet.class); private static final long serialVersionUID = -5361461082028405171L; private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline"; - private static final String DATABASE_REQUEST_URI_REGEX = "/mwtn/mediator-server"; + private static final String DATABASE_REQUEST_URI_REGEX = "/mediator-server/mediator-server"; private final DatabaseEntryProvider entryProvider; + private boolean isSecure; + public void setIsSecure(boolean secure) { + if(this.isSecure!=secure) { + this.isSecure=secure; + this.entryProvider.setBaseUrl(this.getDBBaseUrl()); + } + } public MsServlet() { super(); - this.entryProvider = new DatabaseEntryProvider("http://localhost:9200/",60); + this.entryProvider = new DatabaseEntryProvider(this.getDBBaseUrl(),60); EsServlet.registerRequestCallback(DATABASE_REQUEST_URI_REGEX, this.dbRequestCallback); } + private String getDBBaseUrl() { + return MyProperties.getInstance().getEsBaseUrl(); + } + private final IRequestCallback dbRequestCallback = new IRequestCallback() { @Override @@ -64,7 +75,11 @@ public class MsServlet extends BaseServlet { protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(200); } - + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doGet(req, resp); + this.isSecure=req.getScheme().equals("https"); + } @Override protected String getOfflineResponse() { return OFFLINE_RESPONSE_MESSAGE; 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 3d66f526e..36fce2081 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 @@ -40,7 +40,7 @@ public class MyProperties { private static final String DEFAULT_AAI_HEADERS = "[\"X-FromAppId:SDNR\",\"Authorization:Basic QUFJOkFBSQ==\"]"; private static final String DEFAULT_CORSENABLED = "0"; private static final String DEFAULT_TRUSTINSECURE = "0"; - private static final String DEFAULT_ESDATABASE = "http://localhost:9200"; + private static final String DEFAULT_ESDATABASE = "http://sdnrdb:9200"; private static final String DEFAULT_AAI = "off"; @Override diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseEntryProvider.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseEntryProvider.java index 086c3c977..b467e27a0 100644 --- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseEntryProvider.java +++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseEntryProvider.java @@ -102,5 +102,8 @@ public class DatabaseEntryProvider implements AutoCloseable { } return s; } + public void setBaseUrl(String baseUrl) { + this.httpClient.setBaseUrl(baseUrl); + } } diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseHttpClient.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseHttpClient.java index af46509e9..d0f575362 100644 --- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseHttpClient.java +++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/DatabaseHttpClient.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; public class DatabaseHttpClient extends BaseHTTPClient { private static Logger LOG = LoggerFactory.getLogger(DatabaseHttpClient.class); - private static final String URI = "/mwtn/mediator-server/_search"; + private static final String URI = "/mediator-server/mediator-server/_search"; private final Map headers; public DatabaseHttpClient(String base, boolean trustAllCerts) { @@ -44,7 +44,7 @@ public class DatabaseHttpClient extends BaseHTTPClient { private Map getHeaders() { Map h = new HashMap(); - + h.put("Content-Type", "application/json"); return h; } @@ -80,4 +80,6 @@ public class DatabaseHttpClient extends BaseHTTPClient { } return entries; } + + } diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/http/BaseHTTPClient.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/http/BaseHTTPClient.java index f8f95b386..9c89eeff3 100644 --- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/http/BaseHTTPClient.java +++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/database/http/BaseHTTPClient.java @@ -40,154 +40,161 @@ import org.slf4j.LoggerFactory; public class BaseHTTPClient { - private static Logger LOG = LoggerFactory.getLogger(BaseHTTPClient.class); - private static final int BUFSIZE = 1024; - private static final Charset CHARSET = StandardCharsets.UTF_8; - private static final String SSLCONTEXT = "TLSv1.2"; - private static final int DEFAULT_HTTP_TIMEOUT_MS = 30000; // in ms - - private final boolean trustAll; - private final String baseUrl; - - private int timeout = DEFAULT_HTTP_TIMEOUT_MS; - private SSLContext sc = null; - - public BaseHTTPClient(String base) { - this(base, false); - } - - - public BaseHTTPClient(String base, boolean trustAllCerts) { - this.baseUrl = base; - this.trustAll = trustAllCerts; - try { - sc = setupSsl(trustAll); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - LOG.warn("problem ssl setup: " + e.getMessage()); - } - } - - protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, String body, Map headers) - throws IOException { - return this.sendRequest(uri, method, body != null ? body.getBytes(CHARSET) : null, headers); - } - - protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, byte[] body, Map headers) - throws IOException { - if (uri == null) { - uri = ""; - } - String surl = this.baseUrl; - if (!surl.endsWith("/") && uri.length() > 0) { - surl += "/"; - } - if (uri.startsWith("/")) { - uri = uri.substring(1); - } - surl += uri; - LOG.debug("try to send request with url=" + this.baseUrl + uri + " as method=" + method); - LOG.trace("body:" + (body == null ? "null" : new String(body, CHARSET))); - URL url = new URL(surl); - URLConnection http = url.openConnection(); - http.setConnectTimeout(this.timeout); - if (surl.toString().startsWith("https")) { - if (sc != null) { - ((HttpsURLConnection) http).setSSLSocketFactory(sc.getSocketFactory()); - if (trustAll) { - LOG.debug("trusting all certs"); - HostnameVerifier allHostsValid = (hostname, session) -> true; - ((HttpsURLConnection) http).setHostnameVerifier(allHostsValid); - } - } else // Should never happen - { - LOG.warn("No SSL context available"); - return new BaseHTTPResponse(-1, ""); - } - } - ((HttpURLConnection) http).setRequestMethod(method); - http.setDoOutput(true); - if (headers != null && headers.size() > 0) { - for (String key : headers.keySet()) { - http.setRequestProperty(key, headers.get(key)); - LOG.trace("set http header " + key + ": " + headers.get(key)); - } - } - byte[] buffer = new byte[BUFSIZE]; - int len = 0, lensum = 0; - // send request - // Send the message to destination - if (!method.equals("GET") && body != null && body.length > 0) { - try (OutputStream output = http.getOutputStream()) { - output.write(body); - } - } - // Receive answer - int responseCode = ((HttpURLConnection) http).getResponseCode(); - String sresponse = ""; - InputStream response = null; - try { - if (responseCode >= 200 && responseCode < 300) { - response = http.getInputStream(); - } else { - response = ((HttpURLConnection) http).getErrorStream(); - if (response == null) { - response = http.getInputStream(); - } - } - if (response != null) { - while (true) { - len = response.read(buffer, 0, BUFSIZE); - if (len <= 0) { - break; - } - lensum += len; - sresponse += new String(buffer, 0, len, CHARSET); - } - } else { - LOG.debug("response is null"); - } - } catch (Exception e) { - LOG.debug("No response. ", e); - } finally { - if (response != null) { - response.close(); - } - } - LOG.debug("ResponseCode: " + responseCode); - LOG.trace("Response (len:{}): {}", String.valueOf(lensum), sresponse); - return new BaseHTTPResponse(responseCode, sresponse); - } - - - public static SSLContext setupSsl(boolean trustall) throws KeyManagementException, NoSuchAlgorithmException{ - - SSLContext sc = SSLContext.getInstance(SSLCONTEXT); - TrustManager[] trustCerts = null; - if (trustall) { - trustCerts = new TrustManager[] {new javax.net.ssl.X509TrustManager() { - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - }}; - - } - KeyManager[] kms = null; - // Init the SSLContext with a TrustManager[] and SecureRandom() - sc.init(kms, trustCerts, new java.security.SecureRandom()); - return sc; - } - - public static String getAuthorizationHeaderValue(String username, String password) { - return "Basic " + new String(Base64.getEncoder().encode((username + ":" + password).getBytes())); - } - - - + private static Logger LOG = LoggerFactory.getLogger(BaseHTTPClient.class); + private static final int BUFSIZE = 1024; + private static final Charset CHARSET = StandardCharsets.UTF_8; + private static final String SSLCONTEXT = "TLSv1.2"; + private static final int DEFAULT_HTTP_TIMEOUT_MS = 30000; // in ms + + private final boolean trustAll; + private String baseUrl; + + private int timeout = DEFAULT_HTTP_TIMEOUT_MS; + private SSLContext sc = null; + + public BaseHTTPClient(String base) { + this(base, false); + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + try { + sc = setupSsl(trustAll); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + LOG.warn("problem ssl setup: " + e.getMessage()); + } + } + + public BaseHTTPClient(String base, boolean trustAllCerts) { + this.baseUrl = base; + this.trustAll = trustAllCerts; + try { + sc = setupSsl(trustAll); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + LOG.warn("problem ssl setup: " + e.getMessage()); + } + } + + protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, String body, Map headers) + throws IOException { + return this.sendRequest(uri, method, body != null ? body.getBytes(CHARSET) : null, headers); + } + + protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, byte[] body, Map headers) + throws IOException { + if (uri == null) { + uri = ""; + } + String surl = this.baseUrl; + if (!surl.endsWith("/") && uri.length() > 0) { + surl += "/"; + } + if (uri.startsWith("/")) { + uri = uri.substring(1); + } + surl += uri; + LOG.debug("try to send request with url=" + this.baseUrl + uri + " as method=" + method); + LOG.trace("body:" + (body == null ? "null" : new String(body, CHARSET))); + URL url = new URL(surl); + URLConnection http = url.openConnection(); + http.setConnectTimeout(this.timeout); + if (surl.toString().startsWith("https")) { + if (sc != null) { + ((HttpsURLConnection) http).setSSLSocketFactory(sc.getSocketFactory()); + if (trustAll) { + LOG.debug("trusting all certs"); + HostnameVerifier allHostsValid = (hostname, session) -> true; + ((HttpsURLConnection) http).setHostnameVerifier(allHostsValid); + } + } else // Should never happen + { + LOG.warn("No SSL context available"); + return new BaseHTTPResponse(-1, ""); + } + } + ((HttpURLConnection) http).setRequestMethod(method); + http.setDoOutput(true); + if (headers != null && headers.size() > 0) { + for (String key : headers.keySet()) { + http.setRequestProperty(key, headers.get(key)); + LOG.trace("set http header " + key + ": " + headers.get(key)); + } + } + byte[] buffer = new byte[BUFSIZE]; + int len = 0, lensum = 0; + // send request + // Send the message to destination + if (!method.equals("GET") && body != null && body.length > 0) { + try (OutputStream output = http.getOutputStream()) { + output.write(body); + } + } + // Receive answer + int responseCode = ((HttpURLConnection) http).getResponseCode(); + String sresponse = ""; + InputStream response = null; + try { + if (responseCode >= 200 && responseCode < 300) { + response = http.getInputStream(); + } else { + response = ((HttpURLConnection) http).getErrorStream(); + if (response == null) { + response = http.getInputStream(); + } + } + if (response != null) { + while (true) { + len = response.read(buffer, 0, BUFSIZE); + if (len <= 0) { + break; + } + lensum += len; + sresponse += new String(buffer, 0, len, CHARSET); + } + } else { + LOG.debug("response is null"); + } + } catch (Exception e) { + LOG.debug("No response. ", e); + } finally { + if (response != null) { + response.close(); + } + } + LOG.debug("ResponseCode: " + responseCode); + LOG.trace("Response (len:{}): {}", String.valueOf(lensum), sresponse); + return new BaseHTTPResponse(responseCode, sresponse); + } + + public static SSLContext setupSsl(boolean trustall) throws KeyManagementException, NoSuchAlgorithmException { + + SSLContext sc = SSLContext.getInstance(SSLCONTEXT); + TrustManager[] trustCerts = null; + if (trustall) { + trustCerts = new TrustManager[] { new javax.net.ssl.X509TrustManager() { + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } + } }; + + } + KeyManager[] kms = null; + // Init the SSLContext with a TrustManager[] and SecureRandom() + sc.init(kms, trustCerts, new java.security.SecureRandom()); + return sc; + } + + public static String getAuthorizationHeaderValue(String username, String password) { + return "Basic " + new String(Base64.getEncoder().encode((username + ":" + password).getBytes())); + } + } diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseHttpClient.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseHttpClient.java index 795228834..791e9bad0 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseHttpClient.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseHttpClient.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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.*; diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestHttpClient.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestHttpClient.java index 6e21bc133..18e84853a 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestHttpClient.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestHttpClient.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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.fail; 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 index 1a63240d8..6efd06feb 100644 --- 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 @@ -27,6 +27,8 @@ 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; @@ -38,7 +40,7 @@ public class TestProperties { private static final boolean DEFAULT_TRUSTINSECURE = false; private static final String DEFAULT_AAIBASEURL = "off"; private static Map DEFAULT_AAIHEADERS = new HashMap(); - private static final String DEFAULT_ESBASEURL = "http://localhost:9200"; + private static final String DEFAULT_ESBASEURL = "http://sdnrdb:9200"; private static final boolean CUSTOM_CORSENABLED = true; private static final boolean CUSTOM_AAIOFF = false; @@ -49,10 +51,18 @@ public class TestProperties { 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() { - final String tmpFilename = "tmp2.cfg"; DEFAULT_AAIHEADERS.put("X-FromAppId", "SDNR"); DEFAULT_AAIHEADERS.put("Authorization", "Basic QUFJOkFBSQ=="); CUSTOM_AAIHEADERS.put("X-FromAppId", "SDNC"); @@ -62,9 +72,6 @@ public class TestProperties { + "\"]" + LR + "database=" + CUSTOM_ESBASEURL + LR + "insecure=" + (CUSTOM_TRUSTINSECURE ? "1" : "0") + LR + "cors=" + (CUSTOM_CORSENABLED ? "1" : "0"); File ftest = new File(tmpFilename); - // delete autogenerated testfile - if (ftest.exists()) - ftest.delete(); MyProperties prop = null; ftest = new File(tmpFilename); try { diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestQueryCallback.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestQueryCallback.java index 78341dfad..3340ec66c 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestQueryCallback.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestQueryCallback.java @@ -1,3 +1,20 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * 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.*; -- cgit 1.2.3-korg