2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.adapter.restHealthcheck.impl;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
29 import static org.junit.Assert.fail;
31 import java.io.IOException;
32 import java.lang.reflect.Field;
33 import java.util.HashMap;
34 import java.util.List;
36 import java.util.Properties;
39 import org.junit.Before;
40 import org.junit.BeforeClass;
41 import org.junit.Ignore;
42 import org.junit.Test;
45 import org.onap.appc.Constants;
46 import org.onap.appc.adapter.restHealthcheck.*;
47 import org.onap.appc.configuration.ConfigurationFactory;
48 import org.onap.appc.exceptions.APPCException;
49 import org.onap.appc.exceptions.UnknownProviderException;
50 import com.att.cdp.exceptions.ZoneException;
51 import com.att.cdp.zones.ComputeService;
52 import com.att.cdp.zones.Context;
53 import com.att.cdp.zones.ContextFactory;
54 import com.att.cdp.zones.model.Server;
55 import com.att.cdp.zones.model.Server.Status;
56 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
60 public class TestRestHealthcheckAdapterImpl {
62 @SuppressWarnings("nls")
63 private static final String PROVIDER_NAME = "ILAB";
65 @SuppressWarnings("nls")
66 private static final String PROVIDER_TYPE = "OpenStackProvider";
68 private static String IDENTITY_URL;
70 private static String PRINCIPAL;
72 private static String CREDENTIAL;
74 private static String TENANT_NAME;
76 private static String TENANT_ID;
78 private static String USER_ID;
80 private static String REGION_NAME;
82 private static String SERVER_URL;
84 private static Class<?> providerAdapterImplClass;
85 private static Class<?> configurationFactoryClass;
86 private static Field providerCacheField;
87 private static Field configField;
89 private RestHealthcheckAdapterImpl adapter;
92 @SuppressWarnings("nls")
94 public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
99 public void setup() throws IllegalArgumentException, IllegalAccessException {
101 adapter = new RestHealthcheckAdapterImpl();
105 public void testCheckHealth() throws IOException, IllegalStateException, IllegalArgumentException,
106 ZoneException, APPCException {
108 Map<String, String> params = new HashMap<>();
109 params.put("VNF.URI", "http://restHalthCheck.test");
110 params.put("VNF.endpoint", "health");
111 SvcLogicContext svcContext = new SvcLogicContext();
112 adapter.checkHealth(params, svcContext);
113 String statusCode=svcContext.getAttribute("healthcheck.result.code");
114 assertEquals("200",statusCode);