2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
24 import static org.junit.Assert.fail;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section;
30 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter;
31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet;
32 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
33 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl;
35 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
36 import org.opendaylight.mdsal.binding.api.RpcProviderService;
37 import org.opendaylight.yangtools.concepts.ObjectRegistration;
38 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
39 import org.opendaylight.yangtools.yang.binding.RpcService;
42 * @author Michael Dürre
45 public class TestImplementation {
47 static String XY = "http://localhost:"
48 + (System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
52 //TestConfig.setSDNRDBURLEnv("http://localhost:"+(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"));
53 EnvGetter env = Section.getEnvGetter();
54 Section.setEnvGetter((xy) -> {
55 System.out.println("Search " + xy);
56 return xy.equals("SDNRDBURL") ? XY : env.getenv(xy);
58 DataProviderImpl impl = new DataProviderImpl();
59 impl.setRpcProviderService(new RpcProviderService() {
62 public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
63 T implementation, Set<InstanceIdentifier<?>> paths) {
68 public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
73 impl.setMediatorServerServlet(new MsServlet());
74 impl.setAboutServlet(new AboutHttpServlet());
75 impl.setTreeServlet(new DataTreeHttpServlet());
78 } catch (Exception e) {
80 fail("failed to init impl: " + e.getMessage());
83 impl.setStatus(StatusKey.CLUSTER_SIZE, "3");
84 impl.setReadyStatus(true);
87 } catch (Exception e) {
89 fail("failed to close impl: " + e.getMessage());