Merge "Yangtools version police: remove references to non-current versions"
authorGiovanni Meo <gmeo@cisco.com>
Fri, 24 Jan 2014 14:50:51 +0000 (14:50 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 24 Jan 2014 14:50:51 +0000 (14:50 +0000)
20 files changed:
opendaylight/distribution/opendaylight/src/main/resources/configuration/logback.xml
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestConfigDataTest.java [deleted file]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java [moved from opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ControllerContextTest.java with 57% similarity]
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module
opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang
opendaylight/md-sal/topology-lldp-discovery/pom.xml

index 61d274d80c22daf91dd28fe6cf8b9c7138fb7c41..a24a507840d2b259638043b9f19b82d2bf8a99a2 100644 (file)
@@ -41,7 +41,7 @@
   <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 -->
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestConfigDataTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestConfigDataTest.java
deleted file mode 100644 (file)
index c6d0a93..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-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;
-    }
-}
index ebc8a09f151adccaf9916c5d8a0062c9a2eef7bb..681444efd4b472561e4c4edd9275161c30b6e0aa 100644 (file)
@@ -13,13 +13,16 @@ import java.net.URI;
 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;
@@ -63,10 +66,10 @@ public class RestGetOperationTest extends JerseyTest {
     @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,
@@ -82,10 +85,10 @@ public class RestGetOperationTest extends JerseyTest {
         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);
@@ -100,7 +103,7 @@ public class RestGetOperationTest extends JerseyTest {
         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));
     }
@@ -113,7 +116,7 @@ public class RestGetOperationTest extends JerseyTest {
         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));
     }
@@ -123,6 +126,26 @@ public class RestGetOperationTest extends JerseyTest {
      */
     @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);
@@ -133,16 +156,10 @@ public class RestGetOperationTest extends JerseyTest {
         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();
     }
index 819b5f8213d8b4a5c1931648cd680855c5309057..5f8262ae7023e58a1380236fd8f58024717157cc 100644 (file)
@@ -3,6 +3,8 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 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;
@@ -12,16 +14,21 @@ import java.io.InputStream;
 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;
@@ -29,6 +36,7 @@ import org.opendaylight.controller.sal.rest.api.Draft02;
 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;
@@ -38,22 +46,30 @@ import org.opendaylight.yangtools.yang.common.QName;
 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 {
@@ -64,16 +80,20 @@ public class RestPostOperationTest extends JerseyTest {
         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,
@@ -87,13 +107,13 @@ public class RestPostOperationTest extends JerseyTest {
         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));
     }
@@ -104,10 +124,10 @@ public class RestPostOperationTest extends JerseyTest {
         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));
     }
@@ -118,10 +138,10 @@ public class RestPostOperationTest extends JerseyTest {
         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));
     }
@@ -132,10 +152,10 @@ public class RestPostOperationTest extends JerseyTest {
         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));
     }
@@ -143,10 +163,11 @@ public class RestPostOperationTest extends JerseyTest {
     @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);
