Removed usage of deprecated YangParserImpl from tests in mdsal project
[mdsal.git] / binding / mdsal-binding-generator-util / src / test / java / org / opendaylight / yangtools / binding / generator / util / BindingGeneratorUtilTest.java
index 928958966c8af55c717abc42499bacb69a59db27..5a3581b0e7f319d621f0bbd1024aaa4f738cd6ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -13,7 +13,12 @@ import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
 import com.google.common.base.Optional;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
@@ -22,6 +27,7 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -42,7 +48,6 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
 import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
 import org.opendaylight.yangtools.yang.model.util.Decimal64;
@@ -52,14 +57,13 @@ import org.opendaylight.yangtools.yang.model.util.Int16;
 import org.opendaylight.yangtools.yang.model.util.StringType;
 import org.opendaylight.yangtools.yang.model.util.Uint16;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class BindingGeneratorUtilTest {
 
     @Rule
     public ExpectedException expectedEx = ExpectedException.none();
 
-    private static List<File> loadTestResources(final String testFile) {
+    private static List<File> loadTestResources(String testFile) {
         final List<File> testModels = new ArrayList<File>();
         File listModelFile;
         try {
@@ -73,20 +77,22 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Tests methods:
-     * <ul>
-     * <li>moduleNamespaceToPackageName</li> - with revision
-     * <li>packageNameForGeneratedType</li>
-     * <ul>
-     * <li>validateJavaPackage</li>
-     * </ul>
-     * <li>packageNameForTypeDefinition</li> <li>moduleNamespaceToPackageName</li>
-     * - without revision </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;moduleNamespaceToPackageName&lt;/li&gt; - with revision
+     * &lt;li&gt;packageNameForGeneratedType&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;validateJavaPackage&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;li&gt;packageNameForTypeDefinition&lt;/li&gt; &lt;li&gt;moduleNamespaceToPackageName&lt;/li&gt;
+     * - without revision &lt;/ul&gt;
+     * @throws ReactorException Reactor exception
+     * @throws SourceException Source exception
      */
     @Test
-    public void testBindingGeneratorUtilMethods() throws IOException {
+    public void testBindingGeneratorUtilMethods() throws IOException, SourceException, ReactorException {
         List<File> testModels = loadTestResources("/module.yang");
-        final YangContextParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseFiles(testModels).getModules();
+
+        final Set<Module> modules = RetestUtils.parseYangSources(testModels).getModules();
         String packageName = "";
         Module module = null;
         for (Module m : modules) {
@@ -165,10 +171,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
-     * packageNameForTypeDefinition()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+     * packageNameForTypeDefinition(String, TypeDefinition)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     @Deprecated
@@ -180,10 +186,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForTypeDefinition()
-     * packageNameForTypeDefinition()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForTypeDefinition(String, TypeDefinition)
+     * packageNameForTypeDefinition(String, TypeDefinition)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     @Deprecated
@@ -195,10 +201,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
-     * packageNameForGeneratedType()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+     * packageNameForGeneratedType(String, SchemaPath)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testPackageNameForGeneratedTypeNullBasePackageName() {
@@ -208,10 +214,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#packageNameForGeneratedType()
-     * packageNameForGeneratedType()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#packageNameForGeneratedType(String, SchemaPath)
+     * packageNameForGeneratedType(String, SchemaPath)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testPackageNameForGeneratedTypeNullSchemaPath() {
@@ -221,10 +227,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#parseToClassName()
-     * parseToClassName()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#parseToClassName(String)
+     * parseToClassName(String)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testParseToClassNameNullValue() {
@@ -238,10 +244,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#parseToClassName()
-     * parseToClassName()}</li>
-     * </ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#parseToClassName(String)
+     * parseToClassName(String)}&lt;/li&gt;
+     * &lt;/ul&gt;
      */
     @Test
     public void testParseToClassNameEmptyValue() {
@@ -255,10 +261,10 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Test for the method
-     * <ul>
-     * <li>{@link BindingGeneratorUtil#validateParameterName()
-     * validateParameterName()}</li>
-     * <ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;{@link BindingGeneratorUtil#resolveJavaReservedWordEquivalency(String)
+     * resolveJavaReservedWordEquivalency(String)}&lt;/li&gt;
+     * &lt;ul&gt;
      */
     @Test
     public void testValidateParameterName() {
@@ -271,21 +277,21 @@ public class BindingGeneratorUtilTest {
 
     /**
      * Tests the methods:
-     * <ul>
-     * <li>parseToClassName</li>
-     * <ul>
-     * <li>parseToCamelCase</li>
-     * <ul>
-     * <li>replaceWithCamelCase</li>
-     * </ul>
-     * </ul> <li>parseToValidParamName</li>
-     * <ul>
-     * <li>parseToCamelCase</li>
-     * <ul>
-     * <li>replaceWithCamelCase</li>
-     * </ul>
-     * </ul>
-     * <ul>
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToClassName&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToCamelCase&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;replaceWithCamelCase&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;/ul&gt; &lt;li&gt;parseToValidParamName&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;parseToCamelCase&lt;/li&gt;
+     * &lt;ul&gt;
+     * &lt;li&gt;replaceWithCamelCase&lt;/li&gt;
+     * &lt;/ul&gt;
+     * &lt;/ul&gt;
+     * &lt;ul&gt;
      */
     @Test
     public void testParsingMethods() {