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;
 
  26 import org.junit.Test;
 
  27 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section;
 
  28 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter;
 
  29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet;
 
  30 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
 
  31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.UserdataHttpServlet;
 
  32 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet;
 
  33 import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl;
 
  34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
 
  35 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 
  36 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 
  37 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
  38 import org.opendaylight.yangtools.yang.binding.RpcService;
 
  41  * @author Michael Dürre
 
  44 public class TestImplementation {
 
  46     static String XY = "http://localhost:"
 
  47             + (System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
 
  51         //TestConfig.setSDNRDBURLEnv("http://localhost:"+(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"));
 
  52         EnvGetter env = Section.getEnvGetter();
 
  53         Section.setEnvGetter((xy) -> {
 
  54             System.out.println("Search " + xy);
 
  55             return xy.equals("SDNRDBURL") ? XY : env.getenv(xy);
 
  57         DataProviderImpl impl = new DataProviderImpl();
 
  58         impl.setRpcProviderService(new RpcProviderService() {
 
  61             public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
 
  62                     T implementation, Set<InstanceIdentifier<?>> paths) {
 
  67             public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
 
  72         impl.setMediatorServerServlet(new MsServlet());
 
  73         impl.setAboutServlet(new AboutHttpServlet());
 
  74         impl.setTreeServlet(new DataTreeHttpServlet());
 
  75         impl.setUserdataServlet(new UserdataHttpServlet());
 
  78         } catch (Exception e) {
 
  80             fail("failed to init impl: " + e.getMessage());
 
  83         impl.setStatus(StatusKey.CLUSTER_SIZE, "3");
 
  86         } catch (Exception e) {
 
  88             fail("failed to close impl: " + e.getMessage());