Cleanup mdsal-binding-java-api-generator tests 98/69598/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 19 Mar 2018 01:13:58 +0000 (02:13 +0100)
committerJie Han <han.jie@zte.com.cn>
Mon, 19 Mar 2018 10:34:49 +0000 (10:34 +0000)
We have a lot of copy&pasted code here, trim it down by providing
convenience classes.

Change-Id: Ic1e63569f10b6eb38e058f64bf49bc9d09ca8762
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 files changed:
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/AugmentToUsesInAugmentCompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/Bug1276Test.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/Bug5151Test.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/Bug532Test.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/CascadeUsesCompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/CompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/CompilationTestUtils.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/EncodingInJavaDocTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/NestedGroupingCompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/TypedefCompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/UnionTypedefUnusedImportTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/UnionWithIdentityrefTest.java

index ab6f8b1b08acfb4c4c063b8c6245570d3f17dcb5..1e569c35e595b2483caa5b9da3cdd7dfc187252a 100644 (file)
@@ -26,11 +26,8 @@ public class AugmentToUsesInAugmentCompilationTest extends BaseCompilationTest {
 
     @Test
     public void testAugmentToUsesInAugment() throws IOException, URISyntaxException {
-        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(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "augment-uses-to-augment");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("augment-uses-to-augment");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("augment-uses-to-augment");
         final List<File> sourceFiles = CompilationTestUtils.getSourceFiles("/compilation/augment-uses-to-augment");
         final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
index 01d16e9552880ccfa155bd834b360490ed16c301..cf649baf3344f6834e7b1f1effcfed2689f2ef35 100644 (file)
@@ -51,11 +51,8 @@ public class Bug1276Test extends BaseCompilationTest {
 
     @Test
     public void test() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug1276");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug1276");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug1276");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug1276");
         generateTestSources("/compilation/bug1276", sourcesOutputDir);
 
         // Test if sources are compilable
index 328be8ef9318ea065a8e054cae6b894e128da2ea..b07e6bc76744b3ca0841d9861780d3aa900cdeb2 100644 (file)
@@ -35,11 +35,8 @@ public class Bug5151Test extends BaseCompilationTest {
 
     @Test
     public void test() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + BUG_ID);
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + BUG_ID);
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput(BUG_ID);
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput(BUG_ID);
         generateTestSources(CompilationTestUtils.FS + "compilation" + CompilationTestUtils.FS + BUG_ID, sourcesOutputDir);
 
         // Test if sources are compilable
index 008dec23300c605723453b2f49e46c9ce914f8ba..9843a83ad0daa176f3e012339ddc253ff78edaac 100644 (file)
@@ -9,11 +9,7 @@ package org.opendaylight.mdsal.binding.java.api.generator.test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.BASE_PKG;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.FS;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.cleanUp;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.getSourceFiles;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.testCompilation;
@@ -41,11 +37,8 @@ public class Bug532Test extends BaseCompilationTest {
 
     @Test
     public void test() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug532");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug532");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug532");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug532");
         generateTestSources("/compilation/list-gen-test", sourcesOutputDir);
 
         // Test if sources are compilable
index d164574bff90a82d461ce6ed0f5439f212a31ea8..7a59f33c2333ad5e210b92d54b890fe5a2af4dca 100644 (file)
@@ -12,9 +12,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.BASE_PKG;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.FS;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.NS_BAR;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.NS_BAZ;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.NS_FOO;
@@ -41,11 +38,8 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
 
     @Test
     public void testCascadeUsesCompilation() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "cascade-uses");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "cascade-uses");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("cascade-uses");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("cascade-uses");
         final List<File> sourceFiles = getSourceFiles("/compilation/cascade-uses");
         final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
index 734892f1e0e6619d80c70f6eb92d04474cc8350c..be375a3dc41c0b30d22a6f9e0082b8c00ff74986 100644 (file)
@@ -58,11 +58,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testListGeneration() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "list-gen");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "list-gen");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("list-gen");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("list-gen");
         generateTestSources("/compilation/list-gen", sourcesOutputDir);
 
         // Test if all sources are generated
