Bug 7433 - Remove use of YangSchemaSourceImpl from restconf tests 24/50124/4
authorJakub Toth <jatoth@cisco.com>
Mon, 9 Jan 2017 10:35:00 +0000 (11:35 +0100)
committerJakub Toth <jatoth@cisco.com>
Tue, 10 Jan 2017 09:31:38 +0000 (09:31 +0000)
Change-Id: I3a5901618cbe162eed07cf0301626e6228df4360
Signed-off-by: Jakub Toth <jatoth@cisco.com>
33 files changed:
restconf/sal-rest-connector/pom.xml
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/InstanceIdentifierTypeLeafTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplNotificationSubscribingTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/sal/restconf/impl/InstanceIdentifierCodecImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/base/services/impl/RestconfImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/base/services/impl/RestconfOperationsServiceTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/base/services/impl/RestconfSchemaServiceTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/handlers/SchemaContextHandlerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/jersey/providers/JsonBodyReaderTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/jersey/providers/XmlBodyReaderTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfDataServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfInvokeOperationsServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfStreamsSubscriptionServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/CreateStreamUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/PatchDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/PostDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/PutDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/parser/ParserFieldsParameterTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/parser/ParserIdentifierTest.java
restconf/sal-rest-docgen/pom.xml
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGenTestHelper.java

index 098c1b3f0d618b1ec055bbd5ab2c19157e062857..14d4cf3ac1a51af90168646781e7fdb2c1de3386 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-parser-impl</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-test-util</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.mdsal.model</groupId>
       <artifactId>ietf-restconf</artifactId>
index 029c3c9bf7487c375beca84f60a4f79a98f4936e..1ba0f3f89395a98e216f79b9563608a49a8235d8 100644 (file)
@@ -8,19 +8,17 @@
 
 package org.opendaylight.controller.md.sal.rest.common;
 
+import com.google.common.base.Preconditions;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-
 import org.opendaylight.controller.sal.rest.impl.test.providers.TestJsonBodyWriter;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
