From: Ladislav Borak Date: Wed, 22 Jan 2014 12:05:42 +0000 (+0100) Subject: Added test for MouontPoints and URI X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-4~4^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e78416d29c15efca617e1227b544b9681f950f19;ds=sidebyside Added test for MouontPoints and URI Change-Id: Ibb18ac011f0523e18595e4fff0900a492d3c5e25 Signed-off-by: Ladislav Borak --- 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 index c6d0a93a6f..0000000000 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestConfigDataTest.java +++ /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 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 rpcResult = new DummyRpcResult.Builder().result( - TransactionStatus.COMMITED).build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); - - when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) - .thenReturn(dummyFuture); - - ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class); - ArgumentCaptor compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class); - - // Test URI_1 - Entity 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 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 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 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 createEntity(final String relativePathToXml) { - InputStream inputStream = XmlMapper.class.getResourceAsStream(relativePathToXml); - String xml = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(inputStream)); - Entity 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; - } -} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java index ebc8a09f15..681444efd4 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java @@ -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(); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index 819b5f8213..5f8262ae70 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -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 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 rpcResult = new DummyRpcResult.Builder().result(TransactionStatus.COMMITED) - .build(); + RpcResult rpcResult = new DummyRpcResult.Builder().result( + TransactionStatus.COMMITED).build(); Future> 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 rpcResult = new DummyRpcResult.Builder().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 rpcResult = new DummyRpcResult.Builder().result( + TransactionStatus.COMMITED).build(); + Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + + when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) + .thenReturn(dummyFuture); + + ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class); + ArgumentCaptor 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 { diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java index 2df68af62f..45ead9bfdd 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java @@ -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 rpcResult = new DummyRpcResult.Builder().result(TransactionStatus.COMMITED) - .build(); + RpcResult rpcResult = new DummyRpcResult.Builder().result( + TransactionStatus.COMMITED).build(); Future> 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 rpcResult = new DummyRpcResult.Builder().result( + TransactionStatus.COMMITED).build(); + Future> 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 { diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ControllerContextTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java similarity index 57% rename from opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ControllerContextTest.java rename to opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java index 4c5922d73f..4e2f525d45 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/ControllerContextTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java @@ -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 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); + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml index 8fbc0a99c4..db2f4e9cf9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data2.xml @@ -1,6 +1,6 @@ - lf1 data - lf2 data + lf1 data + lf2 data 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 index 0000000000..3ce6741261 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data4.xml @@ -0,0 +1,6 @@ + + + lf1 data + lf2 data + + 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 index 0000000000..89aa782b01 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data5.xml @@ -0,0 +1,8 @@ + + + John +
F.C.I 43
+ j@j +
+
+ 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 index 0000000000..7feb6bf12b --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data6.xml @@ -0,0 +1,6 @@ + + John +
F.C.I 43
+ j@j +
+ 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 index 0000000000..43742770ae --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data7.xml @@ -0,0 +1,8 @@ + + + + lf1 data + lf2 data + + + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module index ad0716bc11..93342ead54 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module @@ -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 index 0000000000..b4bdec8b8d --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces2.xml @@ -0,0 +1,5 @@ + + xxx +
bbb
+ ccc +
\ 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 index 0000000000..77cb0267c9 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path2.xml @@ -0,0 +1,7 @@ + + + eth0 + ethernetCsmacd + false + some 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 index 0000000000..7502f8514f --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface.yang @@ -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 index 0000000000..086d68287b --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/test-mount-point/yang/test-interface2.yang @@ -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 index 0000000000..625b04d0fe --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/block-data.xml @@ -0,0 +1,4 @@ + +
456
+ First +
\ 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 index 0000000000..21712cb1b1 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/xml/data2.xml @@ -0,0 +1,4 @@ + + Vojtech + 17 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang index f683a69444..7594143922 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/test-config-data/yang1/test-interface.yang @@ -13,6 +13,17 @@ module test-interface { } container interfaces { + + container block { + + leaf address { + type string; + } + leaf location { + type string; + } + } + list interface { key "name";