1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertEquals;
4 import static org.mockito.Matchers.any;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.when;
8 import java.io.FileNotFoundException;
9 import java.io.InputStream;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.restconf.impl.*;
15 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
16 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 public class RestconfImplTest {
22 private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
25 public static void init() throws FileNotFoundException {
26 Set<Module> allModules = TestUtils.loadModules(RestconfImplTest.class.getResource("/full-versions/yangs")
28 SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
29 ControllerContext controllerContext = ControllerContext.getInstance();
30 controllerContext.setSchemas(schemaContext);
31 restconfImpl.setControllerContext(controllerContext);
35 public void testExample() throws FileNotFoundException {
36 InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
37 CompositeNode loadedCompositeNode = TestUtils.loadCompositeNodeWithXmlTreeBuilder(xmlStream);
38 BrokerFacade brokerFacade = mock(BrokerFacade.class);
39 when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
40 assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));