@@ -35,28 +33,20 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.base.Preconditions;
-
 /**
- * sal-rest-connector
- * org.opendaylight.controller.md.sal.rest.common
+ * sal-rest-connector org.opendaylight.controller.md.sal.rest.common
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 7, 2015
+ *         Created: Mar 7, 2015
  */
 public class TestRestconfUtils {
 
@@ -82,21 +72,20 @@ public class TestRestconfUtils {
         BUILDERFACTORY = factory;
     }
 
-    private TestRestconfUtils () {
+    private TestRestconfUtils() {
         throw new UnsupportedOperationException("Test utility class");
     }
 
     public static SchemaContext loadSchemaContext(final String yangPath, final SchemaContext schemaContext) {
         try {
             Preconditions.checkArgument(yangPath != null, "Path can not be null.");
-            Preconditions.checkArgument(( ! yangPath.isEmpty()), "Path can not be empty.");
+            Preconditions.checkArgument((!yangPath.isEmpty()), "Path can not be empty.");
             if (schemaContext == null) {
-                return loadSchemaContext(yangPath);
+                return YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(yangPath));
             } else {
                 throw new UnsupportedOperationException("Unable to add new yang sources to existing schema context.");
             }
-        }
-        catch (final Exception e) {
+        } catch (final Exception e) {
             LOG.error("Yang files at path: " + yangPath + " weren't loaded.");
         }
         return schemaContext;
@@ -106,7 +95,8 @@ public class TestRestconfUtils {
         throw new AbstractMethodError("Not implemented yet");
     }
 
-    public static NormalizedNodeContext loadNormalizedContextFromXmlFile(final String pathToInputFile, final String uri) {
+    public static NormalizedNodeContext loadNormalizedContextFromXmlFile(final String pathToInputFile,
+            final String uri) {
         final InstanceIdentifierContext<?> iiContext = ControllerContext.getInstance().toInstanceIdentifier(uri);
         final InputStream inputStream = TestJsonBodyWriter.class.getResourceAsStream(pathToInputFile);
         try {
@@ -114,8 +104,7 @@ public class TestRestconfUtils {
             final Document doc = dBuilder.parse(inputStream);
             final NormalizedNode<?, ?> nn = parse(iiContext, doc);
             return new NormalizedNodeContext(iiContext, nn);
-        }
-        catch (final Exception e) {
+        } catch (final Exception e) {
             LOG.error("Load xml file " + pathToInputFile + " fail.", e);
         }
         return null;
@@ -152,12 +141,13 @@ public class TestRestconfUtils {
                 }
             }
         }
-        final DomToNormalizedNodeParserFactory parserFactory =
-                DomToNormalizedNodeParserFactory.getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, iiContext.getSchemaContext());
+        final DomToNormalizedNodeParserFactory parserFactory = DomToNormalizedNodeParserFactory
+                .getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, iiContext.getSchemaContext());
 
-        if(schemaNode instanceof ContainerSchemaNode) {
-            return parserFactory.getContainerNodeParser().parse(Collections.singletonList(doc.getDocumentElement()), (ContainerSchemaNode) schemaNode);
-        } else if(schemaNode instanceof ListSchemaNode) {
+        if (schemaNode instanceof ContainerSchemaNode) {
+            return parserFactory.getContainerNodeParser().parse(Collections.singletonList(doc.getDocumentElement()),
+                    (ContainerSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ListSchemaNode) {
             final ListSchemaNode casted = (ListSchemaNode) schemaNode;
             return parserFactory.getMapEntryNodeParser().parse(elements, casted);
         } // FIXME : add another DataSchemaNode extensions e.g. LeafSchemaNode
@@ -180,22 +170,4 @@ public class TestRestconfUtils {
         }
         return testFiles;
     }
-
-    public static SchemaContext loadSchemaContext(String resourceDirectory)
-            throws SourceException, ReactorException, FileNotFoundException,
-            URISyntaxException {
-        return parseYangSources(loadFiles(resourceDirectory));
-    }
-
-    public static SchemaContext parseYangSources(Collection<File> testFiles)
-            throws SourceException, ReactorException, FileNotFoundException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        for (File testFile : testFiles) {
-            reactor.addSource(new YangStatementSourceImpl(
-                    new NamedFileInputStream(testFile, testFile.getPath())));
-        }
-
-        return reactor.buildEffective();
-    }
 }
index 8439d0cbc4deed7e9b5ffb7fdaa98137cca8e6ea..23eab0435ceaf33285029c810bd6f232b6cb55fb 100644 (file)
@@ -17,12 +17,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class InstanceIdentifierTypeLeafTest {
 
     @Test
     public void stringToInstanceIdentifierTest() throws Exception {
-        final SchemaContext schemaContext = TestRestconfUtils.loadSchemaContext("/instanceidentifier");
+        final SchemaContext schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/instanceidentifier"));
         ControllerContext.getInstance().setGlobalSchema(schemaContext);
         final InstanceIdentifierContext<?> instanceIdentifier =
                 ControllerContext.getInstance().toInstanceIdentifier(
index a12dcf014fa55a95f0eff28a99f44cb78835fe64..b3cc32dcaf53c9426f021d611b511df2344b5208 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector
@@ -70,7 +71,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
 
     public TestJsonBodyReader () throws NoSuchFieldException, SecurityException {
         super();
-        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
@@ -83,7 +84,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
     }
 
@@ -93,11 +94,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, false);
+        mockBodyReader(uri, this.jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -110,11 +111,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName);
         final String uri = "instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, jsonBodyReader, false);
+        mockBodyReader(uri, this.jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII);
     }
@@ -126,11 +127,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1");
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -146,11 +147,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augII).node(contAugmentQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_augment_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -172,11 +173,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
                 .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName)
                 .node(containerQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_augment_choice_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -184,11 +185,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName
index 604df056f74f728d56b90e08377ced2527b1277a..f4f063964d47820e202a288cc3844af976794f47 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
@@ -69,7 +70,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
     public TestJsonBodyReaderMountPoint() throws NoSuchFieldException,
             SecurityException {
         super();
-        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
@@ -82,7 +83,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
 
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
@@ -99,11 +100,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, false);
+        mockBodyReader(uri, this.jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -113,11 +114,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, jsonBodyReader, false);
+        mockBodyReader(uri, this.jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
                 QName.create(dataSchemaNode.getQName(), "cont1"));
@@ -128,11 +129,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -140,11 +141,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName
@@ -179,7 +180,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
                 .getSchemaContext().getDataChildByName(
                         dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
-        if (qName != null && dataSchemaNode instanceof DataNodeContainer) {
+        if ((qName != null) && (dataSchemaNode instanceof DataNodeContainer)) {
             final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
                     .getDataChildByName(qName);
             dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
index 37d56bfbf1b2f2c6363f79ee25d986f3aea905e2..d708ef822c96b204f07c92fca1715d27805a65b2 100644 (file)
@@ -15,9 +15,7 @@ import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
-
 import javax.ws.rs.core.MediaType;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
@@ -25,6 +23,7 @@ import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
 import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
@@ -43,8 +42,8 @@ public class TestJsonBodyWriter extends AbstractBodyReaderTest {
 
     public TestJsonBodyWriter() throws NoSuchFieldException, SecurityException {
         super();
-        jsonBodyWriter = new NormalizedNodeJsonBodyWriter();
-        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        this.jsonBodyWriter = new NormalizedNodeJsonBodyWriter();
+        this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
@@ -54,23 +53,23 @@ public class TestJsonBodyWriter extends AbstractBodyReaderTest {
 
     @BeforeClass
     public static void initialization() throws Exception {
-        Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
+        final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
     }
 
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, jsonBodyReader, true);
+        mockBodyReader(uri, this.jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyWriter.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-output.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         final OutputStream output = new ByteArrayOutputStream();
-        jsonBodyWriter.writeTo(returnValue, null, null, null, mediaType, null,
+        this.jsonBodyWriter.writeTo(returnValue, null, null, null, this.mediaType, null,
                 output);
         assertTrue(output.toString().contains("lf-test"));
     }
index e14246434c06db91f3d6e4d510f478e042762e7a..5817257b362cbbdbd7b33c3e09138379ede97786 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector
@@ -65,7 +66,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
 
     public TestXmlBodyReader () throws NoSuchFieldException, SecurityException {
         super();
-        xmlBodyReader = new XmlNormalizedNodeBodyReader();
+        this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
     }
 
     @Override
@@ -78,7 +79,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
     }
 
@@ -88,11 +89,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, false);
+        mockBodyReader(uri, this.xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -105,11 +106,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName);
         final String uri = "instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, xmlBodyReader, false);
+        mockBodyReader(uri, this.xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII);
     }
@@ -121,11 +122,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1");
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -141,11 +142,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augII).node(contAugmentQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_augment_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -166,11 +167,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
                 .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName)
                 .node(containerQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_augment_choice_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -178,11 +179,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
@@ -217,11 +218,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
      */
     @Test
     public void findFooContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("", xmlBodyReader, true);
+        mockBodyReader("", this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindFooContainer.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
 
         // check return value
         checkNormalizedNodeContext(returnValue);
@@ -239,11 +240,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
      */
     @Test
     public void findBarContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("", xmlBodyReader, true);
+        mockBodyReader("", this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindBarContainer.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
 
         // check return value
         checkNormalizedNodeContext(returnValue);
index 2bb8ece0e10fa8651e1ae52ec66dd4c38c9015f0..bc35c07d966ed63cfd4301c58df45fc2ea7313f4 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
@@ -70,7 +71,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
     public TestXmlBodyReaderMountPoint() throws NoSuchFieldException,
             SecurityException {
         super();
-        xmlBodyReader = new XmlNormalizedNodeBodyReader();
+        this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
     }
 
     @Override
@@ -83,7 +84,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
 
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
@@ -100,11 +101,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, false);
+        mockBodyReader(uri, this.xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -114,11 +115,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, xmlBodyReader, false);
+        mockBodyReader(uri, this.xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
                 QName.create(dataSchemaNode.getQName(), "cont1"));
@@ -129,11 +130,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -141,11 +142,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, xmlBodyReader, true);
+        mockBodyReader(uri, this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
-                null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
+                null, null, this.mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
@@ -177,7 +178,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
                 .getSchemaContext().getDataChildByName(
                         dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
-        if (qName != null && dataSchemaNode instanceof DataNodeContainer) {
+        if ((qName != null) && (dataSchemaNode instanceof DataNodeContainer)) {
             final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
                     .getDataChildByName(qName);
             dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
@@ -198,11 +199,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
      */
     @Test
     public void findFooContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, true);
+        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindFooContainer.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
 
         // check return value
         checkMountPointNormalizedNodeContext(returnValue);
@@ -220,11 +221,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
      */
     @Test
     public void findBarContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, true);
+        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindBarContainer.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = this.xmlBodyReader
+                .readFrom(null, null, null, this.mediaType, null, inputStream);
 
         // check return value
         checkMountPointNormalizedNodeContext(returnValue);
index 67e6b6ddf2af02d5274fafc99616af038b1daa24..3ea5f837b7efbea7d234372efeaa02347c0238e9 100644 (file)
@@ -14,15 +14,14 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.OutputStream;
 import java.util.Collection;
-
 import javax.ws.rs.core.MediaType;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
@@ -40,7 +39,7 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest {
 
     public TestXmlBodyWriter() throws NoSuchFieldException, SecurityException {
         super();
-        xmlBodyWriter = new NormalizedNodeXmlBodyWriter();
+        this.xmlBodyWriter = new NormalizedNodeXmlBodyWriter();
     }
 
     @Override
@@ -50,10 +49,10 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest {
 
     @BeforeClass
     public static void initialization() throws Exception {
-        Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
+        final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
     }
 
@@ -64,7 +63,7 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest {
         final NormalizedNodeContext nnContext = TestRestconfUtils
                 .loadNormalizedContextFromXmlFile(pathToInputFile, uri);
         final OutputStream output = new ByteArrayOutputStream();
-        xmlBodyWriter.writeTo(nnContext, null, null, null, mediaType, null,
+        this.xmlBodyWriter.writeTo(nnContext, null, null, null, this.mediaType, null,
                 output);
         assertTrue(output.toString().contains("lf-test"));
     }
index c2e69f79888edee23b4da7e7b95d8e6568846384..fae6281d4a88d63152d96bd06c94d629b866ec6c 100644 (file)
@@ -5,9 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-/**
- *
- */
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import java.lang.reflect.Field;
@@ -41,6 +38,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfImplNotificationSubscribingTest {
 
@@ -61,7 +59,8 @@ public class RestconfImplNotificationSubscribingTest {
 
         this.broker.setDomDataBroker(this.domDataBroker);
         RestconfImpl.getInstance().setBroker(this.broker);
-        ControllerContext.getInstance().setGlobalSchema(TestRestconfUtils.loadSchemaContext("/notifications"));
+        ControllerContext.getInstance()
+                .setGlobalSchema(YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/notifications")));
 
         final YangInstanceIdentifier path = Mockito.mock(YangInstanceIdentifier.class);
         final PathArgument pathValue = NodeIdentifier.create(QName.create("module", "2016-14-12", "localName"));
index 38fc0bba1363d8c36a7d982ba6bc3d00a0a919a0..e25f2531906e0c9748a4f273719e88dac5ded17f 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertNotNull;
+
 import com.google.common.base.Preconditions;
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
@@ -22,7 +23,9 @@ import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
 import java.sql.Date;
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
@@ -47,10 +50,8 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -62,8 +63,7 @@ public final class TestUtils {
 
     public static SchemaContext loadSchemaContext(final String... yangPath)
             throws FileNotFoundException, ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-
+        final List<InputStream> files = new ArrayList<>();
         for (int i = 0; i < yangPath.length; i++) {
             final String path = yangPath[i];
             final String pathToFile = TestUtils.class.getResource(path).getPath();
@@ -72,15 +72,16 @@ public final class TestUtils {
             if (fileList == null) {
                 throw new FileNotFoundException(pathToFile);
             }
+
             for (int j = 0; j < fileList.length; j++) {
                 final String fileName = fileList[j];
                 final File file = new File(testDir, fileName);
                 if (file.isDirectory() == false) {
-                    reactor.addSource(new YangStatementSourceImpl(new NamedFileInputStream(file, file.getPath())));
+                    files.add(new NamedFileInputStream(file, file.getPath()));
                 }
             }
         }
-        return reactor.buildEffective();
+        return YangParserTestUtils.parseYangStreams(files);
     }
 
     public static Module findModule(final Set<Module> modules, final String moduleName) {
@@ -119,7 +120,7 @@ public final class TestUtils {
                 StandardCharsets.UTF_8)));
             final byte[] charData = out.toByteArray();
             return new String(charData, StandardCharsets.UTF_8);
-        } catch (TransformerException e) {
+        } catch (final TransformerException e) {
             final String msg = "Error during transformation of Document into String";
             LOG.error(msg, e);
             return msg;
index de9e1f54581a987b2fd2a851054b6da91bd329ad..207dac862ad2193bd29fe245f6b63101fb7d4309 100644 (file)
@@ -10,15 +10,16 @@ package org.opendaylight.netconf.sal.restconf.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.opendaylight.netconf.sal.restconf.impl.RestCodec.InstanceIdentifierCodecImpl;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
+import org.opendaylight.netconf.sal.restconf.impl.RestCodec.InstanceIdentifierCodecImpl;
 import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class InstanceIdentifierCodecImplTest {
 
@@ -30,26 +31,27 @@ public class InstanceIdentifierCodecImplTest {
 
     @Before
     public void setUp() throws Exception {
-        schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser/deserializer");
-        instanceIdentifierDTO = new InstanceIdentifierCodecImpl(null);
-        ControllerContext.getInstance().setGlobalSchema(schemaContext);
+        this.schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
+        this.instanceIdentifierDTO = new InstanceIdentifierCodecImpl(null);
+        ControllerContext.getInstance().setGlobalSchema(this.schemaContext);
 
         final QName baseQName = QName.create("deserializer:test", "2016-06-06", "deserializer-test");
         final QName contA = QName.create(baseQName, "contA");
         final QName leafList = QName.create(baseQName, "leaf-list-A");
 
-        instanceIdentifierOKLeafList = YangInstanceIdentifier.builder()
+        this.instanceIdentifierOKLeafList = YangInstanceIdentifier.builder()
                 .node(contA)
                 .node(new YangInstanceIdentifier.NodeWithValue<>(leafList, "instance"))
                 .build();
 
-        instanceIdentifierOKList = YangInstanceIdentifier.builder()
+        this.instanceIdentifierOKList = YangInstanceIdentifier.builder()
                 .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
                         QName.create(baseQName, "list-one-key"),
                         QName.create(QName.create(baseQName, "list-one-key"), "name"), "value"))
                 .build();
 
-        instanceIdentifierBadNamespace = YangInstanceIdentifier.builder()
+        this.instanceIdentifierBadNamespace = YangInstanceIdentifier.builder()
                 .nodeWithKey(QName.create("nonexistent:module", "2016-10-17", "nonexistent-1"),
                         QName.create("nonexistent:module", "2016-10-17", "nonexistent"),
                         "value")
@@ -59,32 +61,32 @@ public class InstanceIdentifierCodecImplTest {
     @Test
     public void testSerializeDeserializeList() throws Exception {
         final IdentityValuesDTO valuesDTO =
-                instanceIdentifierDTO.serialize(instanceIdentifierOKList);
+                this.instanceIdentifierDTO.serialize(this.instanceIdentifierOKList);
 
         final YangInstanceIdentifier deserializedIdentifier =
-                instanceIdentifierDTO.deserialize(valuesDTO);
-        assertEquals(instanceIdentifierOKList, deserializedIdentifier);
+                this.instanceIdentifierDTO.deserialize(valuesDTO);
+        assertEquals(this.instanceIdentifierOKList, deserializedIdentifier);
     }
 
     @Test
     public void testSerializeDeserializeLeafList() throws Exception {
         final IdentityValuesDTO valuesDTO =
-                instanceIdentifierDTO.serialize(instanceIdentifierOKLeafList);
+                this.instanceIdentifierDTO.serialize(this.instanceIdentifierOKLeafList);
 
         final YangInstanceIdentifier deserializedIdentifier =
-                instanceIdentifierDTO.deserialize(valuesDTO);
-        assertEquals(instanceIdentifierOKLeafList, deserializedIdentifier);
+                this.instanceIdentifierDTO.deserialize(valuesDTO);
+        assertEquals(this.instanceIdentifierOKLeafList, deserializedIdentifier);
     }
 
     @Test
     public void testSerializeDeserializeBadModuleNamespace() throws Exception {
         final IdentityValuesDTO valuesDTO =
-                instanceIdentifierDTO.serialize(instanceIdentifierBadNamespace);
+                this.instanceIdentifierDTO.serialize(this.instanceIdentifierBadNamespace);
         assertEquals("nonexistent-1", valuesDTO.getValuesWithNamespaces().get(0).getValue());
         assertEquals("nonexistent:module", valuesDTO.getValuesWithNamespaces().get(0).getNamespace());
 
         final YangInstanceIdentifier deserializedIdentifier =
-                instanceIdentifierDTO.deserialize(valuesDTO);
+                this.instanceIdentifierDTO.deserialize(valuesDTO);
         assertNull(deserializedIdentifier);
     }
 }
\ No newline at end of file
index 2d1e64517d52630a97a5ea214b3c3a84247f89af..a9d4fdec67e9fadc80de9d5c917a3e599db27ca4 100644 (file)
@@ -20,12 +20,14 @@ import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.handlers.TransactionChainHandler;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfImplTest {
 
     @Test
     public void RestImplTest() throws Exception {
-        final SchemaContext schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/impl");
+        final SchemaContext schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/impl"));
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
index 7037bf8429ef4bc89a54f401ce41a2b38a7a19ee..ded94ef8342ee6429adc377e4665f35ec3cbd2f2 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.restconf.base.services.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.net.URI;
@@ -25,7 +26,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.restconf.base.services.impl.RestconfOperationsServiceImpl;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.handlers.TransactionChainHandler;
@@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfOperationsServiceTest {
 
@@ -53,7 +54,7 @@ public class RestconfOperationsServiceTest {
     @Before
     public void init() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.schemaContext = TestRestconfUtils.loadSchemaContext("/modules");
+        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
index e3f65e7a6710ba9bcab13d0ddfdfda8d6e0b36d9..681d25b3e19f27e28c4e5ac9eb294a69faeba518 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.when;
+
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import java.util.HashMap;
 import org.junit.Before;
@@ -30,7 +31,6 @@ import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
 import org.opendaylight.restconf.base.services.api.RestconfSchemaService;
-import org.opendaylight.restconf.base.services.impl.RestconfSchemaServiceImpl;
 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.utils.RestconfConstants;
@@ -39,6 +39,7 @@ import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@code RestconfSchemaService}
@@ -81,9 +82,11 @@ public class RestconfSchemaServiceTest {
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
 
-        this.schemaContext = TestRestconfUtils.loadSchemaContext("/modules");
-        this.schemaContextBehindMountPoint = TestRestconfUtils.loadSchemaContext("/modules/modules-behind-mount-point");
-        this.schemaContextWithMountPoints = TestRestconfUtils.loadSchemaContext("/modules/mount-points");
+        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
+        this.schemaContextBehindMountPoint = YangParserTestUtils
+                .parseYangSources(TestRestconfUtils.loadFiles("/modules/modules-behind-mount-point"));
+        this.schemaContextWithMountPoints =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules/mount-points"));
 
         // create and register mount points
         this.mountPoint = SimpleDOMMountPoint.create(
index 55d247a35370d4f905eea2a5ae501a7333427d7a..89aa8fbe1328b4c5696b419c46a59b379ab83621 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.restconf.handlers;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
+
 import com.google.common.util.concurrent.CheckedFuture;
 import org.junit.Before;
 import org.junit.Test;
@@ -19,6 +20,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Tests for handling {@link SchemaContext}
@@ -44,7 +46,8 @@ public class SchemaContextHandlerTest {
         Mockito.when(checked.checkedGet()).thenReturn(value);
         this.schemaContextHandler = new SchemaContextHandler(txHandler);
 
-        this.schemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_ACTUAL_SCHEMA_CONTEXT);
+        this.schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_ACTUAL_SCHEMA_CONTEXT));
         this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
     }
 
@@ -77,7 +80,8 @@ public class SchemaContextHandlerTest {
     @Test
     public void onGlobalContextUpdateTest() throws Exception {
         // create new SchemaContext and update SchemaContextHandler
-        final SchemaContext newSchemaContext = TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT);
+        final SchemaContext newSchemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
         this.schemaContextHandler.onGlobalContextUpdated(newSchemaContext);
 
         assertNotEquals("SchemaContextHandler should not has reference to old SchemaContext",
index 80b147be607d3d7ce96ac45809e8d871ec76b00e..4fffdb6d8eccd880a1c8c64a8152f478f9c42772 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class JsonBodyReaderTest extends AbstractBodyReaderTest {
 
@@ -71,7 +72,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
         when(mountPointServiceHandler.get()).thenReturn(mock(DOMMountPointService.class));
     }
index e1cbb96e5a17d5bff0786d30bdeb65add678e1ae..3cb0e30f02e96c949788f17fb1d34d5649ddb129 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class XmlBodyReaderTest extends AbstractBodyReaderTest {
 
@@ -65,7 +66,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
-        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
+        schemaContext = YangParserTestUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
         when(mountPointServiceHandler.get()).thenReturn(mock(DOMMountPointService.class));
     }
index e1cdd8ba6bd4f6b605501d0d4a62ef2ea4586442..9a60be5adc50107e1209e3795324b2f98f1fbff1 100644 (file)
@@ -10,11 +10,13 @@ package org.opendaylight.restconf.parser;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@link IdentifierCodec} mostly according to examples from draft-ietf-netconf-restconf-13
@@ -23,14 +25,13 @@ public class IdentifierCodecTest {
 
     private static final String URI_WITH_LIST_AND_LEAF =
             "list-test:top/list1=%2C%27" + '"' + "%3A" + '"' + "%20%2F,,foo/list2=a,b/result";
-    private static final String URI_WITH_LEAF_LIST = "list-test:top/Y=x%3Ay";
     private static final String URI_WITH_INT_VAL_LEAF_LIST = "list-test:top/Y=4";
 
     private SchemaContext schemaContext;
 
     @Before
     public void init() throws Exception {
-        this.schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser");
+        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser"));
     }
 
     /**
@@ -41,11 +42,11 @@ public class IdentifierCodecTest {
     @Test
     public void codecListAndLeafTest() {
         final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(
-                this.URI_WITH_LIST_AND_LEAF, this.schemaContext);
+                IdentifierCodecTest.URI_WITH_LIST_AND_LEAF, this.schemaContext);
         final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, this.schemaContext);
 
         assertEquals("Failed codec deserialization and serialization test",
-                this.URI_WITH_LIST_AND_LEAF, serializedDataYangII);
+                IdentifierCodecTest.URI_WITH_LIST_AND_LEAF, serializedDataYangII);
     }
 
     /**
@@ -56,11 +57,11 @@ public class IdentifierCodecTest {
     @Test
     public void codecLeafListTest() {
         final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize(
-                this.URI_WITH_INT_VAL_LEAF_LIST, this.schemaContext);
+                IdentifierCodecTest.URI_WITH_INT_VAL_LEAF_LIST, this.schemaContext);
         final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, this.schemaContext);
 
         assertEquals("Failed codec deserialization and serialization test",
-                this.URI_WITH_INT_VAL_LEAF_LIST, serializedDataYangII);
+                IdentifierCodecTest.URI_WITH_INT_VAL_LEAF_LIST, serializedDataYangII);
     }
 
     /**
index e6d24ec2513c9e17a69c2050f597e81a694aec86..47cd097ecdcecc74d64a7ade033bf9516e9a8e10 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.restconf.parser.builder;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
 import java.util.Iterator;
@@ -27,6 +28,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@link YangInstanceIdentifierDeserializer}
@@ -41,7 +43,8 @@ public class YangInstanceIdentifierDeserializerTest {
 
     @Before
     public void init() throws Exception {
-        this.schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser/deserializer");
+        this.schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/deserializer"));
     }
 
     /**
index b05f43f4f62378a78093b52ea86b0d75c10bbe5f..582ecdc6c04b7df601bbeb4f39f35d66333646e2 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@link YangInstanceIdentifierSerializer}
@@ -39,7 +40,8 @@ public class YangInstanceIdentifierSerializerTest {
 
     @Before
     public void init() throws Exception {
-        schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser/serializer");
+        this.schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/restconf/parser/serializer"));
     }
 
     /**
@@ -52,7 +54,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "contA"))
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful",
                 "serializer-test:contA", result);
     }
@@ -68,7 +70,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "leaf-A"))
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:contA/leaf-A", result);
     }
 
@@ -90,7 +92,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(new NodeWithValue(leafList, "instance"))
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful",
                 "serializer-test:contA/list-A=100/leaf-list-AA=instance",
                 result);
@@ -108,7 +110,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .nodeWithKey(QName.create("serializer:test", "2016-06-06", "list-no-key"), Maps.newHashMap())
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:list-no-key", result);
     }
 
@@ -125,7 +127,7 @@ public class YangInstanceIdentifierSerializerTest {
                         QName.create("serializer:test", "2016-06-06", "list-one-key"), "value")
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:list-one-key=value", result);
     }
 
@@ -145,7 +147,7 @@ public class YangInstanceIdentifierSerializerTest {
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(list).nodeWithKey(list, values).build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:list-multiple-keys=value-1,2,true", result);
     }
 
@@ -160,7 +162,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "leaf-0"))
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:leaf-0", result);
     }
 
@@ -176,7 +178,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(new NodeWithValue(QName.create("serializer:test", "2016-06-06", "leaf-list-0"), "instance"))
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:leaf-list-0=instance", result);
     }
 
@@ -187,7 +189,7 @@ public class YangInstanceIdentifierSerializerTest {
      */
     @Test
     public void serializeNullSchemaContextNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         YangInstanceIdentifierSerializer.create(null, YangInstanceIdentifier.EMPTY);
     }
 
@@ -198,8 +200,8 @@ public class YangInstanceIdentifierSerializerTest {
      */
     @Test
     public void serializeNullDataNegativeTest() {
-        thrown.expect(NullPointerException.class);
-        YangInstanceIdentifierSerializer.create(schemaContext, null);
+        this.thrown.expect(NullPointerException.class);
+        YangInstanceIdentifierSerializer.create(this.schemaContext, null);
     }
 
     /**
@@ -209,7 +211,7 @@ public class YangInstanceIdentifierSerializerTest {
      */
     @Test
     public void serializeEmptyDataTest() {
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, YangInstanceIdentifier.EMPTY);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, YangInstanceIdentifier.EMPTY);
         assertTrue("Empty identifier is expected", result.isEmpty());
     }
 
@@ -224,8 +226,8 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "not-existing-leaf"))
                 .build();
 
-        thrown.expect(IllegalArgumentException.class);
-        YangInstanceIdentifierSerializer.create(schemaContext, data);
+        this.thrown.expect(IllegalArgumentException.class);
+        YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 
     /**
@@ -262,7 +264,7 @@ public class YangInstanceIdentifierSerializerTest {
                         QName.create("serializer:test", "2016-06-06", "list-one-key"), value)
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:list-one-key=" + encoded, result);
     }
 
@@ -279,7 +281,7 @@ public class YangInstanceIdentifierSerializerTest {
                         QName.create("serializer:test", "2016-06-06", "list-one-key"), value)
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
         assertEquals("Serialization not successful", "serializer-test:list-one-key=" + value, result);
     }
 
@@ -300,7 +302,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(child)
                 .build();
 
-        final String result = YangInstanceIdentifierSerializer.create(schemaContext, data);
+        final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
 
         assertEquals("Serialization not successful",
                 "serializer-test-included:augmented-list=100/serializer-test:augmented-leaf", result);
@@ -326,7 +328,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(child)
                 .build();
 
-        thrown.expect(IllegalArgumentException.class);
-        YangInstanceIdentifierSerializer.create(schemaContext, data);
+        this.thrown.expect(IllegalArgumentException.class);
+        YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 }
index d838d4be29778b04a097aa49ba0d809dd9ee652e..99e598315da339dcf6fa42555b7afc3b170c1544 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -67,6 +68,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfDataServiceImplTest {
 
@@ -165,7 +167,8 @@ public class RestconfDataServiceImplTest {
                 .node(this.baseQName)
                 .build();
 
-        this.contextRef = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.contextRef = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schemaNode = DataSchemaContextTree.from(this.contextRef.get()).getChild(this.iidBase).getDataSchemaNode();
 
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
index df5b1c63a5465bad83b7dbd63230e6f085361019..378e53ae84bd4c2eccfe36aa9f3979ada2ea7b21 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfInvokeOperationsServiceImplTest {
 
@@ -49,7 +50,8 @@ public class RestconfInvokeOperationsServiceImplTest {
     @Before
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
-        final SchemaContextRef contextRef = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        final SchemaContextRef contextRef = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
         Mockito.when(txHandler.get()).thenReturn(domTx);
index 7a8fcd327f59342bc72b578e266695954862de1d..b441109ec57aebb9601527baee9908517ebd13a0 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.lang.reflect.Field;
@@ -49,6 +50,7 @@ import org.opendaylight.restconf.handlers.TransactionChainHandler;
 import org.opendaylight.restconf.parser.IdentifierCodec;
 import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class RestconfStreamsSubscriptionServiceImplTest {
 
@@ -97,7 +99,8 @@ public class RestconfStreamsSubscriptionServiceImplTest {
         final Set<Entry<String, List<String>>> set = new HashSet<>();
         Mockito.when(map.entrySet()).thenReturn(set);
         Mockito.when(this.uriInfo.getQueryParameters()).thenReturn(map);
-        this.schemaHandler.onGlobalContextUpdated(TestRestconfUtils.loadSchemaContext("/notifications"));
+        this.schemaHandler.onGlobalContextUpdated(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/notifications")));
     }
 
     @BeforeClass
index 0ab186c3058129092b85bc8c916ecbc77cea01ff..4565d6a61c275230a84cf405d80a6db9f9c3f9db 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.restconf.restful.utils;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+
 import java.util.Collections;
 import java.util.Set;
 import org.junit.Before;
@@ -36,6 +37,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class CreateStreamUtilTest {
 
@@ -47,7 +49,8 @@ public class CreateStreamUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.refSchemaCtx = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
     }
 
     @Test
index 283db9b2012b158f81726d65900680ba560ed493..08c11be9e2a52a0275c5dd6ad66565cc9edd39a7 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class PatchDataTransactionUtilTest {
 
@@ -81,7 +82,8 @@ public class PatchDataTransactionUtilTest {
         PatchDataTransactionUtilTest.broker.setAccessible(true);
         PatchDataTransactionUtilTest.broker.set(RestConnectorProvider.class, mock(DOMDataBroker.class));
 
-        refSchemaCtx = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.refSchemaCtx = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName containerPlayerQName = QName.create(baseQName, "player");
         final QName leafGapQName = QName.create(baseQName, "gap");
@@ -92,7 +94,7 @@ public class PatchDataTransactionUtilTest {
                 new YangInstanceIdentifier.NodeIdentifierWithPredicates(listArtistQName, leafNameQName, "name of artist");
 
         /** instance identifier for accessing leaf node "gap" */
-        iIDCreateAndDelete = YangInstanceIdentifier.builder()
+        this.iIDCreateAndDelete = YangInstanceIdentifier.builder()
                 .node(baseQName)
                 .node(containerPlayerQName)
                 .node(leafGapQName)
@@ -109,18 +111,18 @@ public class PatchDataTransactionUtilTest {
                 .withChild(buildGapLeaf)
                 .build();
 
-        buildBaseContainerForTests = Builders.containerBuilder()
+        this.buildBaseContainerForTests = Builders.containerBuilder()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(baseQName))
                 .withChild(buildPlayerContainer)
                 .build();
 
-        targetNodeForCreateAndDelete = YangInstanceIdentifier.builder(iIDCreateAndDelete)
+        this.targetNodeForCreateAndDelete = YangInstanceIdentifier.builder(this.iIDCreateAndDelete)
                 .node(containerPlayerQName)
                 .node(leafGapQName)
                 .build();
 
         /** instance identifier for accessing leaf node "name" in list "artist" */
-        iIDMerge = YangInstanceIdentifier.builder()
+        this.iIDMerge = YangInstanceIdentifier.builder()
                 .node(baseQName)
                 .node(containerLibraryQName)
                 .node(listArtistQName)
@@ -145,12 +147,12 @@ public class PatchDataTransactionUtilTest {
                 .withChild(contentDescription)
                 .build();
 
-        buildArtistList = Builders.mapBuilder()
+        this.buildArtistList = Builders.mapBuilder()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(listArtistQName))
                 .withChild(mapEntryNode)
                 .build();
 
-        targetNodeMerge = YangInstanceIdentifier.builder()
+        this.targetNodeMerge = YangInstanceIdentifier.builder()
                 .node(baseQName)
                 .node(containerLibraryQName)
                 .node(listArtistQName)
@@ -158,18 +160,18 @@ public class PatchDataTransactionUtilTest {
                 .build();
 
         /** Mocks */
-        doReturn(rWTransaction).when(transactionChain).newReadWriteTransaction();
-        doReturn(Futures.immediateCheckedFuture(null)).when(rWTransaction).submit();
+        doReturn(this.rWTransaction).when(this.transactionChain).newReadWriteTransaction();
+        doReturn(Futures.immediateCheckedFuture(null)).when(this.rWTransaction).submit();
     }
 
     @Test
     public void testPatchDataReplaceMergeAndRemove() {
         doReturn(Futures.immediateCheckedFuture(false)).doReturn(Futures.immediateCheckedFuture(true))
-                .when(rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, targetNodeMerge);
+                .when(this.rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeMerge);
 
-        final PATCHEntity entityReplace = new PATCHEntity("edit1", "REPLACE", targetNodeMerge, buildArtistList);
-        final PATCHEntity entityMerge = new PATCHEntity("edit2", "MERGE", targetNodeMerge, buildArtistList);
-        final PATCHEntity entityRemove = new PATCHEntity("edit3", "REMOVE", targetNodeMerge);
+        final PATCHEntity entityReplace = new PATCHEntity("edit1", "REPLACE", this.targetNodeMerge, this.buildArtistList);
+        final PATCHEntity entityMerge = new PATCHEntity("edit2", "MERGE", this.targetNodeMerge, this.buildArtistList);
+        final PATCHEntity entityRemove = new PATCHEntity("edit3", "REMOVE", this.targetNodeMerge);
         final List<PATCHEntity> entities = new ArrayList<>();
 
         entities.add(entityReplace);
@@ -177,13 +179,13 @@ public class PatchDataTransactionUtilTest {
         entities.add(entityRemove);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(iIDMerge, null, null, refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.iIDMerge, null, null, this.refSchemaCtx.get());
         final PATCHContext patchContext = new PATCHContext(iidContext, entities, "patchRMRm");
-        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChain);
+        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, this.transactionChain);
         final PATCHStatusContext patchStatusContext =
-                PatchDataTransactionUtil.patchData(patchContext, wrapper, refSchemaCtx);
+                PatchDataTransactionUtil.patchData(patchContext, wrapper, this.refSchemaCtx);
 
-        for (PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
+        for (final PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
             assertTrue(entity.isOk());
         }
         assertTrue(patchStatusContext.isOk());
@@ -192,24 +194,24 @@ public class PatchDataTransactionUtilTest {
     @Test
     public void testPatchDataCreateAndDelete() throws Exception {
         doReturn(Futures.immediateCheckedFuture(false)).doReturn(Futures.immediateCheckedFuture(true))
-                .when(rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, targetNodeForCreateAndDelete);
+                .when(this.rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
 
         final PATCHEntity entityCreate =
-                new PATCHEntity("edit1", "CREATE", targetNodeForCreateAndDelete, buildBaseContainerForTests);
+                new PATCHEntity("edit1", "CREATE", this.targetNodeForCreateAndDelete, this.buildBaseContainerForTests);
         final PATCHEntity entityDelete =
-                new PATCHEntity("edit2", "DELETE", targetNodeForCreateAndDelete);
+                new PATCHEntity("edit2", "DELETE", this.targetNodeForCreateAndDelete);
         final List<PATCHEntity> entities = new ArrayList<>();
 
         entities.add(entityCreate);
         entities.add(entityDelete);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(iIDCreateAndDelete, null, null, refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.iIDCreateAndDelete, null, null, this.refSchemaCtx.get());
         final PATCHContext patchContext = new PATCHContext(iidContext, entities, "patchCD");
-        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChain);
-        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, refSchemaCtx);
+        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, this.transactionChain);
+        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, this.refSchemaCtx);
 
-        for (PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
+        for (final PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
             assertTrue(entity.isOk());
         }
         assertTrue(patchStatusContext.isOk());
@@ -218,19 +220,19 @@ public class PatchDataTransactionUtilTest {
     @Test
     public void deleteNonexistentDataTest() {
         doReturn(Futures.immediateCheckedFuture(false))
-                .when(rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, targetNodeForCreateAndDelete);
+                .when(this.rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
 
         final PATCHEntity entityDelete =
-                new PATCHEntity("edit", "DELETE", targetNodeForCreateAndDelete);
+                new PATCHEntity("edit", "DELETE", this.targetNodeForCreateAndDelete);
         final List<PATCHEntity> entities = new ArrayList<>();
 
         entities.add(entityDelete);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(iIDCreateAndDelete, null, null, refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.iIDCreateAndDelete, null, null, this.refSchemaCtx.get());
         final PATCHContext patchContext = new PATCHContext(iidContext, entities, "patchD");
-        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChain);
-        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, refSchemaCtx);
+        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, this.transactionChain);
+        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, this.refSchemaCtx);
 
         assertFalse(patchStatusContext.isOk());
         assertEquals(RestconfError.ErrorType.PROTOCOL,
@@ -242,21 +244,21 @@ public class PatchDataTransactionUtilTest {
     @Test
     public void testPatchMergePutContainer() throws Exception {
         doReturn(Futures.immediateCheckedFuture(false)).doReturn(Futures.immediateCheckedFuture(true))
-                .when(rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, targetNodeForCreateAndDelete);
+                .when(this.rWTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
 
         final PATCHEntity entityMerge =
-                new PATCHEntity("edit1", "MERGE", targetNodeForCreateAndDelete, buildBaseContainerForTests);
+                new PATCHEntity("edit1", "MERGE", this.targetNodeForCreateAndDelete, this.buildBaseContainerForTests);
         final List<PATCHEntity> entities = new ArrayList<>();
 
         entities.add(entityMerge);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(iIDCreateAndDelete, null, null, refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.iIDCreateAndDelete, null, null, this.refSchemaCtx.get());
         final PATCHContext patchContext = new PATCHContext(iidContext, entities, "patchM");
-        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChain);
-        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, refSchemaCtx);
+        final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, this.transactionChain);
+        final PATCHStatusContext patchStatusContext = PatchDataTransactionUtil.patchData(patchContext, wrapper, this.refSchemaCtx);
 
-        for (PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
+        for (final PATCHStatusEntity entity : patchStatusContext.getEditCollection()) {
             assertTrue(entity.isOk());
         }
         assertTrue(patchStatusContext.isOk());
index 337c4cbc047d711793f4a0958df9777cae720abf..f055b3b701d8b60cd52af2430a7b8ca1598d6c53 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+
 import com.google.common.util.concurrent.Futures;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
@@ -40,6 +41,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.DOMException;
 
 public class PostDataTransactionUtilTest {
@@ -68,7 +70,8 @@ public class PostDataTransactionUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.refSchemaCtx = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schema = this.refSchemaCtx.get();
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
index 672dca2896f2e081cae9fa292cdbb7021bf3ffc7..5083583b1117d3490a05a94f1af5c5c02b4be464 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.restconf.restful.utils;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
 import org.junit.Before;
@@ -38,6 +39,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class PutDataTransactionUtilTest {
 
@@ -69,7 +71,8 @@ public class PutDataTransactionUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(TestRestconfUtils.loadSchemaContext(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.refSchemaCtx = new SchemaContextRef(
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
         this.schema = this.refSchemaCtx.get();
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
index f650f85a567426cce83910cff4a9b8b03fec7ebc..758bca72a045c62e54dc60fe57f791e4706e8003 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.restconf.utils.mapping;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.when;
+
 import java.net.URI;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -50,6 +51,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@link RestconfMappingNodeUtil}
@@ -73,11 +75,12 @@ public class RestconfMappingNodeUtilTest {
 
     @BeforeClass
     public static void loadTestSchemaContextAndModules() throws Exception {
-        schemaContext = TestRestconfUtils.loadSchemaContext(
-                "/modules/restconf-module-testing");
-        schemaContextMonitoring = TestRestconfUtils.loadSchemaContext("/modules");
+        schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules/restconf-module-testing"));
+        schemaContextMonitoring = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/modules"));
         modules = schemaContextMonitoring.getModules();
-        modulesRest = TestRestconfUtils.loadSchemaContext("/modules/restconf-module-testing").getModules();
+        modulesRest = YangParserTestUtils
+                .parseYangSources(TestRestconfUtils.loadFiles("/modules/restconf-module-testing")).getModules();
     }
 
     @Before
index 4ba30236b585b1fdf1210dcba343ba83b4462b80..7b6f1448515b68fe5ab435997fa7ab88cd8ed109 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit test for {@link ParserFieldsParameter}
@@ -75,40 +76,41 @@ public class ParserFieldsParameterTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        final SchemaContext schemaContext = TestRestconfUtils.loadSchemaContext("/jukebox");
+        final SchemaContext schemaContext =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/jukebox"));
 
         final QNameModule qNameModule = QNameModule.create(URI.create("http://example.com/ns/example-jukebox"),
                 new SimpleDateFormat("yyyy-MM-dd").parse("2015-04-04"));
 
-        jukeboxQName = QName.create(qNameModule, "jukebox");
-        playerQName = QName.create(qNameModule, "player");
-        libraryQName = QName.create(qNameModule, "library");
-        augmentedLibraryQName = QName.create(
+        this.jukeboxQName = QName.create(qNameModule, "jukebox");
+        this.playerQName = QName.create(qNameModule, "player");
+        this.libraryQName = QName.create(qNameModule, "library");
+        this.augmentedLibraryQName = QName.create(
                 QNameModule.create(
                         URI.create("http://example.com/ns/augmented-jukebox"),
                         new SimpleDateFormat("yyyy-MM-dd").parse("2016-05-05")),
                 "augmented-library");
-        albumQName = QName.create(qNameModule, "album");
-        nameQName = QName.create(qNameModule, "name");
+        this.albumQName = QName.create(qNameModule, "album");
+        this.nameQName = QName.create(qNameModule, "name");
 
-        Mockito.when(identifierContext.getSchemaContext()).thenReturn(schemaContext);
-        Mockito.when(containerJukebox.getQName()).thenReturn(jukeboxQName);
-        Mockito.when(identifierContext.getSchemaNode()).thenReturn(containerJukebox);
+        Mockito.when(this.identifierContext.getSchemaContext()).thenReturn(schemaContext);
+        Mockito.when(this.containerJukebox.getQName()).thenReturn(this.jukeboxQName);
+        Mockito.when(this.identifierContext.getSchemaNode()).thenReturn(this.containerJukebox);
 
-        Mockito.when(containerLibrary.getQName()).thenReturn(libraryQName);
-        Mockito.when(containerJukebox.getDataChildByName(libraryQName)).thenReturn(containerLibrary);
+        Mockito.when(this.containerLibrary.getQName()).thenReturn(this.libraryQName);
+        Mockito.when(this.containerJukebox.getDataChildByName(this.libraryQName)).thenReturn(this.containerLibrary);
 
-        Mockito.when(augmentedContainerLibrary.getQName()).thenReturn(augmentedLibraryQName);
-        Mockito.when(containerJukebox.getDataChildByName(augmentedLibraryQName)).thenReturn(augmentedContainerLibrary);
+        Mockito.when(this.augmentedContainerLibrary.getQName()).thenReturn(this.augmentedLibraryQName);
+        Mockito.when(this.containerJukebox.getDataChildByName(this.augmentedLibraryQName)).thenReturn(this.augmentedContainerLibrary);
 
-        Mockito.when(containerPlayer.getQName()).thenReturn(playerQName);
-        Mockito.when(containerJukebox.getDataChildByName(playerQName)).thenReturn(containerPlayer);
+        Mockito.when(this.containerPlayer.getQName()).thenReturn(this.playerQName);
+        Mockito.when(this.containerJukebox.getDataChildByName(this.playerQName)).thenReturn(this.containerPlayer);
 
-        Mockito.when(listAlbum.getQName()).thenReturn(albumQName);
-        Mockito.when(containerLibrary.getDataChildByName(albumQName)).thenReturn(listAlbum);
+        Mockito.when(this.listAlbum.getQName()).thenReturn(this.albumQName);
+        Mockito.when(this.containerLibrary.getDataChildByName(this.albumQName)).thenReturn(this.listAlbum);
 
-        Mockito.when(leafName.getQName()).thenReturn(nameQName);
-        Mockito.when(listAlbum.getDataChildByName(nameQName)).thenReturn(leafName);
+        Mockito.when(this.leafName.getQName()).thenReturn(this.nameQName);
+        Mockito.when(this.listAlbum.getDataChildByName(this.nameQName)).thenReturn(this.leafName);
     }
 
     /**
@@ -117,12 +119,12 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterSimplePathTest() {
         final String input = "library";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(libraryQName));
+        assertTrue(parsedFields.get(0).contains(this.libraryQName));
     }
 
     /**
@@ -131,13 +133,13 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterDoublePathTest() {
         final String input = "library;player";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
         assertEquals(2, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(libraryQName));
-        assertTrue(parsedFields.get(0).contains(playerQName));
+        assertTrue(parsedFields.get(0).contains(this.libraryQName));
+        assertTrue(parsedFields.get(0).contains(this.playerQName));
     }
 
     /**
@@ -146,19 +148,19 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterSubPathTest() {
         final String input = "library/album/name";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
 
         assertNotNull(parsedFields);
         assertEquals(3, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(libraryQName));
+        assertTrue(parsedFields.get(0).contains(this.libraryQName));
 
         assertEquals(1, parsedFields.get(1).size());
-        assertTrue(parsedFields.get(1).contains(albumQName));
+        assertTrue(parsedFields.get(1).contains(this.albumQName));
 
         assertEquals(1, parsedFields.get(2).size());
-        assertTrue(parsedFields.get(2).contains(nameQName));
+        assertTrue(parsedFields.get(2).contains(this.nameQName));
     }
 
     /**
@@ -167,19 +169,19 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterChildrenPathTest() {
         final String input = "library(album(name))";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
 
         assertNotNull(parsedFields);
         assertEquals(3, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(libraryQName));
+        assertTrue(parsedFields.get(0).contains(this.libraryQName));
 
         assertEquals(1, parsedFields.get(1).size());
-        assertTrue(parsedFields.get(1).contains(albumQName));
+        assertTrue(parsedFields.get(1).contains(this.albumQName));
 
         assertEquals(1, parsedFields.get(2).size());
-        assertTrue(parsedFields.get(2).contains(nameQName));
+        assertTrue(parsedFields.get(2).contains(this.nameQName));
     }
 
     /**
@@ -188,13 +190,13 @@ public class ParserFieldsParameterTest {
     @Test
     public void parseFieldsParameterNamespaceTest() {
         final String input = "augmented-jukebox:augmented-library";
-        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+        final List<Set<QName>> parsedFields = ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
 
         assertNotNull(parsedFields);
         assertEquals(1, parsedFields.size());
 
         assertEquals(1, parsedFields.get(0).size());
-        assertTrue(parsedFields.get(0).contains(augmentedLibraryQName));
+        assertTrue(parsedFields.get(0).contains(this.augmentedLibraryQName));
     }
 
     /**
@@ -205,7 +207,7 @@ public class ParserFieldsParameterTest {
         final String input = "*";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
             fail("Test should fail due to not expected character used in parameter input value");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -223,7 +225,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
             fail("Test should fail due to missing closing parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -241,7 +243,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(not-existing)";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
             fail("Test should fail due to missing child node in parent node");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -259,7 +261,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(album);";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
             fail("Test should fail due to unexpected character after parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
@@ -277,7 +279,7 @@ public class ParserFieldsParameterTest {
         final String input = "library(album)player";
 
         try {
-            ParserFieldsParameter.parseFieldsParameter(identifierContext, input);
+            ParserFieldsParameter.parseFieldsParameter(this.identifierContext, input);
             fail("Test should fail due to missing semicolon after parenthesis");
         } catch (final RestconfDocumentedException e) {
             // Bad request
index 368456a97c486c54ae0b2cc2a1af4b89e3ef71f3..f87ef3588225c08b608ca9de2e6193a5a9662cde 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Unit tests for {@link ParserIdentifier}
@@ -101,25 +102,26 @@ public class ParserIdentifierTest {
     @Before
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
-        schemaContext = TestRestconfUtils.loadSchemaContext("/parser-identifier");
-        schemaContextOnMountPoint = TestRestconfUtils.loadSchemaContext("/parser-identifier");
+        this.schemaContext = YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/parser-identifier"));
+        this.schemaContextOnMountPoint =
+                YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/parser-identifier"));
 
         // create and register mount point
-        mountPoint = SimpleDOMMountPoint.create(
+        this.mountPoint = SimpleDOMMountPoint.create(
                 YangInstanceIdentifier.builder()
                         .node(QName.create("mount:point", "2016-06-02", "mount-container"))
                         .node(QName.create("mount:point", "2016-06-02", "point-number"))
                         .build(),
                 ImmutableClassToInstanceMap.copyOf(Maps.newHashMap()),
-                schemaContextOnMountPoint
+                this.schemaContextOnMountPoint
         );
 
-        mountPointService = new DOMMountPointServiceImpl();
-        ((DOMMountPointServiceImpl) mountPointService).registerMountPoint(mountPoint);
+        this.mountPointService = new DOMMountPointServiceImpl();
+        ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPoint);
 
         // register mount point with null schema context
-        when(mockMountPoint.getSchemaContext()).thenReturn(null);
-        when(mockMountPointService.getMountPoint(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.of(mockMountPoint));
+        when(this.mockMountPoint.getSchemaContext()).thenReturn(null);
+        when(this.mockMountPointService.getMountPoint(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.of(this.mockMountPoint));
     }
 
     /**
@@ -133,7 +135,7 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierTest() {
         final InstanceIdentifierContext<?> context = ParserIdentifier.toInstanceIdentifier(
-                TEST_IDENT, schemaContext, Optional.absent());
+                TEST_IDENT, this.schemaContext, Optional.absent());
 
         assertEquals("Returned not expected identifier",
                 TEST_IDENT_RESULT, context .getInstanceIdentifier().toString());
@@ -146,7 +148,7 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierOtherModulesTest() {
         final InstanceIdentifierContext<?> context = ParserIdentifier.toInstanceIdentifier(
-                TEST_IDENT_OTHERS, schemaContext, Optional.absent());
+                TEST_IDENT_OTHERS, this.schemaContext, Optional.absent());
 
         assertEquals("Returned not expected identifier",
                 TEST_IDENT_OTHERS_RESULT, context.getInstanceIdentifier().toString());
@@ -159,16 +161,16 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierMountPointTest() {
         final InstanceIdentifierContext<?> context = ParserIdentifier.toInstanceIdentifier(
-                MOUNT_POINT_IDENT + "/" + TEST_IDENT, schemaContext, Optional.of(mountPointService));
+                MOUNT_POINT_IDENT + "/" + TEST_IDENT, this.schemaContext, Optional.of(this.mountPointService));
 
         assertEquals("Returned not expected identifier",
                 TEST_IDENT_RESULT.toString(), context.getInstanceIdentifier().toString());
 
         assertEquals("Mount point not found",
-                mountPoint, context.getMountPoint());
+                this.mountPoint, context.getMountPoint());
 
         assertEquals("Schema context from mount point expected",
-                schemaContextOnMountPoint, context.getSchemaContext());
+                this.schemaContextOnMountPoint, context.getSchemaContext());
     }
 
     /**
@@ -178,7 +180,7 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierNullIdentifierTest() {
         final InstanceIdentifierContext<?> context = ParserIdentifier.toInstanceIdentifier(
-                null, schemaContext, Optional.absent());
+                null, this.schemaContext, Optional.absent());
         assertEquals("Returned not expected identifier",
                 YangInstanceIdentifier.EMPTY, context.getInstanceIdentifier());
     }
@@ -189,7 +191,7 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toInstanceIdentifierNullSchemaContextNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.toInstanceIdentifier(TEST_IDENT, null, Optional.absent());
     }
 
@@ -199,7 +201,7 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierEmptyIdentifierTest() {
         final InstanceIdentifierContext<?> context = ParserIdentifier.toInstanceIdentifier(
-                "", schemaContext, Optional.absent());
+                "", this.schemaContext, Optional.absent());
         assertEquals("Returned not expected identifier",
                 YangInstanceIdentifier.EMPTY, context.getInstanceIdentifier());
     }
@@ -209,8 +211,8 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toInstanceIdentifierInvalidIdentifierNegativeTest() {
-        thrown.expect(IllegalArgumentException.class);
-        ParserIdentifier.toInstanceIdentifier(INVALID_TEST_IDENT, schemaContext, Optional.absent());
+        this.thrown.expect(IllegalArgumentException.class);
+        ParserIdentifier.toInstanceIdentifier(INVALID_TEST_IDENT, this.schemaContext, Optional.absent());
     }
 
     /**
@@ -219,8 +221,8 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toInstanceIdentifierMountPointInvalidIdentifierNegativeTest() {
-        thrown.expect(IllegalArgumentException.class);
-        ParserIdentifier.toInstanceIdentifier(INVALID_MOUNT_POINT_IDENT, schemaContext, Optional.of(mountPointService));
+        this.thrown.expect(IllegalArgumentException.class);
+        ParserIdentifier.toInstanceIdentifier(INVALID_MOUNT_POINT_IDENT, this.schemaContext, Optional.of(this.mountPointService));
     }
 
     /**
@@ -232,7 +234,7 @@ public class ParserIdentifierTest {
     public void toInstanceIdentifierMissingMountPointNegativeTest() {
         try {
             ParserIdentifier.toInstanceIdentifier(
-                    "" + "/" + RestconfConstants.MOUNT, schemaContext, Optional.of(mountPointService));
+                    "" + "/" + RestconfConstants.MOUNT, this.schemaContext, Optional.of(this.mountPointService));
             fail("Test should fail due to missing mount point");
         } catch (final RestconfDocumentedException e) {
             assertEquals("Not expected error type",
@@ -252,7 +254,7 @@ public class ParserIdentifierTest {
     @Test
     public void toInstanceIdentifierMissingMountPointServiceNegativeTest() {
         try {
-            ParserIdentifier.toInstanceIdentifier(RestconfConstants.MOUNT, schemaContext, Optional.absent());
+            ParserIdentifier.toInstanceIdentifier(RestconfConstants.MOUNT, this.schemaContext, Optional.absent());
             fail("Test should fail due to absent mount point service");
         } catch (final RestconfDocumentedException e) {
             assertEquals("Not expected error type",
@@ -399,7 +401,7 @@ public class ParserIdentifierTest {
      */
     @Test
     public void makeQNameFromIdentifierNullIdentifierNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.makeQNameFromIdentifier(null);
     }
 
@@ -455,7 +457,7 @@ public class ParserIdentifierTest {
     @Test
     public void toSchemaExportContextFromIdentifierTest() {
         final SchemaExportContext exportContext = ParserIdentifier.
-                toSchemaExportContextFromIdentifier(schemaContext, TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION, null);
+                toSchemaExportContextFromIdentifier(this.schemaContext, TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION, null);
 
         assertNotNull("Export context should be parsed", exportContext);
 
@@ -477,7 +479,7 @@ public class ParserIdentifierTest {
     @Test
     public void toSchemaExportContextFromIdentifierNotFoundTest() {
         final SchemaExportContext exportContext = ParserIdentifier.toSchemaExportContextFromIdentifier(
-                schemaContext,
+                this.schemaContext,
                 "not-existing-module" + "/" + "2016-01-01",
                 null);
 
@@ -494,7 +496,7 @@ public class ParserIdentifierTest {
     public void toSchemaExportContextFromIdentifierInvalidIdentifierNegativeTest() {
         try {
             ParserIdentifier.toSchemaExportContextFromIdentifier(
-                    schemaContext, TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME, null);
+                    this.schemaContext, TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME, null);
             fail("Test should fail due to invalid identifier supplied");
         } catch (final RestconfDocumentedException e) {
             assertEquals("Not expected error type",
@@ -513,9 +515,9 @@ public class ParserIdentifierTest {
     @Test
     public void toSchemaExportContextFromIdentifierMountPointTest() {
         final SchemaExportContext exportContext = ParserIdentifier.toSchemaExportContextFromIdentifier(
-                schemaContext,
+                this.schemaContext,
                 MOUNT_POINT_IDENT + "/" + TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION,
-                mountPointService);
+                this.mountPointService);
 
         final Module module = exportContext.getModule();
         assertNotNull("Export context should contains test module", module);
@@ -535,9 +537,9 @@ public class ParserIdentifierTest {
     @Test
     public void toSchemaExportContextFromIdentifierMountPointNotFoundTest() {
         final SchemaExportContext exportContext = ParserIdentifier.toSchemaExportContextFromIdentifier(
-                schemaContext,
+                this.schemaContext,
                 MOUNT_POINT_IDENT + "/" + "not-existing-module" + "/" + "2016-01-01",
-                mountPointService);
+                this.mountPointService);
 
         assertNotNull("Export context should be parsed", exportContext);
         assertNull("Not-existing module should be null", exportContext.getModule());
@@ -552,9 +554,9 @@ public class ParserIdentifierTest {
     public void toSchemaExportContextFromIdentifierMountPointInvalidIdentifierNegativeTest() {
         try {
             ParserIdentifier.toSchemaExportContextFromIdentifier(
-                    schemaContext,
+                    this.schemaContext,
                     MOUNT_POINT_IDENT + "/" + TEST_MODULE_REVISION + "/" + TEST_MODULE_NAME,
-                    mountPointService);
+                    this.mountPointService);
 
             fail("Test should fail due to invalid identifier supplied");
         } catch (final RestconfDocumentedException e) {
@@ -573,8 +575,8 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toSchemaExportContextFromIdentifierNullIdentifierNegativeTest() {
-        thrown.expect(NullPointerException.class);
-        ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContext, null, null);
+        this.thrown.expect(NullPointerException.class);
+        ParserIdentifier.toSchemaExportContextFromIdentifier(this.schemaContext, null, null);
     }
 
     /**
@@ -583,7 +585,7 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toSchemaExportContextFromIdentifierNullSchemaContextNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.toSchemaExportContextFromIdentifier(null, TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION, null);
     }
 
@@ -594,7 +596,7 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toSchemaExportContextFromIdentifierMountPointNullSchemaContextNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.toSchemaExportContextFromIdentifier(
                 null,
                 MOUNT_POINT_IDENT
@@ -602,7 +604,7 @@ public class ParserIdentifierTest {
                 + TEST_MODULE_NAME
                 + "/"
                 + TEST_MODULE_REVISION,
-                mountPointService);
+                this.mountPointService);
     }
 
     /**
@@ -612,9 +614,9 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toSchemaExportContextFromIdentifierNullMountPointServiceNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.toSchemaExportContextFromIdentifier(
-                schemaContext,
+                this.schemaContext,
                 MOUNT_POINT_IDENT
                 + "/"
                 + TEST_MODULE_NAME
@@ -629,15 +631,15 @@ public class ParserIdentifierTest {
      */
     @Test
     public void toSchemaExportContextFromIdentifierNullSchemaContextBehindMountPointNegativeTest() {
-        thrown.expect(NullPointerException.class);
+        this.thrown.expect(NullPointerException.class);
         ParserIdentifier.toSchemaExportContextFromIdentifier(
-                schemaContext,
+                this.schemaContext,
                 "/"
                 + RestconfConstants.MOUNT
                 + "/"
                 + TEST_MODULE_NAME
                 + "/"
                 + TEST_MODULE_REVISION,
-                mockMountPointService);
+                this.mockMountPointService);
     }
 }
index 838b84a9c7d9b352c1e168b33455a939af4c3e4e..d36a7d6ab95c0742138c1f067c76377df73244b5 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-parser-api</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-parser-impl</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-test-util</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>org.osgi</groupId>
index 9295afb1063367581b48ac10b0f2b21832e9af6c..3adc8569837f3638c5a97cb422899d44d6000daa 100644 (file)
@@ -17,9 +17,11 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.List;
 import java.util.Set;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
@@ -30,10 +32,7 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class DocGenTestHelper {
 
@@ -42,8 +41,7 @@ public class DocGenTestHelper {
     private SchemaContext schemaContext;
 
     public Set<Module> loadModules(final String resourceDirectory)
-            throws FileNotFoundException,
-            URISyntaxException, ReactorException {
+            throws URISyntaxException, FileNotFoundException, ReactorException {
 
         final URI resourceDirUri = getClass().getResource(resourceDirectory).toURI();
         final File testDir = new File(resourceDirUri);
@@ -51,13 +49,12 @@ public class DocGenTestHelper {
         if (fileList == null) {
             throw new FileNotFoundException(resourceDirectory.toString());
         }
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final List<File> files = new ArrayList<>();
         for (final String fileName : fileList) {
-            final File file = new File(testDir, fileName);
-            reactor.addSource(new YangStatementSourceImpl(new NamedFileInputStream(file, file.getPath())));
+            files.add(new File(testDir, fileName));
         }
 
-        this.schemaContext = reactor.buildEffective();
+        this.schemaContext = YangParserTestUtils.parseYangSources(files);
         return this.schemaContext.getModules();
     }