2 * ============LICENSE_START======================================================= ONAP :
3 * CCSDK.apps.sdnr.wt.apigateway
4 * ================================================================================ Copyright (C)
5 * 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * ================================================================================ Licensed under
7 * the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
15 * the License. ============LICENSE_END=========================================================
17 package org.onap.ccsdk.features.sdnr.wt.apigateway.test;
20 import java.io.IOException;
21 import javax.servlet.ServletException;
22 import org.junit.Test;
23 import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
24 import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpMsServlet;
25 import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
27 public class TestMediatorServerServlet extends HelpServletBase {
29 private static final int PORT = 40004;
31 public TestMediatorServerServlet() {
36 public void test() throws ServletException, IOException {
38 String tmpFilename = "tmp3.cfg";
39 File tmpFile = new File(tmpFilename);
40 if (tmpFile.exists()) {
43 MyProperties.Instantiate(tmpFile, true);
44 String query = "{\"query\":{\"match_all\":{}}}";
45 HelpMsServlet servlet = new HelpMsServlet();
46 this.setServlet(servlet);
47 // test diabled message
48 servlet.setOfflineStatus(true);
49 servlet.setBaseUrl("http://localhost:" + PORT);
50 String expectedResponse = "offline";
51 testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
52 testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
53 testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
54 testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
56 servlet.setOfflineStatus(false);
57 testrequest(HTTPMETHOD_GET, query, HelpMsServlet.RESPONSE_GET, true);
58 testrequest(HTTPMETHOD_POST, query, HelpMsServlet.RESPONSE_POST, true);
59 testrequest(HTTPMETHOD_PUT, query, HelpMsServlet.RESPONSE_PUT, true);
60 testrequest(HTTPMETHOD_DELETE, query, HelpMsServlet.RESPONSE_DELETE, true);
61 testrequest(HTTPMETHOD_OPTIONS, query, "", false);
63 if (tmpFile.exists()) {