1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.mockito.Mockito.*;
4 import static org.junit.Assert.*;
6 import java.io.FileNotFoundException;
7 import java.io.InputStream;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
13 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
14 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
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").getPath());
27 SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
28 ControllerContext controllerContext = ControllerContext.getInstance();
29 controllerContext.setSchemas(schemaContext);
30 restconfImpl.setControllerContext(controllerContext);
34 public void testExample() throws FileNotFoundException {
35 InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
36 CompositeNode loadedCompositeNode = TestUtils.loadCompositeNode(xmlStream);
37 BrokerFacade brokerFacade = mock(BrokerFacade.class);
38 when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
39 assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));