@@ -128,11 +125,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testAugmentUnderUsesGeneration() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "augment-under-uses");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "augment-under-uses");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("augment-under-uses");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("augment-under-uses");
         generateTestSources("/compilation/augment-under-uses", sourcesOutputDir);
 
         // Test if all sources were generated from 'module foo'
@@ -233,11 +227,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testAugmentOfAugmentGeneration() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "aug-of-aug");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "aug-of-aug");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("aug-of-aug");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("aug-of-aug");
         generateTestSources("/compilation/augment-of-augment", sourcesOutputDir);
 
         // Test if all sources were generated from 'module foo'
@@ -373,11 +364,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testLeafReturnTypes() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "leaf-return-types");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "leaf-return-types");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("leaf-return-types");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("leaf-return-types");
         generateTestSources("/compilation/leaf-return-types", sourcesOutputDir);
 
         final File parent = new File(sourcesOutputDir, CompilationTestUtils.NS_TEST);
@@ -439,11 +427,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testGenerationContextReferenceExtension() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "context-reference");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "context-reference");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("context-reference");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("context-reference");
         generateTestSources("/compilation/context-reference", sourcesOutputDir);
 
         // Test if all sources are generated
@@ -490,11 +475,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void compilationTest() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "yang");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "yang");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("yang");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("yang");
         generateTestSources("/yang", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -505,11 +487,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testBug586() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug586");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug586");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug586");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug586");
         generateTestSources("/compilation/bug586", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -520,11 +499,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testBug4760() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug4760");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug4760");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug4760");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug4760");
         generateTestSources("/compilation/bug4760", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -540,11 +516,8 @@ public class CompilationTest extends BaseCompilationTest {
      */
     @Test
     public void testBug1172() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug1172");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug1172");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug1172");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug1172");
         generateTestSources("/compilation/bug1172", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -555,11 +528,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testBug5461() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug5461");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug5461");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug5461");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug5461");
         generateTestSources("/compilation/bug5461", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -570,10 +540,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void testBug5882() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug5882");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug5882");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug5882");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug5882");
         generateTestSources("/compilation/bug5882", sourcesOutputDir);
 
         // Test if sources are compilable
@@ -630,10 +598,8 @@ public class CompilationTest extends BaseCompilationTest {
      */
     @Test
     public void testBug1377() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug1377");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug1377");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("bug1377");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("bug1377");
 
         generateTestSources("/compilation/bug1377", sourcesOutputDir);
 
@@ -654,11 +620,8 @@ public class CompilationTest extends BaseCompilationTest {
 
     @Test
     public void classNamesColisionTest() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "class-name-collision");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "class-name-collision");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("class-name-collision");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("class-name-collision");
         generateTestSources("/compilation/class-name-collision", sourcesOutputDir);
         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
index 5765caa9832a7ae9dac65bc42dc4aa6be530e03e..0aebe8e90b47a6ebe2a7c7ea401fbba83749c5af 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.mdsal.binding.java.api.generator.test;
 
