Removed usage of deprecated YangParserImpl from tests in mdsal project
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / yangtools / sal / java / api / generator / test / AugmentToUsesInAugmentCompilationTest.java
index 41521a73e750915186866f0e173d96a80b5354fa..9797c4240729f5ba8b00446344e278951d7dc93a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 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,
@@ -8,19 +8,7 @@
 package org.opendaylight.yangtools.sal.java.api.generator.test;
 
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.BASE_PKG;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.FS;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAR;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAZ;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_FOO;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertFilesCount;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertImplementsIfc;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testAugmentation;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
+
 import com.google.common.collect.ImmutableSet;
 import java.io.File;
 import java.net.URL;
@@ -35,27 +23,27 @@ public class AugmentToUsesInAugmentCompilationTest extends BaseCompilationTest {
 
     @Test
     public void testAugmentToUsesInAugment() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "augment-uses-to-augment");
+        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "augment-uses-to-augment");
         assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "augment-uses-to-augment");
+        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "augment-uses-to-augment");
         assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
 
-        final List<File> sourceFiles = getSourceFiles("/compilation/augment-uses-to-augment");
-        final SchemaContext context = parser.parseFiles(sourceFiles);
+        final List<File> sourceFiles = CompilationTestUtils.getSourceFiles("/compilation/augment-uses-to-augment");
+        final SchemaContext context = RetestUtils.parseYangSources(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
         final GeneratorJavaFile generator = new GeneratorJavaFile(ImmutableSet.copyOf(types));
         generator.generateToFile(sourcesOutputDir);
 
         // Test if all sources are generated from 'module foo'
-        File fooParent = new File(sourcesOutputDir, NS_FOO);
-        assertFilesCount(fooParent, 4);
+        File fooParent = new File(sourcesOutputDir, CompilationTestUtils.NS_FOO);
+        CompilationTestUtils.assertFilesCount(fooParent, 4);
         assertTrue(new File(fooParent, "IgpLinkAttributes.java").exists());
         assertTrue(new File(fooParent, "Link1.java").exists());
         assertTrue(new File(fooParent, "Link1Builder.java").exists());
 
         // Test if all sources are generated from 'module bar'
-        File barParent = new File(sourcesOutputDir, NS_BAR);
-        assertFilesCount(barParent, 7);
+        File barParent = new File(sourcesOutputDir, CompilationTestUtils.NS_BAR);
+        CompilationTestUtils.assertFilesCount(barParent, 7);
         assertTrue(new File(barParent, "BarData.java").exists());
         assertTrue(new File(barParent, "NetworkTopology.java").exists());
         assertTrue(new File(barParent, "NetworkTopologyBuilder.java").exists());
@@ -63,57 +51,57 @@ public class AugmentToUsesInAugmentCompilationTest extends BaseCompilationTest {
         assertTrue(new File(barParent, "LinkAttributes.java").exists());
 
         File networkParent = new File(barParent, "network");
-        assertFilesCount(networkParent, 1);
+        CompilationTestUtils.assertFilesCount(networkParent, 1);
         File topologyParent = new File(networkParent, "topology");
-        assertFilesCount(topologyParent, 3);
+        CompilationTestUtils.assertFilesCount(topologyParent, 3);
         assertTrue(new File(topologyParent, "Topology.java").exists());
         assertTrue(new File(topologyParent, "TopologyBuilder.java").exists());
         assertTrue(new File(topologyParent, "TopologyKey.java").exists());
 
         File linkParent = new File(barParent, "link");
-        assertFilesCount(linkParent, 3);
+        CompilationTestUtils.assertFilesCount(linkParent, 3);
         assertTrue(new File(linkParent, "Link.java").exists());
         assertTrue(new File(linkParent, "LinkBuilder.java").exists());
         assertTrue(new File(linkParent, "LinkKey.java").exists());
 
         // Test if all sources are generated from 'module baz'
-        File bazParent = new File(sourcesOutputDir, NS_BAZ);
-        assertFilesCount(bazParent, 4);
+        File bazParent = new File(sourcesOutputDir, CompilationTestUtils.NS_BAZ);
+        CompilationTestUtils.assertFilesCount(bazParent, 4);
         assertTrue(new File(bazParent, "IgpLinkAttributes1.java").exists());
         assertTrue(new File(bazParent, "IgpLinkAttributes1Builder.java").exists());
         assertTrue(new File(bazParent, "LinkAttributes.java").exists());
 
         // Test if sources are compilable
-        testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
 
         ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
 
         try {
-            Class<?> link1Class = Class.forName(BASE_PKG + ".urn.opendaylight.foo.rev131008.Link1", true, loader);
-            String augmentableNode = BASE_PKG + ".urn.opendaylight.bar.rev131008.link.Link";
-            testAugmentation(link1Class, augmentableNode);
+            Class<?> link1Class = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.foo.rev131008.Link1", true, loader);
+            String augmentableNode = CompilationTestUtils.BASE_PKG + ".urn.opendaylight.bar.rev131008.link.Link";
+            CompilationTestUtils.testAugmentation(link1Class, augmentableNode);
 
-            Class<?> igpLinkAttributesClass = Class.forName(BASE_PKG
+            Class<?> igpLinkAttributesClass = Class.forName(CompilationTestUtils.BASE_PKG
                     + ".urn.opendaylight.foo.rev131008.IgpLinkAttributes", true, loader);
-            assertImplementsIfc(link1Class, igpLinkAttributesClass);
+            CompilationTestUtils.assertImplementsIfc(link1Class, igpLinkAttributesClass);
         } catch (ClassNotFoundException e) {
             throw new AssertionError("Class for augment wasn't generated");
         }
 
         try {
-            Class<?> igpLinkAttributes1Class = Class.forName(BASE_PKG
+            Class<?> igpLinkAttributes1Class = Class.forName(CompilationTestUtils.BASE_PKG
                     + ".urn.opendaylight.baz.rev131008.IgpLinkAttributes1", true, loader);
-            String augmentableNode = BASE_PKG + ".urn.opendaylight.foo.rev131008.igp.link.attributes.IgpLinkAttributes";
-            testAugmentation(igpLinkAttributes1Class, augmentableNode);
+            String augmentableNode = CompilationTestUtils.BASE_PKG + ".urn.opendaylight.foo.rev131008.igp.link.attributes.IgpLinkAttributes";
+            CompilationTestUtils.testAugmentation(igpLinkAttributes1Class, augmentableNode);
 
-            Class<?> linkAttributesClass = Class.forName(BASE_PKG + ".urn.opendaylight.baz.rev131008.LinkAttributes",
+            Class<?> linkAttributesClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.baz.rev131008.LinkAttributes",
                     true, loader);
-            assertImplementsIfc(igpLinkAttributes1Class, linkAttributesClass);
+            CompilationTestUtils.assertImplementsIfc(igpLinkAttributes1Class, linkAttributesClass);
         } catch (ClassNotFoundException e) {
             throw new AssertionError("Class for augment wasn't generated");
         }
 
-        cleanUp(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
 }