X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-maven-plugin-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang2sources%2Fplugin%2Fit%2FYangToSourcesPluginTestIT.java;h=5015100ca26817fe33e1cf6a79a2be7b58d504e6;hb=refs%2Fheads%2Fstable%2Fberyllium;hp=381274a098c72740672a40ece39870d42439c393;hpb=393bf3e76fdfb545bb74047d23839dc619f347dd;p=yangtools.git diff --git a/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java b/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java index 381274a098..5015100ca2 100644 --- a/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java +++ b/yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java @@ -10,9 +10,7 @@ package org.opendaylight.yangtools.yang2sources.plugin.it; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; - import com.google.common.base.Joiner; - import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -21,29 +19,28 @@ import java.net.URL; import java.util.Arrays; import java.util.List; import java.util.Properties; - import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; +import org.junit.BeforeClass; import org.junit.Test; public class YangToSourcesPluginTestIT { + private static String GLOBAL_SETTINGS_OVERRIDE; + private static String USER_SETTINGS_OVERRIDE; + + @BeforeClass + public static void setupClass() { + // OpenDaylight Jenkins does not have settings at the default path, pick file locations from environment + GLOBAL_SETTINGS_OVERRIDE = System.getenv("GLOBAL_SETTINGS_FILE"); + USER_SETTINGS_OVERRIDE = System.getenv("SETTINGS_FILE"); + } // TODO Test yang files in transitive dependencies @Test - public void testYangRootNotExist() throws URISyntaxException { - try { - setUp("test-parent/YangRootNotExist/", false); - } catch (VerificationException e) { - assertVerificationException(e, - "[ERROR] yang-to-sources: Unable to parse yang files from "); - assertVerificationException( - e, - "Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from "); - return; - } - - fail("Verification exception should have been thrown"); + public void testYangRootNotExist() throws Exception { + Verifier v = setUp("test-parent/YangRootNotExist/", false); + v.verifyTextInLog("[WARNING] yang-to-sources: YANG source directory"); } @Test @@ -73,28 +70,14 @@ public class YangToSourcesPluginTestIT { } catch (VerificationException e) { assertVerificationException( e, - "org.opendaylight.yangtools.yang.parser.util.YangValidationException: Not existing module imported:unknownDep:2013-02-27 by:private:2013-02-27"); + "org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Imported module " + + "[ModuleIdentifierImpl{name='unknownDep', namespace=null, revision=2013-02-27}"); return; } fail("Verification exception should have been thrown"); } - @Test - public void testNamingConflict() throws Exception { - Verifier v = setUp("test-parent/NamingConflict/", false); - v.verifyErrorFreeLog(); - String baseDir = v.getBasedir(); - String fileName = v.getLogFileName(); - List lines = v.loadFile(baseDir, fileName, false); - for (String s : lines) { - if (s.contains("conflict")) { - System.err.println(s); - } - } - v.verifyTextInLog("[WARNING] Naming conflict for type 'org.opendaylight.yang.gen.v1.urn.yang.test.rev140303.NetworkTopologyRef': file with same name already exists and will not be generated."); - } - static void verifyCorrectLog(final Verifier v) throws VerificationException { v.verifyErrorFreeLog(); v.verifyTextInLog("[INFO] yang-to-sources: YANG files parsed from"); @@ -146,6 +129,14 @@ public class YangToSourcesPluginTestIT { if (ignoreF) { verifier.addCliOption("-fn"); } + if (GLOBAL_SETTINGS_OVERRIDE != null) { + verifier.addCliOption("-gs"); + verifier.addCliOption(GLOBAL_SETTINGS_OVERRIDE); + } + if (USER_SETTINGS_OVERRIDE != null) { + verifier.addCliOption("-s"); + verifier.addCliOption(USER_SETTINGS_OVERRIDE); + } verifier.setMavenDebug(true); verifier.executeGoal("generate-sources"); return verifier; @@ -159,8 +150,7 @@ public class YangToSourcesPluginTestIT { @Test public void testFindResourceOnCp() throws Exception { - Verifier v1 = new Verifier(new File(getClass().getResource( - "/test-parent/GenerateTest1/pom.xml").toURI()).getParent()); + Verifier v1 = setUp("test-parent/GenerateTest1/", false); v1.executeGoal("clean"); v1.executeGoal("package"); @@ -174,8 +164,7 @@ public class YangToSourcesPluginTestIT { v1.assertFilePresent(buildDir + "/classes/META-INF/yang/testfile2.yang"); v1.assertFilePresent(buildDir + "/classes/META-INF/yang/testfile3.yang"); - Verifier v2 = new Verifier(new File(getClass().getResource( - "/test-parent/GenerateTest2/pom.xml").toURI()).getParent()); + Verifier v2 = setUp("test-parent/GenerateTest2/", false); v2.executeGoal("clean"); v2.executeGoal("package");