+import static com.google.common.base.Preconditions.checkState;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -40,7 +41,7 @@ public class CompilationTestUtils {
 
     static final String GENERATOR_OUTPUT_PATH = TEST_PATH + FS + "src";
     static final File GENERATOR_OUTPUT_DIR = new File(GENERATOR_OUTPUT_PATH);
-    static final String COMPILER_OUTPUT_PATH = TEST_PATH + FS + "bin";
+    private static final String COMPILER_OUTPUT_PATH = TEST_PATH + FS + "bin";
     static final File COMPILER_OUTPUT_DIR = new File(COMPILER_OUTPUT_PATH);
 
     static final String AUGMENTATION = "interface org.opendaylight.yangtools.yang.binding.Augmentation";
@@ -51,6 +52,20 @@ public class CompilationTestUtils {
     static final String NS_BAZ = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "baz" + FS + "rev131008";
     static final String NS_BUG5882 = BASE_PATH + FS + "urn" + FS + "yang" + FS + "foo" + FS + "rev160102";
 
+    static File compilerOutput(final String name) {
+        return createDirectory(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + name);
+    }
+
+    static File generatorOutput(final String name) {
+        return createDirectory(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + name);
+    }
+
+    private static File createDirectory(final String path) {
+        final File ret = new File(path);
+        checkState(ret.mkdir(), "Failed to create test directory %s", path);
+        return ret;
+    }
+
     /**
      * Method to clean resources. It is manually called at the end of each test
      * instead of marking it with @After annotation to prevent removing
index 2e6369baab4b972c9fa437943c18a6f7aa6b91a8..a8a71c121891c59ee33b899ad6108f0adf3aeef9 100644 (file)
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.mdsal.binding.java.api.generator.test;
 
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.FS;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.cleanUp;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.getSourceFiles;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.testCompilation;
@@ -32,11 +28,8 @@ public class EncodingInJavaDocTest extends BaseCompilationTest {
 
     @Test
     public void testAugmentToUsesInAugment() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "encoding-javadoc");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "encoding-javadoc");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("encoding-javadoc");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("encoding-javadoc");
         final List<File> sourceFiles = getSourceFiles("/compilation/encoding-javadoc");
         final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
index 8b3c82c543a69bc4758775fa30279873cbd8d9ee..dfe572e05cd4c60b146331325705e8b82f9ce997 100644 (file)
@@ -9,9 +9,6 @@ package org.opendaylight.mdsal.binding.java.api.generator.test;
 
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.BASE_PKG;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.FS;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.NS_TEST;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.assertFilesCount;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.assertImplementsIfc;
@@ -40,11 +37,8 @@ public class NestedGroupingCompilationTest extends BaseCompilationTest {
 
     @Test
     public void testListGeneration() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "nested-grouping");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "nested-grouping");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("nested-grouping");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("nested-grouping");
         generateTestSources("/compilation/nested-grouping", sourcesOutputDir);
 
         // Test if all sources are generated
index faefe0627bb7610971712770e94f6863d72f4776..8a646f113180d55ca155a9cc1ab084290b9f3b15 100644 (file)
@@ -39,11 +39,8 @@ public class TypedefCompilationTest extends BaseCompilationTest {
 
     @Test
     public void test() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "typedef");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "typedef");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("typedef");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("typedef");
         final List<File> sourceFiles = CompilationTestUtils.getSourceFiles("/compilation/typedef");
         final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
index cfa2e7a1a8646183ed37382b6766726599114edc..7961c7e46cf23eeb427efd6596ede367d7618861 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.mdsal.binding.java.api.generator.test;
 
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.FS;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
 import static org.opendaylight.mdsal.binding.java.api.generator.test.CompilationTestUtils.cleanUp;
@@ -35,11 +33,8 @@ public class UnionTypedefUnusedImportTest extends BaseCompilationTest {
 
     @Test
     public void testUnionTypedefUnusedImport() throws Exception {
-        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "union-typedef");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "union-typedef");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("union-typedef");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("union-typedef");
         final List<File> sourceFiles = getSourceFiles("/compilation/union-typedef");
         final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
         final List<Type> types = bindingGenerator.generateTypes(context);
index a8478097d36a12e50677dc952795177d4073ac82..eb4e0104299455a6d89f0f9629dfdbf173febf01 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.java.api.generator.test;
 import static org.junit.Assert.assertArrayEquals;
 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 java.io.File;
@@ -35,11 +34,8 @@ public class UnionWithIdentityrefTest extends BaseCompilationTest {
 
     @Test
     public void test() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "union-with-identityref");
-        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "union-with-identityref");
-        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("union-with-identityref");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("union-with-identityref");
         generateTestSources("/compilation/union-with-identityref", sourcesOutputDir);
 
         // Test if sources are compilable