2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ============LICENSE_END=========================================================
23 package org.onap.appc.adapter.restHealthcheck.impl;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28 import static org.junit.Assert.fail;
30 import java.io.IOException;
31 import java.lang.reflect.Field;
32 import java.util.HashMap;
33 import java.util.List;
35 import java.util.Properties;
38 import org.junit.Before;
39 import org.junit.BeforeClass;
40 import org.junit.Ignore;
41 import org.junit.Test;
44 import org.onap.appc.Constants;
45 import org.onap.appc.adapter.restHealthcheck.*;
46 import org.onap.appc.configuration.ConfigurationFactory;
47 import org.onap.appc.exceptions.APPCException;
48 import org.onap.appc.exceptions.UnknownProviderException;
49 import com.att.cdp.exceptions.ZoneException;
50 import com.att.cdp.zones.ComputeService;
51 import com.att.cdp.zones.Context;
52 import com.att.cdp.zones.ContextFactory;
53 import com.att.cdp.zones.model.Server;
54 import com.att.cdp.zones.model.Server.Status;
55 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
59 public class TestRestHealthcheckAdapterImpl {
61 @SuppressWarnings("nls")
62 private static final String PROVIDER_NAME = "ILAB";
64 @SuppressWarnings("nls")
65 private static final String PROVIDER_TYPE = "OpenStackProvider";
67 private static String IDENTITY_URL;
69 private static String PRINCIPAL;
71 private static String CREDENTIAL;
73 private static String TENANT_NAME;
75 private static String TENANT_ID;
77 private static String USER_ID;
79 private static String REGION_NAME;
81 private static String SERVER_URL;
83 private static Class<?> providerAdapterImplClass;
84 private static Class<?> configurationFactoryClass;
85 private static Field providerCacheField;
86 private static Field configField;
88 private RestHealthcheckAdapterImpl adapter;
91 @SuppressWarnings("nls")
93 public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
98 public void setup() throws IllegalArgumentException, IllegalAccessException {
100 adapter = new RestHealthcheckAdapterImpl();
104 public void testCheckHealth() throws IOException, IllegalStateException, IllegalArgumentException,
105 ZoneException, APPCException {
107 Map<String, String> params = new HashMap<>();
108 params.put("VNF.URI", "http://restHalthCheck.test");
109 params.put("VNF.endpoint", "health");
110 SvcLogicContext svcContext = new SvcLogicContext();
111 adapter.checkHealth(params, svcContext);
112 String statusCode=svcContext.getAttribute("healthcheck.result.code");
113 assertEquals("200",statusCode);