@@ -156,12 +177,12 @@ public class RestPostOperationTest extends JerseyTest {
 
         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();
@@ -181,24 +202,87 @@ public class RestPostOperationTest extends JerseyTest {
         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 {
index 2df68af62f71e1aa89e0654fe1184c67ede23795..45ead9bfdda629a61244492086ef29e82f73901e 100644 (file)
@@ -22,6 +22,7 @@ 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.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
@@ -42,6 +43,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 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;
@@ -64,15 +67,19 @@ public class RestPutOperationTest extends JerseyTest {
     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,
@@ -88,12 +95,11 @@ public class RestPutOperationTest extends JerseyTest {
         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}".
      */
@@ -102,7 +108,7 @@ public class RestPutOperationTest extends JerseyTest {
         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));
     }
@@ -111,12 +117,12 @@ public class RestPutOperationTest extends JerseyTest {
     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));
@@ -130,12 +136,30 @@ public class RestPutOperationTest extends JerseyTest {
         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 {
@@ -3,23 +3,30 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 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();
 
@@ -34,11 +41,6 @@ public class ControllerContextTest {
         controllerContext.setSchemas(schemaContext);
     }
 
-    @After
-    public void releaseMountService() {
-        controllerContext.setMountService(null);
-    }
-
     @Test
     public void testToInstanceIdentifierList() throws FileNotFoundException {
         InstanceIdWithSchemaNode instanceIdentifier = controllerContext
@@ -107,5 +109,67 @@ public class ControllerContextTest {
         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);
+    }
 }
index 8fbc0a99c4e0f771ecab62cf0aaf6153736129b8..db2f4e9cf979105042f55f6725f9de6b54f54a2b 100644 (file)
@@ -1,6 +1,6 @@
 <cont xmlns="test:module">
     <cont1>
-           <lf11>lf1 data</lf11>
-           <lf12>lf2 data</lf12>
+        <lf11>lf1 data</lf11>
+        <lf12>lf2 data</lf12>
     </cont1>
 </cont>
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml
new file mode 100644 (file)
index 0000000..3ce6741
--- /dev/null
@@ -0,0 +1,6 @@
+
+<cont1 xmlns="test:module">
+    <lf11>lf1 data</lf11>
+    <lf12>lf2 data</lf12>
+</cont1>
+
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml
new file mode 100644 (file)
index 0000000..89aa782
--- /dev/null
@@ -0,0 +1,8 @@
+<interfaces xmlns="test:module">
+    <class>
+        <name>John</name>
+        <address>F.C.I 43</address>
+        <email>j@j</email>
+    </class>
+</interfaces>
+
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml
new file mode 100644 (file)
index 0000000..7feb6bf
--- /dev/null
@@ -0,0 +1,6 @@
+<class xmlns="test:module">
+    <name>John</name>
+    <address>F.C.I 43</address>
+    <email>j@j</email>
+</class>
+
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml
new file mode 100644 (file)
index 0000000..4374277
--- /dev/null
@@ -0,0 +1,8 @@
+<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
index ad0716bc11ac44d0a300f7e4a00bd35851e121f9..93342ead54f27a633973a965c3ee48e16c238445 100644 (file)
@@ -5,6 +5,20 @@ module test-module {
   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 {
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml
new file mode 100644 (file)
index 0000000..b4bdec8
--- /dev/null
@@ -0,0 +1,5 @@
+<class xmlns="test:module">
+    <name>xxx</name>
+    <address>bbb</address>
+    <email>ccc</email>
+</class>
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml
new file mode 100644 (file)
index 0000000..77cb026
--- /dev/null
@@ -0,0 +1,7 @@
+
+<interface xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
+    <name>eth0</name>
+    <type>ethernetCsmacd</type>
+    <enabled>false</enabled>
+    <description>some interface</description>
+</interface>
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang
new file mode 100644 (file)
index 0000000..7502f85
--- /dev/null
@@ -0,0 +1,30 @@
+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;
+            }
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang
new file mode 100644 (file)
index 0000000..086d682
--- /dev/null
@@ -0,0 +1,27 @@
+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;
+            }
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml
new file mode 100644 (file)
index 0000000..625b04d
--- /dev/null
@@ -0,0 +1,4 @@
+<block xmlns="urn:ietf:params:xml:ns:yang:test-interface">
+    <address>456</address>
+    <location>First</location>
+</block>
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml
new file mode 100644 (file)
index 0000000..21712cb
--- /dev/null
@@ -0,0 +1,4 @@
+<student xmlns="urn:ietf:params:xml:ns:yang:test-interface2">
+    <name>Vojtech</name>
+    <age>17</age>
+</student>
\ No newline at end of file
index f683a69444177b1acb6c4aa847d5ec379c8e1de2..7594143922317b9b5df762a037acd7e5eca830cb 100644 (file)
@@ -13,6 +13,17 @@ module test-interface {
     }
     
     container interfaces {
+    
+        container block {
+            
+            leaf address {
+                type string;
+            }
+            leaf location {
+                type string;
+            }
+        }
+    
         list interface {
             key "name";
          
index 36c4f621380d1b415b5e9b090eb89230a4e32141..aa4210ee578718c7a7c29d6f02a2f56b97aec00c 100644 (file)
@@ -62,7 +62,7 @@
              <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
-            <version>2.6</version>
+            <version>2.4</version>
           </dependency>
           <dependency>
             <groupId>com.google.guava</groupId>