2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019,2023 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.domains.onap.vcpe;
24 import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
25 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
26 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
27 import org.onap.policy.common.gson.GsonMessageBodyHandler;
28 import org.onap.policy.common.utils.network.NetworkUtil;
31 * The Class OnapVCpeSim.
33 public class OnapVCpeSim {
34 private static final int MAX_LOOPS = 100000;
35 private static HttpServletServer server;
38 * Instantiates a new aai and guard sim.
40 public OnapVCpeSim(final String[] args) throws Exception {
41 server = HttpServletServerFactoryInstance.getServerFactory().build(
42 "OnapVCpeSimEndpoint", false, args[0], Integer.valueOf(args[1]).intValue(), false, "/OnapVCpeSim", false,
45 server.addServletClass(null, OnapVCpeSimEndpoint.class.getName());
46 server.setSerializationProvider(GsonMessageBodyHandler.class.getName());
50 if (!NetworkUtil.isTcpPortOpen(args[0], Integer.valueOf(args[1]).intValue(), 2000, 1L)) {
51 throw new IllegalStateException("port " + args[1] + " is still not in use");
58 * @throws Exception the exception
60 public void tearDown() throws Exception {
69 * @param args the arguments
70 * @throws Exception the exception
72 public static void main(final String[] args) throws Exception {
73 final OnapVCpeSim sim = new OnapVCpeSim(args);
75 for (int index = 0; index < MAX_LOOPS; index++) {
76 ThreadUtilities.sleep(100);