From afabc939fc258e64453e4210e7d1193148636d81 Mon Sep 17 00:00:00 2001 From: Jakub Toth Date: Fri, 8 Sep 2017 00:26:11 +0200 Subject: [PATCH] Split Restconf implementations (draft02 and RFC) - providers tests Change-Id: If8c26aa059508763e4730d69d9b64f594ec9e302 Signed-off-by: Jakub Toth --- .../handlers/SchemaContextHandler.java | 4 ++ .../AbstractIdentifierAwareJaxRsProvider.java | 4 +- ...terAwareNormalizedNodeWriterDepthTest.java | 2 +- ...erAwareNormalizedNodeWriterFieldsTest.java | 2 +- ...areNormalizedNodeWriterParametersTest.java | 2 +- .../XmlBodyReaderMountPointTest.java | 18 +++--- .../JsonPatchBodyReaderMountPointTest.java | 26 ++++---- .../patch}/JsonPatchBodyReaderTest.java | 25 ++++---- .../XmlPatchBodyReaderMountPointTest.java | 23 +++---- .../patch}/XmlPatchBodyReaderTest.java | 22 ++++--- .../test}/AbstractBodyReaderTest.java | 17 +++-- .../providers/test}/JsonBodyReaderTest.java | 12 ++-- .../providers/test}/XmlBodyReaderTest.java | 15 ++--- .../src/test/resources/foo-xml-test/foo.xml | 5 ++ .../test/resources/foo-xml-test/yang/foo.yang | 18 ++++++ .../instanceidentifier/iid-value.yang | 23 +++++++ .../jsonPATCHMergeOperationOnContainer.json | 43 +++++++++++++ .../json/jsonPATCHMergeOperationOnList.json | 32 ++++++++++ .../json/jsonPATCHSimpleLeafValue.json | 17 +++++ .../json/jsonPATCHdata.json | 35 +++++++++++ .../jsonPATCHdataCompleteTargetInURI.json | 44 +++++++++++++ .../json/jsonPATCHdataCreateAndDelete.json | 31 +++++++++ .../json/jsonPATCHdataValueMissing.json | 13 ++++ .../json/jsonPATCHdataValueNotSupported.json | 20 ++++++ .../json/json_augment_choice_container.json | 5 ++ .../json/json_augment_container.json | 5 ++ .../json/json_sub_container.json | 5 ++ .../instanceidentifier/json/jsondata.json | 14 +++++ .../json/jsondata_leaf_list.json | 7 +++ .../instanceidentifier/xml/bug7933.xml | 9 +++ .../xml/xmlDataFindBarContainer.xml | 10 +++ .../xml/xmlDataFindFooContainer.xml | 10 +++ .../instanceidentifier/xml/xmlPATCHdata.xml | 28 +++++++++ .../xml/xmlPATCHdataAbsoluteTargetPath.xml | 35 +++++++++++ .../xml/xmlPATCHdataCompleteTargetInURI.xml | 44 +++++++++++++ .../xmlPATCHdataMergeOperationOnContainer.xml | 44 +++++++++++++ .../xml/xmlPATCHdataMergeOperationOnList.xml | 35 +++++++++++ .../xml/xmlPATCHdataValueMissing.xml | 16 +++++ .../xml/xmlPATCHdataValueNotSupported.xml | 23 +++++++ .../xml/xml_augment_choice_container.xml | 3 + .../xml/xml_augment_container.xml | 3 + .../xml/xml_sub_container.xml | 6 ++ .../instanceidentifier/xml/xmldata.xml | 10 +++ .../xml/xmldata_leaf_list.xml | 8 +++ .../yang/augment-augment-module.yang | 20 ++++++ .../yang/augment-module-leaf-list.yang | 19 ++++++ .../yang/augment-module.yang | 63 +++++++++++++++++++ .../instanceidentifier/yang/bar-module.yang | 11 ++++ .../instanceidentifier/yang/foo-module.yang | 11 ++++ .../yang/instance-identifier-module.yang | 12 ++++ .../instance-identifier-patch-module.yang | 47 ++++++++++++++ 51 files changed, 877 insertions(+), 79 deletions(-) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040}/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java (99%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040}/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java (99%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040}/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java (99%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040}/jersey/providers/XmlBodyReaderMountPointTest.java (95%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch}/JsonPatchBodyReaderMountPointTest.java (89%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch}/JsonPatchBodyReaderTest.java (88%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch}/XmlPatchBodyReaderMountPointTest.java (89%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch}/XmlPatchBodyReaderTest.java (88%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test}/AbstractBodyReaderTest.java (87%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test}/JsonBodyReaderTest.java (96%) rename restconf/{restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers => restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test}/XmlBodyReaderTest.java (96%) create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/foo.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/yang/foo.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/iid-value.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnList.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHSimpleLeafValue.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdata.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueMissing.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueNotSupported.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_choice_container.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_container.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_sub_container.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/bug7933.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindBarContainer.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindFooContainer.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdata.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueMissing.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_container.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_sub_container.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-augment-module.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/bar-module.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/foo-module.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang create mode 100644 restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-patch-module.yang diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandler.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandler.java index b3719b5e33..6ba7018cb5 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandler.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/SchemaContextHandler.java @@ -84,6 +84,10 @@ public class SchemaContextHandler implements SchemaContextListenerHandler { return actualSchemaContext; } + public static void setActualSchemaContext(final SchemaContext schemaContext) { + actualSchemaContext = schemaContext; + } + private void putData( final NormalizedNode>> normNode) { final DOMDataWriteTransaction wTx = this.transactionChainHandler.get().newWriteOnlyTransaction(); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java index 42c2d0bee7..ac87d2a1e8 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java @@ -85,11 +85,11 @@ public abstract class AbstractIdentifierAwareJaxRsProvider implements Message return HttpMethod.POST.equals(this.request.getMethod()); } - void setUriInfo(final UriInfo uriInfo) { + public void setUriInfo(final UriInfo uriInfo) { this.uriInfo = uriInfo; } - void setRequest(final Request request) { + public void setRequest(final Request request) { this.request = request; } } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java similarity index 99% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java index 5e654a53af..9ff864c8c5 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterDepthTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers; import com.google.common.base.Optional; import com.google.common.collect.Sets; diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java similarity index 99% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java index b6c2da7724..031fc6370f 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterFieldsTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers; import com.google.common.base.Optional; import com.google.common.collect.Sets; diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java similarity index 99% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java index 9604fcdebb..ffb10e3dda 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/ParameterAwareNormalizedNodeWriterParametersTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers; import com.google.common.collect.Sets; import java.util.ArrayList; diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java similarity index 95% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderMountPointTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java index cdd77f3697..f3bd4030a9 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -27,11 +27,13 @@ import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestXmlBodyReader; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; +import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; @@ -82,8 +84,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); when(mountPoint.getSchemaContext()).thenReturn(schemaContext); - - CONTROLLER_CONTEXT.setSchemas(schemaContext); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test @@ -190,7 +191,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { @Test public void findFooContainerUsingNamespaceTest() throws Exception { mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlDataFindFooContainer.xml"); final NormalizedNodeContext returnValue = this.xmlBodyReader .readFrom(null, null, null, this.mediaType, null, inputStream); @@ -212,7 +213,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { @Test public void findBarContainerUsingNamespaceTest() throws Exception { mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlDataFindBarContainer.xml"); final NormalizedNodeContext returnValue = this.xmlBodyReader .readFrom(null, null, null, this.mediaType, null, inputStream); @@ -234,7 +235,8 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { @Test public void wrongRootElementTest() throws Exception { mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream( + final InputStream inputStream = + XmlBodyReaderTest.class.getResourceAsStream( "/instanceidentifier/xml/bug7933.xml"); try { this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java similarity index 89% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderMountPointTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java index a2387f115b..42b35bfff3 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.junit.Assert.assertEquals; @@ -22,9 +22,11 @@ import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestJsonBodyReader; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -54,8 +56,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); when(mountPoint.getSchemaContext()).thenReturn(schemaContext); - - CONTROLLER_CONTEXT.setSchemas(schemaContext); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test @@ -63,7 +64,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -79,7 +80,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -96,7 +97,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueMissing.json"); try { @@ -116,7 +117,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json"); try { @@ -135,7 +136,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -151,7 +152,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnList.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -167,7 +168,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -183,7 +184,8 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = + JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHSimpleLeafValue.json"); final PatchContext returnValue = jsonToPatchBodyReader diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java similarity index 88% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java index dbee32eb0e..22355a8c7b 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonPatchBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.junit.Assert.assertEquals; @@ -19,9 +19,11 @@ import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestJsonBodyReader; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { @@ -43,7 +45,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); - CONTROLLER_CONTEXT.setSchemas(schemaContext); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test @@ -51,7 +53,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -67,7 +69,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -84,7 +86,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueMissing.json"); try { @@ -104,7 +106,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataValueNotSupported.json"); try { @@ -123,7 +125,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -139,7 +141,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnList.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -155,7 +157,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json"); final PatchContext returnValue = jsonToPatchBodyReader @@ -171,7 +173,8 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, jsonToPatchBodyReader, false); - final InputStream inputStream = TestJsonBodyReader.class + final InputStream inputStream = + JsonBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/jsonPATCHSimpleLeafValue.json"); final PatchContext returnValue = jsonToPatchBodyReader diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java similarity index 89% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderMountPointTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java index 0a7b130e84..652d3bede4 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -21,9 +21,11 @@ import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestXmlBodyReader; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -53,15 +55,14 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService); when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint)); when(mountPoint.getSchemaContext()).thenReturn(schemaContext); - - CONTROLLER_CONTEXT.setSchemas(schemaContext); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test public void moduleDataTest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -75,7 +76,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void moduleDataValueMissingNegativeTest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueMissing.xml"); try { xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream); @@ -93,7 +94,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void moduleDataNotValueNotSupportedNegativeTest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml"); try { xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream); @@ -111,7 +112,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void moduleDataAbsoluteTargetPathTest() throws Exception { final String uri = MOUNT_POINT; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -125,7 +126,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void modulePatchCompleteTargetInURITest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -139,7 +140,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void moduleDataMergeOperationOnListTest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -153,7 +154,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest { public void moduleDataMergeOperationOnContainerTest() throws Exception { final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java similarity index 88% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java index 51e28761e4..fd3a9b0a52 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlPatchBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -18,9 +18,11 @@ import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestXmlBodyReader; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.patch.PatchContext; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { @@ -42,14 +44,14 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public static void initialization() { schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext); when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); - CONTROLLER_CONTEXT.setSchemas(schemaContext); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test public void moduleDataTest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -63,7 +65,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void moduleDataValueMissingNegativeTest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueMissing.xml"); try { xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream); @@ -81,7 +83,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void moduleDataNotValueNotSupportedNegativeTest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml"); try { xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream); @@ -99,7 +101,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void moduleDataAbsoluteTargetPathTest() throws Exception { final String uri = ""; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -113,7 +115,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void modulePatchCompleteTargetInURITest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -127,7 +129,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void moduleDataMergeOperationOnListTest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); @@ -141,7 +143,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest { public void moduleDataMergeOperationOnContainerTest() throws Exception { final String uri = "instance-identifier-patch-module:patch-cont"; mockBodyReader(uri, xmlToPatchBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml"); final PatchContext returnValue = xmlToPatchBodyReader .readFrom(null, null, null, mediaType, null, inputStream); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/AbstractBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java similarity index 87% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/AbstractBodyReaderTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java index 899991743a..990340edae 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/AbstractBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; @@ -19,24 +19,23 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.netconf.sal.rest.api.RestconfConstants; -import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; -import org.opendaylight.restconf.RestConnectorProvider; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.patch.PatchContext; -import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider; +import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; +import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider; +import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -abstract class AbstractBodyReaderTest { +public abstract class AbstractBodyReaderTest { - protected static final ControllerContext CONTROLLER_CONTEXT = ControllerContext.getInstance(); protected static final DOMMountPointServiceHandler MOUNT_POINT_SERVICE_HANDLER = mock(DOMMountPointServiceHandler.class); protected final MediaType mediaType; - AbstractBodyReaderTest() throws NoSuchFieldException, IllegalAccessException { + protected AbstractBodyReaderTest() throws NoSuchFieldException, IllegalAccessException { mediaType = getMediaType(); final Field mountPointServiceHandlerField = diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java similarity index 96% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonBodyReaderTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java index 0a437cb80d..fc29d70c3a 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/JsonBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -24,9 +24,9 @@ import javax.ws.rs.core.MediaType; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestXmlBodyReader; import org.opendaylight.restconf.common.context.NormalizedNodeContext; +import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; @@ -72,7 +72,6 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest { final Collection testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang"); testFiles.addAll(TestRestconfUtils.loadFiles("/modules")); schemaContext = YangParserTestUtils.parseYangSources(testFiles); - CONTROLLER_CONTEXT.setSchemas(schemaContext); when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); } @@ -136,7 +135,8 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest { .node(contAugmentQName); final String uri = "instance-identifier-module:cont"; mockBodyReader(uri, this.jsonBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = + XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/json_augment_container.json"); final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream); @@ -160,7 +160,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest { .node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName).node(containerQName); final String uri = "instance-identifier-module:cont"; mockBodyReader(uri, this.jsonBodyReader, true); - final InputStream inputStream = TestXmlBodyReader.class + final InputStream inputStream = XmlBodyReaderTest.class .getResourceAsStream("/instanceidentifier/json/json_augment_choice_container.json"); final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java similarity index 96% rename from restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderTest.java rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java index ed1cd6e247..fa2a1d772b 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.jersey.providers; +package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -26,11 +26,12 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; -import org.opendaylight.controller.sal.rest.impl.test.providers.TestXmlBodyReader; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; +import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; +import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; @@ -76,8 +77,8 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest { testFiles.addAll(TestRestconfUtils.loadFiles("/modules")); testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang")); schemaContext = YangParserTestUtils.parseYangSources(testFiles); - CONTROLLER_CONTEXT.setSchemas(schemaContext); when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class)); + SchemaContextHandler.setActualSchemaContext(schemaContext); } @Test @@ -92,7 +93,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest { private void runXmlTest(final boolean isPost, final String path) throws Exception { mockBodyReader(path, xmlBodyReader, isPost); - final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/foo-xml-test/foo.xml"); + final InputStream inputStream = XmlBodyReaderTest.class.getResourceAsStream("/foo-xml-test/foo.xml"); final NormalizedNodeContext nnc = xmlBodyReader.readFrom(null, null, null, mediaType, null, inputStream); assertNotNull(nnc); @@ -267,8 +268,8 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest { @Test public void wrongRootElementTest() throws Exception { mockBodyReader("instance-identifier-module:cont", this.xmlBodyReader, false); - final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream( - "/instanceidentifier/xml/bug7933.xml"); + final InputStream inputStream = + XmlBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/bug7933.xml"); try { this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream); Assert.fail("Test should fail due to malformed PUT operation message"); diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/foo.xml b/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/foo.xml new file mode 100644 index 0000000000..96b69c4366 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/foo.xml @@ -0,0 +1,5 @@ + + + key-value + leaf-value + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/yang/foo.yang b/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/yang/foo.yang new file mode 100644 index 0000000000..ceed3d9be0 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/foo-xml-test/yang/foo.yang @@ -0,0 +1,18 @@ +module foo { + namespace foo; + prefix foo; + + revision 2017-08-09; + + list top-level-list { + key key-leaf; + + leaf key-leaf { + type string; + } + + leaf ordinary-leaf { + type string; + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/iid-value.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/iid-value.yang new file mode 100644 index 0000000000..4e536dfaee --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/iid-value.yang @@ -0,0 +1,23 @@ +module iid-value-module { + namespace "iid:value:module"; + + prefix "iidvm"; + revision 2016-09-12 { + } + + container cont-iid { + list iid-list{ + key "iid-leaf"; + leaf iid-leaf{ + type instance-identifier; + } + } + + list values-iid{ + key "value-iid"; + leaf value-iid{ + type string; + } + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json new file mode 100644 index 0000000000..14839201c7 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json @@ -0,0 +1,43 @@ +{ + "ietf-yang-patch:yang-patch" : { + "patch-id" : "Test merge operation", + "comment" : "This is test patch for merge operation on container", + "edit" : [ + { + "edit-id": "edit1", + "operation": "create", + "target": "/", + "value": { + "patch-cont": { + "my-list1": [ + { + "name": "my-list1 - A", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + }, + { + "name": "my-list1 - B", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + } + ] + } + } + }, + { + "edit-id": "edit2", + "operation": "merge", + "target": "/", + "value": { + "patch-cont": { + "my-list1": { + "name": "my-list1 - Merged", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + } + } + } + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnList.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnList.json new file mode 100644 index 0000000000..3b809e0061 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHMergeOperationOnList.json @@ -0,0 +1,32 @@ +{ + "ietf-yang-patch:yang-patch" : { + "patch-id" : "Test merge operation", + "comment" : "This is test patch for merge operation on list", + "edit" : [ + { + "edit-id": "edit1", + "operation": "replace", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "value": { + "my-list2": { + "name": "my-leaf20", + "my-leaf21": "I am leaf21-0", + "my-leaf22": "I am leaf22-0" + } + } + }, + { + "edit-id": "edit2", + "operation": "merge", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf21']", + "value": { + "my-list2": { + "name": "my-leaf21", + "my-leaf21": "I am leaf21-1", + "my-leaf22": "I am leaf22-1" + } + } + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHSimpleLeafValue.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHSimpleLeafValue.json new file mode 100644 index 0000000000..4a109efb91 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHSimpleLeafValue.json @@ -0,0 +1,17 @@ +{ + "ietf-yang-patch:yang-patch" : { + + "patch-id" : "test-patch", + "comment" : "this is test patch for simple leaf value", + "edit" : [ + { + "edit-id": "edit1", + "operation": "replace", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']/instance-identifier-patch-module:name", + "value": { + "name": "my-leaf20" + } + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdata.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdata.json new file mode 100644 index 0000000000..e027a76672 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdata.json @@ -0,0 +1,35 @@ +{ + "ietf-yang-patch:yang-patch" : { + + "patch-id" : "test-patch", + "comment" : "this is test patch", + "edit" : [ + { + "edit-id": "edit1", + "operation": "replace", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "value": { + "my-list2": { + "name": "my-leaf20", + "my-leaf21": "I am leaf21-0", + "my-leaf22": "I am leaf22-0" + } + } + }, + + { + "edit-id": "edit2", + "operation": "replace", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "value": { + "my-list2": { + "name": "my-leaf20", + "my-leaf21": "I am leaf21-1", + "my-leaf22": "I am leaf22-1", + "my-leaf-list": ["listelement"] + } + } + } + ] + } +} diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json new file mode 100644 index 0000000000..1b170c772f --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json @@ -0,0 +1,44 @@ +{ + "ietf-yang-patch:yang-patch" : { + + "patch-id" : "test-patch", + "comment" : "Test to create and replace data in container directly using / sign as a target", + "edit" : [ + { + "edit-id": "edit1", + "operation": "create", + "target": "/", + "value": { + "patch-cont": { + "my-list1": [ + { + "name": "my-list1 - A", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + }, + { + "name": "my-list1 - B", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + } + ] + } + } + }, + { + "edit-id": "edit2", + "operation": "replace", + "target": "/", + "value": { + "patch-cont": { + "my-list1": { + "name": "my-list1 - Replacing", + "my-leaf11": "I am leaf11-0", + "my-leaf12": "I am leaf12-1" + } + } + } + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json new file mode 100644 index 0000000000..4455038134 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json @@ -0,0 +1,31 @@ +{ + "ietf-yang-patch:yang-patch" : { + "patch-id" : "test-patch", + "comment" : "this is test patch", + "edit" : [ + { + "edit-id": "edit1", + "value": { + "my-list2": [ + { + "name": "my-leaf20", + "my-leaf21": "I am leaf20" + }, + { + "name": "my-leaf21", + "my-leaf21": "I am leaf21-1", + "my-leaf22": "I am leaf21-2" + } + ] + }, + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "operation": "create" + }, + { + "edit-id": "edit2", + "operation": "delete", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']" + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueMissing.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueMissing.json new file mode 100644 index 0000000000..eaf1b37857 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueMissing.json @@ -0,0 +1,13 @@ +{ + "ietf-yang-patch:yang-patch" : { + "patch-id" : "test-patch", + "comment" : "this is test patch", + "edit" : [ + { + "edit-id": "edit1", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "operation": "create" + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueNotSupported.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueNotSupported.json new file mode 100644 index 0000000000..1ad52fb39f --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsonPATCHdataValueNotSupported.json @@ -0,0 +1,20 @@ +{ + "ietf-yang-patch:yang-patch" : { + "patch-id" : "test-patch", + "comment" : "this is test patch", + "edit" : [ + { + "edit-id": "edit2", + "operation": "delete", + "target": "/instance-identifier-patch-module:my-list2[instance-identifier-patch-module:name='my-leaf20']", + "value": { + "my-list2": [ + { + "name": "my-leaf20" + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_choice_container.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_choice_container.json new file mode 100644 index 0000000000..e64e00ed32 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_choice_container.json @@ -0,0 +1,5 @@ +{ + "augment-module:case-choice-case-container1": { + "augment-module:case-choice-case-leaf1": "stryng" + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_container.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_container.json new file mode 100644 index 0000000000..e2532f2876 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_augment_container.json @@ -0,0 +1,5 @@ +{ + "augment-module:cont-augment": { + "augment-module:leaf1": "stryng" + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_sub_container.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_sub_container.json new file mode 100644 index 0000000000..22a1d15e5a --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/json_sub_container.json @@ -0,0 +1,5 @@ +{ + "instance-identifier-module:cont1": { + "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\"lflst11_1\"]" + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata.json new file mode 100644 index 0000000000..07b189deb7 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata.json @@ -0,0 +1,14 @@ +{ + "instance-identifier-module:cont": { + "cont1": { + "augment-module:lst11": [ + { + "keyvalue111":"value1", + "keyvalue112":"value2", + "augment-augment-module:lf111":"/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module:lst11[augment-module:keyvalue111=\"value1\"][augment-module:keyvalue112=\"value2\"]/augment-augment-module:lf112", + "augment-augment-module:lf112":"lf112 value" + } + ] + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json new file mode 100644 index 0000000000..63be4b9d5d --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/json/jsondata_leaf_list.json @@ -0,0 +1,7 @@ +{ + "instance-identifier-module:cont": { + "cont1": { + "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\"lflst11_1\"]" + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/bug7933.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/bug7933.xml new file mode 100644 index 0000000000..aa0d79e324 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/bug7933.xml @@ -0,0 +1,9 @@ + + + diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindBarContainer.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindBarContainer.xml new file mode 100644 index 0000000000..6523345497 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindBarContainer.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindFooContainer.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindFooContainer.xml new file mode 100644 index 0000000000..93aeff8d53 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlDataFindFooContainer.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdata.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdata.xml new file mode 100644 index 0000000000..d7d3a6bea6 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdata.xml @@ -0,0 +1,28 @@ + + test-patch + this is test patch + + edit1 + create + /my-list2 + + + my-leaf20 + I am leaf21-0 + I am leaf22-0 + + + + + edit2 + create + /my-list2 + + + my-leaf21 + I am leaf21-1 + I am leaf22-1 + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml new file mode 100644 index 0000000000..6e84c47a49 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml @@ -0,0 +1,35 @@ + + + test-patch + Test patch with absolute target path + + edit1 + create + /instance-identifier-patch-module:patch-cont/my-list1/leaf1/my-list2 + + + my-leaf20 + I am leaf21-0 + I am leaf22-0 + + + + + edit2 + create + /instance-identifier-patch-module:patch-cont/my-list1/leaf1/my-list2 + + + my-leaf21 + I am leaf21-1 + I am leaf22-1 + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml new file mode 100644 index 0000000000..23d2ce0cdc --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml @@ -0,0 +1,44 @@ + + + test-patch + Test to create and replace data in container directly using / sign as a target + + edit1 + create + / + + + + my-list1 - A + I am leaf11-0 + I am leaf12-1 + + + my-list1 - B + I am leaf11-0 + I am leaf12-1 + + + + + + edit2 + replace + / + + + + my-list1 - Replacing + I am leaf11-0 + I am leaf12-1 + + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml new file mode 100644 index 0000000000..afa35bdb49 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml @@ -0,0 +1,44 @@ + + + Test merge operation + This is test patch for merge operation on container + + edit1 + create + / + + + + my-list1 - A + I am leaf11-0 + I am leaf12-1 + + + my-list1 - B + I am leaf11-0 + I am leaf12-1 + + + + + + edit2 + merge + / + + + + my-list1 - Merged + I am leaf11-0 + I am leaf12-1 + + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml new file mode 100644 index 0000000000..ad130413a4 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml @@ -0,0 +1,35 @@ + + + Test merge operation + This is test patch for merge operation on list + + edit1 + replace + /my-list2 + + + my-leaf20 + I am leaf21-0 + I am leaf22-0 + + + + + edit2 + merge + /my-list2 + + + my-leaf21 + I am leaf21-1 + I am leaf22-1 + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueMissing.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueMissing.xml new file mode 100644 index 0000000000..eeec5ad9b0 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueMissing.xml @@ -0,0 +1,16 @@ + + + test-patch + Test patch with missing value node for create operation + + edit1 + create + /my-list2 + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml new file mode 100644 index 0000000000..8817094407 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml @@ -0,0 +1,23 @@ + + + test-patch + Test patch with not allowed value node for delete operation + + edit1 + delete + /my-list2/my-leaf21 + + + my-leaf20 + I am leaf21-0 + I am leaf22-0 + + + + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml new file mode 100644 index 0000000000..d73b3008b6 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_choice_container.xml @@ -0,0 +1,3 @@ + + stryng + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_container.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_container.xml new file mode 100644 index 0000000000..6b35e9e967 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_augment_container.xml @@ -0,0 +1,3 @@ + + stryng + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_sub_container.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_sub_container.xml new file mode 100644 index 0000000000..f76e08dda0 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xml_sub_container.xml @@ -0,0 +1,6 @@ + + lflst11_1 + lflst11_2 + lflst11_3 + /a:cont/a:cont1/b:lflst11[.="lflst11_1"] + \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata.xml new file mode 100644 index 0000000000..bd558fb6b9 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata.xml @@ -0,0 +1,10 @@ + + + + value1 + value2 + /a:cont/a:cont1/b:lst11[b:keyvalue111="value1"][b:keyvalue112="value2"]/c:lf112 + lf112 value + + + diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml new file mode 100644 index 0000000000..00d58c2cb7 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/xml/xmldata_leaf_list.xml @@ -0,0 +1,8 @@ + + + lflst11_1 + lflst11_2 + lflst11_3 + /a:cont/a:cont1/b:lflst11[.="lflst11_1"] + + diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-augment-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-augment-module.yang new file mode 100644 index 0000000000..3bcc93acc9 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-augment-module.yang @@ -0,0 +1,20 @@ +module augment-augment-module { + namespace "augment:augment:module"; + + prefix "aamodule"; + + import augment-module {prefix amodule; revision-date 2014-01-17;} + import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} + + revision 2014-01-17 { + } + + augment "/imodule:cont/imodule:cont1/amodule:lst11" { + leaf lf111 { + type instance-identifier; + } + leaf lf112 { + type string; + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang new file mode 100644 index 0000000000..f49ae6536a --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module-leaf-list.yang @@ -0,0 +1,19 @@ +module augment-module-leaf-list { + namespace "augment:module:leaf:list"; + + prefix "amodulelflst"; + + import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} + + revision 2014-01-27 { + } + + augment "/imodule:cont/imodule:cont1" { + leaf-list lflst11 { + type string; + } + leaf lf11 { + type instance-identifier; + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module.yang new file mode 100644 index 0000000000..f795cab53a --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/augment-module.yang @@ -0,0 +1,63 @@ +module augment-module { + namespace "augment:module"; + + prefix "amodule"; + + import instance-identifier-module {prefix imodule; revision-date 2014-01-17;} + + revision 2014-01-17 { + } + + augment "/imodule:cont/imodule:cont1" { + list lst11 { + key "keyvalue111 keyvalue112"; + leaf keyvalue111 { + type string; + } + leaf keyvalue112 { + type string; + } + } + } + + augment "/imodule:cont" { + container cont-augment { + leaf leaf1 { + type string; + } + } + } + + augment "/imodule:cont" { + choice augment-choice1 { + case case1 { + container case-container1 { + leaf case-leaf1 { + type string; + } + } + } + + case case2 { + container case-container2 { + leaf case-leaf2 { + type string; + } + } + } + } + } + + augment "/imodule:cont/augment-choice1/case1" { + choice augment-choice2 { + case case11 { + container case-choice-case-container1 { + leaf case-choice-case-leaf1 { + type string; + } + } + } + } + } + +} diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/bar-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/bar-module.yang new file mode 100644 index 0000000000..90de085472 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/bar-module.yang @@ -0,0 +1,11 @@ +module bar-module { + namespace "bar:module"; + + prefix "bar-module"; + revision 2016-09-29 { + } + + /* This container has the same name as container in foo-module */ + container foo-bar-container { + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/foo-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/foo-module.yang new file mode 100644 index 0000000000..16b8e7f355 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/foo-module.yang @@ -0,0 +1,11 @@ +module foo-module { + namespace "foo:module"; + + prefix "foo-module"; + revision 2016-09-29 { + } + + /* This container has the same name as container in bar-module */ + container foo-bar-container { + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang new file mode 100644 index 0000000000..ffa5db62ad --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-module.yang @@ -0,0 +1,12 @@ +module instance-identifier-module { + namespace "instance:identifier:module"; + + prefix "iimodule"; + revision 2014-01-17 { + } + + container cont { + container cont1 { + } + } +} \ No newline at end of file diff --git a/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-patch-module.yang b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-patch-module.yang new file mode 100644 index 0000000000..02c1c2eaaa --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/test/resources/instanceidentifier/yang/instance-identifier-patch-module.yang @@ -0,0 +1,47 @@ +module instance-identifier-patch-module { + namespace "instance:identifier:patch:module"; + + prefix "iipmodule"; + revision 2015-11-21 { + } + + container patch-cont { + list my-list1 { + + description "PATCH /restconf/config/instance-identifier-patch-module:patch-cont/my-list1/leaf1"; + + key name; + + leaf name { + type string; + } + + leaf my-leaf11 { + type string; + } + + leaf my-leaf12 { + type string; + } + + list my-list2 { + key name; + + leaf name { + type string; + } + + leaf my-leaf21 { + type string; + } + + leaf my-leaf22 { + type string; + } + leaf-list my-leaf-list { + type string; + } + } + } + } +} -- 2.36.6