<properties>\r
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
<nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>\r
- <yang.version>0.5.9-SNAPSHOT</yang.version>\r
+ <yang.version>0.6.0-SNAPSHOT</yang.version>\r
<yang.codegen.version>0.6.0-SNAPSHOT</yang.codegen.version>\r
<bundle.plugin.version>2.3.7</bundle.plugin.version>\r
</properties>\r
<jolokia.version>1.1.4</jolokia.version>
<checkstyle.version>2.10</checkstyle.version>
<testvm.argLine>-Xmx1024m -XX:MaxPermSize=256m</testvm.argLine>
- <yang.version>0.5.9-SNAPSHOT</yang.version>
<guava.version>14.0.1</guava.version>
<osgi.core.version>5.0.0</osgi.core.version>
<ietf-inet-types.version>2010.09.24.2-SNAPSHOT</ietf-inet-types.version>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
- <version>0.6.0-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
<scope>test</scope>
</dependency>
<!-- yang model dependencies -->
<name>runtime-mapping-singleton</name>
</mapping-service>
</module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type>
- <name>remoter</name>
- <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port> 59
- <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc"> 60
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
- <name>dom-broker</name>
- </dom-broker>
- </module>
+
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&revision=2013-10-28</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&revision=2013-10-28</capability>
</required-capabilities>
</snapshot>
--- /dev/null
+<snapshot>
+
+ <configuration>
+
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type>
+ <name>remoter</name>
+ <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
+ <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+ <name>dom-broker</name>
+ </dom-broker>
+ </module>
+ </modules>
+
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ </services>
+ </data>
+
+ </configuration>
+
+ <required-capabilities>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&revision=2013-10-28</capability>
+ </required-capabilities>
+
+</snapshot>
+
<logger name="org.opendaylight.controller" level="INFO"/>
<!-- OSGi logging bridge -->
- <logger name="org.opendaylight.controller.logging.bridge" level="INFO"/>
+ <logger name="org.opendaylight.controller.logging.bridge" level="WARN"/>
<logger name="org.opendaylight.controller.logging.bridge.internal" level="WARN"/>
<!-- Netty -->
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>ietf-topology</artifactId>
- <version>2013.10.21.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>ietf-inet-types</artifactId>
- <version>2010.09.24.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>ietf-yang-types</artifactId>
- <version>2010.09.24.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>yang-ext</artifactId>
- <version>2013.09.07.2-SNAPSHOT</version>
</dependency>
</dependencies>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+ <relativePath>../commons/opendaylight</relativePath>
+ </parent>
+
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- Dependency Versions -->
<slf4j.version>1.7.2</slf4j.version>
- <yang.codegen.version>0.6.0-SNAPSHOT</yang.codegen.version>
+ <yang.codegen.version>${yangtools.version}</yang.codegen.version>
<guava.version>14.0.1</guava.version>
<osgi.core.version>5.0.0</osgi.core.version>
<junit.version>4.8.1</junit.version>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator-impl</artifactId>
- <version>0.6.0-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
- <version>0.6.0-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</execution>
</executions>
</plugin>
+ <plugin>
+ <!-- FIXME: BUG-272: remove this configuration override -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.version}</version>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<reporting>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
- <version>3.17.1-GA</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
</scm>
- <properties>
- <opendaylight.binding.version>0.6.0-SNAPSHOT</opendaylight.binding.version>
- <opendaylight.yang.version>0.5.9-SNAPSHOT</opendaylight.yang.version>
- </properties>
<build>
<plugins>
<plugin>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${opendaylight.yang.version}</version>
+ <version>${yangtools.version}</version>
<executions>
<execution>
<id>sal-remote</id>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>${opendaylight.binding.version}</version>
+ <version>${yangtools.version}</version>
<type>jar</type>
</dependency>
</dependencies>
+++ /dev/null
-package org.opendaylight.controller.sal.restconf.impl.test;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.times;
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.text.ParseException;
-import java.util.Set;
-import java.util.concurrent.Future;
-import java.util.logging.Level;
-
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
-import org.opendaylight.controller.sal.rest.impl.XmlMapper;
-import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
-import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
-import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
-import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.controller.sal.core.api.mount.MountInstance;
-import org.opendaylight.controller.sal.core.api.mount.MountService;
-
-import com.google.common.base.Charsets;
-
-public class RestConfigDataTest extends JerseyTest {
-
- private static ControllerContext controllerContext;
- private static BrokerFacade brokerFacade;
- private static RestconfImpl restconfImpl;
- private static MountService mountService;
- private static SchemaContext schemaContext;
-
- private static final MediaType MEDIA_TYPE_XML_DRAFT02 = new MediaType("application", "yang.data+xml");
-
- @BeforeClass
- public static void init() throws FileNotFoundException {
- Set<Module> modules = TestUtils.loadModulesFrom("/test-config-data/yang1");
- schemaContext = TestUtils.loadSchemaContext(modules);
- initMocking();
- }
-
- private static void initMocking() {
- controllerContext = ControllerContext.getInstance();
- controllerContext.setSchemas(schemaContext);
- mountService = mock(MountService.class);
- controllerContext.setMountService(mountService);
- brokerFacade = mock(BrokerFacade.class);
- restconfImpl = RestconfImpl.getInstance();
- restconfImpl.setBroker(brokerFacade);
- restconfImpl.setControllerContext(controllerContext);
- }
-
-// @Test
- // TODO
- public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException {
- initMocking();
- String URI_1 = createUri("/config", "");
- String URI_2 = createUri("/config/", "");
- String URI_3 = createUri("/config/", "test-interface:interfaces/");
- String URI_4 = createUri("/config/", "test-interface:interfaces/");
- String URI_5 = createUri("/config/", "test-interface:interfaces/test-interface2:class");
-
- RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
- TransactionStatus.COMMITED).build();
- Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
-
- when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
- .thenReturn(dummyFuture);
-
- ArgumentCaptor<InstanceIdentifier> instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class);
- ArgumentCaptor<CompositeNode> compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class);
-
- // Test URI_1
- Entity<String> entity = createEntity("/test-config-data/xml/test-interface.xml");
- Response response = target(URI_1).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(204, response.getStatus());
- verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
- String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]";
- assertEquals("Bad format URI", identifier, instanceIdCaptor.getValue().getPath().toString());
-
- // Test URI_2
- response = target(URI_2).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(204, response.getStatus());
- verify(brokerFacade, times(2))
- .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
- assertEquals("Bad format URI", identifier, instanceIdCaptor.getValue().getPath().toString());
-
- // Test URI_3
- entity = createEntity("/test-config-data/xml/test-interface2.xml");
- response = target(URI_3).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(204, response.getStatus());
- verify(brokerFacade, times(3))
- .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
-
- identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interface[{(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)name=eth0}]]";
- assertEquals("Bad format URI", identifier, instanceIdCaptor.getValue().getPath().toString());
-
- // Test URI_4
- Set<Module> modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2");
- SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2);
- MountInstance mountInstance = mock(MountInstance.class);
- when(mountInstance.getSchemaContext()).thenReturn(schemaContext2);
- when(mountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
-
- entity = createEntity("/test-config-data/xml/test-interface3.xml");
- response = target(URI_4).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(204, response.getStatus());
- verify(brokerFacade, times(4))
- .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
- identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class]";
- assertEquals("Bad format URI", identifier, instanceIdCaptor.getValue().getPath().toString());
-
- // Test URI_5
- response = target(URI_5).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(204, response.getStatus());
- verify(brokerFacade, times(5))
- .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
- identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class]";
- assertEquals("Bad format URI", identifier, instanceIdCaptor.getValue().getPath().toString());
- }
-
-// @Test
- // TODO
- public void testExistingData() throws UnsupportedEncodingException {
- initMocking();
- String URI_1 = createUri("/config", "");
- String URI_2 = createUri("/config/", "");
- String URI_3 = createUri("/config/", "test-interface:interfaces/");
- String URI_4 = createUri("/config/", "test-interface:interfaces/");
- String URI_5 = createUri("/config/", "test-interface:interfaces/test-interface2:class");
-
- when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
- .thenReturn(null);
-
- // Test URI_1
- Entity<String> entity = createEntity("/test-config-data/xml/test-interface.xml");
- Response response = target(URI_1).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(202, response.getStatus());
-
- // Test URI_2
- response = target(URI_2).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(202, response.getStatus());
-
- // Test URI_3
- entity = createEntity("/test-config-data/xml/test-interface2.xml");
- response = target(URI_3).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(202, response.getStatus());
-
- // Test URI_4
- Set<Module> modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2");
- SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2);
- MountInstance mountInstance = mock(MountInstance.class);
- when(mountInstance.getSchemaContext()).thenReturn(schemaContext2);
- when(mountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
-
- entity = createEntity("/test-config-data/xml/test-interface3.xml");
- response = target(URI_4).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(202, response.getStatus());
-
- // Test URI_5
- response = target(URI_5).request(MEDIA_TYPE_XML_DRAFT02).post(entity);
- assertEquals(202, response.getStatus());
- }
-
- private String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
- return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
- }
-
- private Entity<String> createEntity(final String relativePathToXml) {
- InputStream inputStream = XmlMapper.class.getResourceAsStream(relativePathToXml);
- String xml = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(inputStream));
- Entity<String> entity = Entity.entity(xml, MEDIA_TYPE_XML_DRAFT02);
-
- return entity;
- }
-
- @Override
- protected Application configure() {
- enable(TestProperties.LOG_TRAFFIC);
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.RECORD_LOG_LEVEL);
- set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
-
- ResourceConfig resourceConfig = new ResourceConfig();
- resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
- XmlToCompositeNodeProvider.INSTANCE);
- return resourceConfig;
- }
-}
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
@Override
protected Application configure() {
/* enable/disable Jersey logs to console */
-// enable(TestProperties.LOG_TRAFFIC);
-// enable(TestProperties.DUMP_ENTITY);
-// enable(TestProperties.RECORD_LOG_LEVEL);
-// set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
+// enable(TestProperties.LOG_TRAFFIC);
+// enable(TestProperties.DUMP_ENTITY);
+// enable(TestProperties.RECORD_LOG_LEVEL);
+// set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
mockReadOperationalDataMethod();
String uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
-
+
uri = createUri("/datastore/", "wrong-module:interfaces/interface/eth0");
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
-
+
// Test of request for not existing data. Returning status code 404
uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(null);
mockReadOperationalDataMethod();
String uri = createUri("/operational/", "ietf-interfaces:interfaces/interface/eth0");
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
-
+
uri = createUri("/operational/", "wrong-module:interfaces/interface/eth0");
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
mockReadConfigurationDataMethod();
String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
-
+
uri = createUri("/config/", "wrong-module:interfaces/interface/eth0");
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
*/
@Test
public void getDataWithUrlMountPoint() throws UnsupportedEncodingException, URISyntaxException {
+ when(
+ brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class),
+ any(InstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest());
+ MountInstance mountInstance = mock(MountInstance.class);
+ when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
+ MountService mockMountService = mock(MountService.class);
+ when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
+
+ ControllerContext.getInstance().setMountService(mockMountService);
+
+ String uri = createUri("/config/",
+ "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1");
+ assertEquals(200, get(uri, MediaType.APPLICATION_XML));
+
+ uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1");
+ assertEquals(200, get(uri, MediaType.APPLICATION_XML));
+ }
+
+ @Test
+ public void getDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException {
when(brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class),
any(InstanceIdentifier.class))).thenReturn(prepareCnDataForMountPointTest());
MountInstance mountInstance = mock(MountInstance.class);
ControllerContext.getInstance().setMountService(mockMountService);
String uri = createUri("/config/",
- "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1");
- Response response = target(uri).request(Draft02.MediaTypes.DATA + XML).get();
- assertEquals(200, response.getStatus());
-
- uri = createUri("/config/",
- "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1");
- response = target(uri).request(Draft02.MediaTypes.DATA + XML).get();
- assertEquals(200, response.getStatus());
+ "ietf-interfaces:interfaces/interface/0/yang-ext:mount/");
+ assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
-
+
private int get(String uri, String mediaType) {
return target(uri).request(mediaType).get().getStatus();
}
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.util.Set;
import java.util.concurrent.Future;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
import org.opendaylight.controller.sal.core.api.mount.MountService;
import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
+import org.opendaylight.controller.sal.rest.impl.XmlMapper;
import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import com.google.common.base.Charsets;
+
public class RestPostOperationTest extends JerseyTest {
private static String xmlDataAbsolutePath;
private static String xmlDataInterfaceAbsolutePath;
private static String xmlDataRpcInput;
+ private static String xmlBlockData;
+ private static String xmlTestInterface;
private static CompositeNodeWrapper cnSnDataOutput;
- private static String xmlData2;
private static String xmlData3;
+ private static String xmlData4;
private static ControllerContext controllerContext;
private static BrokerFacade brokerFacade;
private static RestconfImpl restconfImpl;
private static SchemaContext schemaContextYangsIetf;
private static SchemaContext schemaContextTestModule;
+ private static SchemaContext schemaContext;
+
+ private static MountService mountService;
@BeforeClass
public static void init() throws URISyntaxException, IOException {
restconfImpl = RestconfImpl.getInstance();
restconfImpl.setBroker(brokerFacade);
restconfImpl.setControllerContext(controllerContext);
+
+ Set<Module> modules = TestUtils.loadModulesFrom("/test-config-data/yang1");
+ schemaContext = TestUtils.loadSchemaContext(modules);
+
loadData();
}
@Override
protected Application configure() {
/* enable/disable Jersey logs to console */
-// enable(TestProperties.LOG_TRAFFIC);
-// enable(TestProperties.DUMP_ENTITY);
-// enable(TestProperties.RECORD_LOG_LEVEL);
-// set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
+ // enable(TestProperties.LOG_TRAFFIC);
+ // enable(TestProperties.DUMP_ENTITY);
+ // enable(TestProperties.RECORD_LOG_LEVEL);
+ // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
mockInvokeRpc(cnSnDataOutput, true);
String uri = createUri("/operations/", "test-module:rpc-test");
assertEquals(200, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
+
mockInvokeRpc(null, true);
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
+
mockInvokeRpc(null, false);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
+
uri = createUri("/operations/", "test-module:rpc-wrongtest");
assertEquals(404, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
}
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
String uri = createUri("/config", "");
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(null);
assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
}
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
String uri = createUri("/config/", "ietf-interfaces:interfaces");
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(null);
assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
}
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
String uri = createUri("/datastore/", "ietf-interfaces:interfaces");
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(null);
assertEquals(202, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
+
mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
}
@Test
public void postDataViaUrlMountPoint() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextYangsIetf);
- RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(TransactionStatus.COMMITED)
- .build();
+ RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+ TransactionStatus.COMMITED).build();
Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
- when(brokerFacade.commitConfigurationDataPostBehindMountPoint(any(MountInstance.class),
+ when(
+ brokerFacade.commitConfigurationDataPostBehindMountPoint(any(MountInstance.class),
any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
MountInstance mountInstance = mock(MountInstance.class);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount");
- assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData2));
+ String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/");
+ assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4));
uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont");
assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3));
}
-
+
private void mockInvokeRpc(CompositeNode result, boolean sucessful) {
RpcResult<CompositeNode> rpcResult = new DummyRpcResult.Builder<CompositeNode>().result(result)
.isSuccessful(sucessful).build();
when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
.thenReturn(dummyFuture);
}
-
+
+ @Test
+ public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException {
+ initMocking();
+ RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+ TransactionStatus.COMMITED).build();
+ Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+
+ when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
+ .thenReturn(dummyFuture);
+
+ ArgumentCaptor<InstanceIdentifier> instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class);
+ ArgumentCaptor<CompositeNode> compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class);
+
+ String URI_1 = createUri("/config", "");
+ assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
+ verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
+ String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]";
+ assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
+
+ String URI_2 = createUri("/config/", "test-interface:interfaces");
+ assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
+ verify(brokerFacade, times(2))
+ .commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
+ identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces, (urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]";
+ assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
+ }
+
+ @Test
+ public void createConfigurationDataNullTest() throws UnsupportedEncodingException {
+ initMocking();
+
+ when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
+ .thenReturn(null);
+
+ String URI_1 = createUri("/config", "");
+ assertEquals(202, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
+
+ String URI_2 = createUri("/config/", "test-interface:interfaces");
+ assertEquals(202, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
+ }
+
+ private String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
+ return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
+ }
+
+ private static void initMocking() {
+ controllerContext = ControllerContext.getInstance();
+ controllerContext.setSchemas(schemaContext);
+ mountService = mock(MountService.class);
+ controllerContext.setMountService(mountService);
+ brokerFacade = mock(BrokerFacade.class);
+ restconfImpl = RestconfImpl.getInstance();
+ restconfImpl.setBroker(brokerFacade);
+ restconfImpl.setControllerContext(controllerContext);
+ }
+
private int post(String uri, String mediaType, String data) {
return target(uri).request(mediaType).post(Entity.entity(data, mediaType)).getStatus();
}
private static void loadData() throws IOException, URISyntaxException {
- InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces_absolute_path.xml");
+ InputStream xmlStream = RestconfImplTest.class
+ .getResourceAsStream("/parts/ietf-interfaces_interfaces_absolute_path.xml");
xmlDataAbsolutePath = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
- xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces_interface_absolute_path.xml");
+ xmlStream = RestconfImplTest.class
+ .getResourceAsStream("/parts/ietf-interfaces_interfaces_interface_absolute_path.xml");
xmlDataInterfaceAbsolutePath = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
String xmlPathRpcInput = RestconfImplTest.class.getResource("/full-versions/test-data2/data-rpc-input.xml")
.getPath();
xmlDataRpcInput = TestUtils.loadTextFile(xmlPathRpcInput);
+ String xmlPathBlockData = RestconfImplTest.class.getResource("/test-config-data/xml/block-data.xml").getPath();
+ xmlBlockData = TestUtils.loadTextFile(xmlPathBlockData);
+ String xmlPathTestInterface = RestconfImplTest.class.getResource("/test-config-data/xml/test-interface.xml")
+ .getPath();
+ xmlTestInterface = TestUtils.loadTextFile(xmlPathTestInterface);
cnSnDataOutput = prepareCnSnRpcOutput();
- String data2Input = RestconfImplTest.class.getResource("/full-versions/test-data2/data2.xml").getPath();
- xmlData2 = TestUtils.loadTextFile(data2Input);
String data3Input = RestconfImplTest.class.getResource("/full-versions/test-data2/data3.xml").getPath();
xmlData3 = TestUtils.loadTextFile(data3Input);
+ String data4Input = RestconfImplTest.class.getResource("/full-versions/test-data2/data7.xml").getPath();
+ xmlData4 = TestUtils.loadTextFile(data4Input);
}
private static CompositeNodeWrapper prepareCnSnRpcOutput() throws URISyntaxException {
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
public class RestPutOperationTest extends JerseyTest {
private static String xmlData;
+ private static String xmlData2;
+ private static String xmlData3;
private static BrokerFacade brokerFacade;
private static RestconfImpl restconfImpl;
private static void loadData() throws IOException {
InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
xmlData = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
+ InputStream xmlStream2 = RestconfImplTest.class.getResourceAsStream("/full-versions/test-data2/data2.xml");
+ xmlData2 = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream2));
+ InputStream xmlStream3 = RestconfImplTest.class.getResourceAsStream("/full-versions/test-data2/data7.xml");
+ xmlData3 = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream3));
}
@Override
protected Application configure() {
/* enable/disable Jersey logs to console */
-// enable(TestProperties.LOG_TRAFFIC);
-// enable(TestProperties.DUMP_ENTITY);
-// enable(TestProperties.RECORD_LOG_LEVEL);
-// set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
+ // enable(TestProperties.LOG_TRAFFIC);
+ // enable(TestProperties.DUMP_ENTITY);
+ // enable(TestProperties.RECORD_LOG_LEVEL);
+ // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
mockCommitConfigurationDataPutMethod(TransactionStatus.COMMITED);
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData));
-
+
mockCommitConfigurationDataPutMethod(TransactionStatus.FAILED);
assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));
}
-
/**
* Tests of status codes for "/datastore/{identifier}".
*/
String uri = createUri("/datastore/", "ietf-interfaces:interfaces/interface/eth0");
mockCommitConfigurationDataPutMethod(TransactionStatus.COMMITED);
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData));
-
+
mockCommitConfigurationDataPutMethod(TransactionStatus.FAILED);
assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));
}
public void testRpcResultCommitedToStatusCodesWithMountPoint() throws UnsupportedEncodingException,
FileNotFoundException, URISyntaxException {
- RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(TransactionStatus.COMMITED)
- .build();
+ RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+ TransactionStatus.COMMITED).build();
Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
- when(brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class),
+ when(
+ brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class),
any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
-
InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/full-versions/test-data2/data2.xml");
String xml = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
ControllerContext.getInstance().setMountService(mockMountService);
String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont");
- Response response = target(uri).request(Draft02.MediaTypes.DATA + XML).put(entity);
- assertEquals(200, response.getStatus());
-
+ assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
+
uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont");
- response = target(uri).request(Draft02.MediaTypes.DATA + XML).put(entity);
- assertEquals(200, response.getStatus());
+ assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
+ }
+
+ @Test
+ public void putDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException {
+ RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+ TransactionStatus.COMMITED).build();
+ Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+ when(
+ brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class),
+ any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture);
+
+ MountInstance mountInstance = mock(MountInstance.class);
+ when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
+ MountService mockMountService = mock(MountService.class);
+ when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
+
+ ControllerContext.getInstance().setMountService(mockMountService);
+
+ String uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount");
+ assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3));
}
private int put(String uri, String mediaType, String data) throws UnsupportedEncodingException {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.FileNotFoundException;
import java.util.Set;
-import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.opendaylight.controller.sal.core.api.mount.MountInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountService;
+import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
import org.opendaylight.controller.sal.restconf.impl.ResponseException;
+import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class ControllerContextTest {
+public class URITest {
private static final ControllerContext controllerContext = ControllerContext.getInstance();
controllerContext.setSchemas(schemaContext);
}
- @After
- public void releaseMountService() {
- controllerContext.setMountService(null);
- }
-
@Test
public void testToInstanceIdentifierList() throws FileNotFoundException {
InstanceIdWithSchemaNode instanceIdentifier = controllerContext
exception.expectMessage("HTTP 400 Bad Request");
controllerContext.toInstanceIdentifier("simple-nodes:food/snack/sports-arena");
}
+
+ @Test
+ public void testToInstanceIdentifierWithoutNode() {
+ exception.expect(ResponseException.class);
+ exception.expectMessage("HTTP 400 Bad Request");
+ controllerContext.toInstanceIdentifier("simple-nodes");
+ }
+ @Test
+ public void testMountPointWithExternModul() throws FileNotFoundException {
+ initMountService(true);
+ InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
+ assertEquals(
+ "[(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)class, (urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)student[{(urn:ietf:params:xml:ns:yang:test-interface2?revision=2014-08-01)name=name}]]",
+ instanceIdentifier.getInstanceIdentifier().getPath().toString());
+ }
+
+ @Test
+ public void testMountPointWithoutExternModul() throws FileNotFoundException {
+ initMountService(true);
+ InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/");
+ assertEquals(true, instanceIdentifier.getInstanceIdentifier().getPath().isEmpty());
+ }
+
+ @Test
+ public void testMountPointWithoutMountService() throws FileNotFoundException {
+ exception.expect(ResponseException.class);
+ exception.expectMessage("HTTP 503 Service Unavailable");
+
+ controllerContext.setMountService(null);
+ InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name");
+ }
+
+ @Test
+ public void testMountPointWithoutMountPointSchema() {
+ initMountService(false);
+ exception.expect(ResponseException.class);
+ exception.expectMessage("HTTP 400 Bad Request");
+
+ InstanceIdWithSchemaNode instanceIdentifier = controllerContext
+ .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class");
+ }
+
+ public void initMountService(boolean withSchema) {
+ MountService mountService = mock(MountService.class);
+ controllerContext.setMountService(mountService);
+ BrokerFacade brokerFacade = mock(BrokerFacade.class);
+ RestconfImpl restconfImpl = RestconfImpl.getInstance();
+ restconfImpl.setBroker(brokerFacade);
+ restconfImpl.setControllerContext(controllerContext);
+
+ Set<Module> modules2 = TestUtils.loadModulesFrom("/test-config-data/yang2");
+ SchemaContext schemaContext2 = TestUtils.loadSchemaContext(modules2);
+ MountInstance mountInstance = mock(MountInstance.class);
+ if (withSchema)
+ when(mountInstance.getSchemaContext()).thenReturn(schemaContext2);
+ else
+ when(mountInstance.getSchemaContext()).thenReturn(null);
+ when(mountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
+ }
}
<cont xmlns="test:module">
<cont1>
- <lf11>lf1 data</lf11>
- <lf12>lf2 data</lf12>
+ <lf11>lf1 data</lf11>
+ <lf12>lf2 data</lf12>
</cont1>
</cont>
--- /dev/null
+
+<cont1 xmlns="test:module">
+ <lf11>lf1 data</lf11>
+ <lf12>lf2 data</lf12>
+</cont1>
+
--- /dev/null
+<interfaces xmlns="test:module">
+ <class>
+ <name>John</name>
+ <address>F.C.I 43</address>
+ <email>j@j</email>
+ </class>
+</interfaces>
+
--- /dev/null
+<class xmlns="test:module">
+ <name>John</name>
+ <address>F.C.I 43</address>
+ <email>j@j</email>
+</class>
+
--- /dev/null
+<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <cont xmlns="test:module">
+ <cont1>
+ <lf11>lf1 data</lf11>
+ <lf12>lf2 data</lf12>
+ </cont1>
+ </cont>
+</data>
\ No newline at end of file
revision 2014-01-09 {
}
+ container interfaces {
+ container class {
+ leaf name {
+ type string;
+ }
+ leaf address {
+ type string;
+ }
+ leaf email {
+ type string;
+ }
+ }
+ }
+
container cont {
container cont1 {
leaf lf11 {
--- /dev/null
+<class xmlns="test:module">
+ <name>xxx</name>
+ <address>bbb</address>
+ <email>ccc</email>
+</class>
\ No newline at end of file
--- /dev/null
+
+<interface xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
+ <name>eth0</name>
+ <type>ethernetCsmacd</type>
+ <enabled>false</enabled>
+ <description>some interface</description>
+</interface>
--- /dev/null
+module mount-interface {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:mount-interface";
+ prefix "sn";
+
+ description
+ "test file";
+
+ revision "2014-07-01" {
+ description
+ "Initial revision";
+ reference "will be defined";
+ }
+
+ container interfaces {
+ list interface {
+ key "name";
+
+ leaf name {
+ type string;
+ }
+ leaf type {
+ type string;
+ }
+ leaf enabled {
+ type string;
+ }
+ }
+ }
+}
--- /dev/null
+module mount-interface2 {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:mount-interface2";
+ prefix "snn";
+
+ description
+ "test file";
+
+ revision "2014-08-01" {
+ description
+ "Initial revision";
+ reference "will be defined";
+ }
+
+ container class {
+ list student {
+ key "name";
+
+ leaf name {
+ type string;
+ }
+ leaf age {
+ type string;
+ }
+ }
+ }
+}
--- /dev/null
+<block xmlns="urn:ietf:params:xml:ns:yang:test-interface">
+ <address>456</address>
+ <location>First</location>
+</block>
\ No newline at end of file
--- /dev/null
+<student xmlns="urn:ietf:params:xml:ns:yang:test-interface2">
+ <name>Vojtech</name>
+ <age>17</age>
+</student>
\ No newline at end of file
}
container interfaces {
+
+ container block {
+
+ leaf address {
+ type string;
+ }
+ leaf location {
+ type string;
+ }
+ }
+
list interface {
key "name";
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
</scm>
- <properties>
- <opendaylight.binding.version>0.6.0-SNAPSHOT</opendaylight.binding.version>
- <opendaylight.yang.version>0.5.9-SNAPSHOT</opendaylight.yang.version>
- </properties>
<build>
<plugins>
<plugin>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-client-api</artifactId>
- <version>0.2.0-SNAPSHOT</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.6</version>
+ <version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>