2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.restconf.impl.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.spy;
15 import static org.mockito.Mockito.when;
17 import java.io.FileNotFoundException;
19 import org.junit.Before;
20 import org.junit.BeforeClass;
21 import org.junit.Test;
22 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
23 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
24 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
25 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
26 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
27 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
28 import org.opendaylight.yangtools.yang.model.api.Module;
29 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
32 * @See {@link InvokeRpcMethodTest}
35 public class RestconfImplTest {
37 private RestconfImpl restconfImpl = null;
38 private static ControllerContext controllerContext = null;
41 public static void init() throws FileNotFoundException {
42 Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
43 assertNotNull(allModules);
44 SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
45 controllerContext = spy(ControllerContext.getInstance());
46 controllerContext.setSchemas(schemaContext);
51 public void initMethod() {
52 restconfImpl = RestconfImpl.getInstance();
53 restconfImpl.setControllerContext(controllerContext);
57 public void testExample() throws FileNotFoundException {
58 CompositeNode loadedCompositeNode = TestUtils.readInputToCnSn("/parts/ietf-interfaces_interfaces.xml",
59 XmlToCompositeNodeProvider.INSTANCE);
60 BrokerFacade brokerFacade = mock(BrokerFacade.class);
61 when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
62 assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));