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 java.io.FileNotFoundException;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
15 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
16 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
17 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
18 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
19 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.mockito.Matchers.any;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
28 public class RestconfImplTest {
30 private static final RestconfImpl restconfImpl = RestconfImpl.getInstance();
33 public static void init() throws FileNotFoundException {
34 Set<Module> allModules = TestUtils.loadModulesFrom("/full-versions/yangs");
35 assertNotNull(allModules);
36 SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
37 ControllerContext controllerContext = ControllerContext.getInstance();
38 controllerContext.setSchemas(schemaContext);
39 restconfImpl.setControllerContext(controllerContext);
43 public void testExample() throws FileNotFoundException {
44 CompositeNode loadedCompositeNode = TestUtils.readInputToCnSn("/parts/ietf-interfaces_interfaces.xml", XmlToCompositeNodeProvider.INSTANCE);
45 BrokerFacade brokerFacade = mock(BrokerFacade.class);
46 when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(loadedCompositeNode);
47 assertEquals(loadedCompositeNode, brokerFacade.readOperationalData(null));