eae301a34541219bffbfc04b010a0feafc322384
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
19
20 import static org.junit.Assert.fail;
21
22 import java.util.Set;
23
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
29 import org.opendaylight.mdsal.binding.api.RpcProviderService;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DataProviderService;
31 import org.opendaylight.yangtools.concepts.ObjectRegistration;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33 import org.opendaylight.yangtools.yang.binding.RpcService;
34
35 import net.bytebuddy.implementation.bytecode.StackSize;
36
37 /**
38  * @author Michael Dürre
39  *
40  */
41 public class TestImplementation {
42
43         @Test
44         public void test() {
45                 DataProviderImpl impl = new DataProviderImpl();
46                 impl.setRpcProviderService(new RpcProviderService() {
47                         
48                         @Override
49                         public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
50                                         T implementation, Set<InstanceIdentifier<?>> paths) {
51                                 // TODO Auto-generated method stub
52                                 return null;
53                         }
54                         
55                         @Override
56                         public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
57                                         T implementation) {
58                                 // TODO Auto-generated method stub
59                                 return null;
60                         }
61                 });
62                 impl.setMediatorServerServlet(new MsServlet());
63                 impl.setAboutServlet(new AboutHttpServlet());
64                 try {
65                         impl.init();
66                 } catch (Exception e) {
67                         e.printStackTrace();
68                         fail("failed to init impl: "+e.getMessage());
69                 }
70                 
71                 impl.setStatus(StatusKey.CLUSTER_SIZE, "3");
72                 impl.setReadyStatus(true);
73                 try {
74                         impl.close();
75                 } catch (Exception e) {
76                         e.printStackTrace();
77                         fail("failed to close impl: "+e.getMessage());
78                 }
79         }
80         
81 }