You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2017/05/26 07:36:36 UTC
[03/11] ant-ivy git commit: Convert tests to JUnit 4, clean up code
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java b/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
index f7d61ab..cdefcea 100644
--- a/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
+++ b/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
@@ -28,27 +28,34 @@ import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-public class LatestConflictManagerTest extends TestCase {
+public class LatestConflictManagerTest {
private Ivy ivy;
private File _cache;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest.xml"));
_cache = new File("build/cache");
_cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
FileUtil.forceDelete(_cache);
}
// Test case for issue IVY-388
+ @Test
public void testIvy388() throws Exception {
ResolveReport report = ivy.resolve(
LatestConflictManagerTest.class.getResource("ivy-388.xml"), getResolveOptions());
@@ -73,6 +80,7 @@ public class LatestConflictManagerTest extends TestCase {
}
// Test case for issue IVY-383
+ @Test
public void testIvy383() throws Exception {
ResolveReport report = ivy.resolve(
LatestConflictManagerTest.class.getResource("ivy-383.xml"), getResolveOptions());
@@ -89,6 +97,7 @@ public class LatestConflictManagerTest extends TestCase {
}
// Test case for issue IVY-407
+ @Test
public void testLatestTime1() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
@@ -116,6 +125,7 @@ public class LatestConflictManagerTest extends TestCase {
}
}
+ @Test
public void testLatestTime2() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
@@ -150,6 +160,7 @@ public class LatestConflictManagerTest extends TestCase {
* ok and publish D-1.0.0 5) E needs D-1.0.0 and A-1.0.0 (D before A in ivy file) retrieve
* failed to get C-1.0.2 from A (get apparently C-1.0.1 from D)
*/
+ @Test
public void testLatestTimeTransitivity() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class
@@ -203,6 +214,7 @@ public class LatestConflictManagerTest extends TestCase {
* MyCompany#C;1
* conflicting-dependency#dep;1
*/
+ @Test
public void testEvictedModules() throws Exception {
ivy.configure(LatestConflictManagerTest.class
.getResource("ivysettings-evicted.xml"));
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/conflict/RegexpConflictManagerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/conflict/RegexpConflictManagerTest.java b/test/java/org/apache/ivy/plugins/conflict/RegexpConflictManagerTest.java
index c97a6ad..3272bcf 100644
--- a/test/java/org/apache/ivy/plugins/conflict/RegexpConflictManagerTest.java
+++ b/test/java/org/apache/ivy/plugins/conflict/RegexpConflictManagerTest.java
@@ -22,25 +22,32 @@ import java.io.File;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-public class RegexpConflictManagerTest extends TestCase {
+public class RegexpConflictManagerTest {
private Ivy ivy;
private File _cache;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
ivy = new Ivy();
ivy.configure(RegexpConflictManagerTest.class.getResource("ivysettings-regexp-test.xml"));
_cache = new File("build/cache");
_cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
FileUtil.forceDelete(_cache);
}
+ @Test
public void testNoApiConflictResolve() throws Exception {
try {
ivy.resolve(RegexpConflictManagerTest.class.getResource("ivy-no-regexp-conflict.xml"),
@@ -50,6 +57,7 @@ public class RegexpConflictManagerTest extends TestCase {
}
}
+ @Test
public void testConflictResolve() throws Exception {
try {
ivy.resolve(RegexpConflictManagerTest.class.getResource("ivy-conflict.xml"),
@@ -60,14 +68,12 @@ public class RegexpConflictManagerTest extends TestCase {
// this is expected
assertTrue(
"bad exception message: " + e.getMessage(),
- e.getMessage().indexOf(
- "org1#mod1.2;2.0.0:2.0 (needed by [apache#resolve-noconflict;1.0])") != -1);
+ e.getMessage().contains("org1#mod1.2;2.0.0:2.0 (needed by [apache#resolve-noconflict;1.0])"));
assertTrue("bad exception message: " + e.getMessage(),
- e.getMessage().indexOf("conflicts with") != -1);
+ e.getMessage().contains("conflicts with"));
assertTrue(
"bad exception message: " + e.getMessage(),
- e.getMessage().indexOf(
- "org1#mod1.2;2.1.0:2.1 (needed by [apache#resolve-noconflict;1.0])") != -1);
+ e.getMessage().contains("org1#mod1.2;2.1.0:2.1 (needed by [apache#resolve-noconflict;1.0])"));
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/conflict/StrictConflictManagerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/conflict/StrictConflictManagerTest.java b/test/java/org/apache/ivy/plugins/conflict/StrictConflictManagerTest.java
index 259de1d..b9f9eee 100644
--- a/test/java/org/apache/ivy/plugins/conflict/StrictConflictManagerTest.java
+++ b/test/java/org/apache/ivy/plugins/conflict/StrictConflictManagerTest.java
@@ -22,40 +22,50 @@ import java.io.File;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-public class StrictConflictManagerTest extends TestCase {
+public class StrictConflictManagerTest {
private Ivy ivy;
private File cache;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
ivy = new Ivy();
ivy.configure(StrictConflictManagerTest.class.getResource("ivysettings-strict-test.xml"));
cache = new File("build/cache");
cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
FileUtil.forceDelete(cache);
}
+ @Test
public void testInitFromConf() throws Exception {
ConflictManager cm = ivy.getSettings().getDefaultConflictManager();
assertTrue(cm instanceof StrictConflictManager);
}
+ @Test
public void testNoConflictResolve() throws Exception {
ivy.resolve(StrictConflictManagerTest.class.getResource("ivy-noconflict.xml"),
getResolveOptions());
}
+ @Test
public void testNoConflictWithDynamicRevisionResolve() throws Exception {
ivy.resolve(StrictConflictManagerTest.class.getResource("ivy-noconflict-dynamic.xml"),
getResolveOptions());
}
+ @Test
public void testConflictResolve() throws Exception {
try {
ivy.resolve(StrictConflictManagerTest.class.getResource("ivy-conflict.xml"),
@@ -67,6 +77,7 @@ public class StrictConflictManagerTest extends TestCase {
}
}
+ @Test
public void testConflictWithDynamicRevisionResolve() throws Exception {
try {
ivy.resolve(StrictConflictManagerTest.class.getResource("ivy-conflict-dynamic.xml"),
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/latest/LatestRevisionStrategyTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/latest/LatestRevisionStrategyTest.java b/test/java/org/apache/ivy/plugins/latest/LatestRevisionStrategyTest.java
index 1b3408c..b2df0dd 100644
--- a/test/java/org/apache/ivy/plugins/latest/LatestRevisionStrategyTest.java
+++ b/test/java/org/apache/ivy/plugins/latest/LatestRevisionStrategyTest.java
@@ -17,15 +17,19 @@
*/
package org.apache.ivy.plugins.latest;
+import org.junit.Test;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-public class LatestRevisionStrategyTest extends TestCase {
+public class LatestRevisionStrategyTest {
+ @Test
public void testComparator() {
ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
"1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
@@ -37,6 +41,7 @@ public class LatestRevisionStrategyTest extends TestCase {
assertEquals(Arrays.asList(revs), shuffled);
}
+ @Test
public void testSort() {
ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
"1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
@@ -51,6 +56,7 @@ public class LatestRevisionStrategyTest extends TestCase {
assertEquals(Arrays.asList(revs), sorted);
}
+ @Test
public void testFindLatest() {
ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
"1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
@@ -66,6 +72,7 @@ public class LatestRevisionStrategyTest extends TestCase {
assertEquals("2.0", latest.getRevision());
}
+ @Test
public void testSpecialMeaningComparator() {
ArtifactInfo[] revs = toMockAI(new String[] {"0.1", "0.2-pre", "0.2-dev", "0.2-rc1",
"0.2-final", "0.2-QA", "1.0-dev1"});
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/lock/ArtifactLockStrategyTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/lock/ArtifactLockStrategyTest.java b/test/java/org/apache/ivy/plugins/lock/ArtifactLockStrategyTest.java
index 09fecb2..e886469 100644
--- a/test/java/org/apache/ivy/plugins/lock/ArtifactLockStrategyTest.java
+++ b/test/java/org/apache/ivy/plugins/lock/ArtifactLockStrategyTest.java
@@ -37,18 +37,25 @@ import org.apache.ivy.plugins.resolver.FileSystemResolver;
import org.apache.ivy.util.CopyProgressEvent;
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-public class ArtifactLockStrategyTest extends TestCase {
- protected void setUp() throws Exception {
+public class ArtifactLockStrategyTest {
+ @Before
+ public void setUp() {
FileUtil.forceDelete(new File("build/test/cache"));
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
FileUtil.forceDelete(new File("build/test/cache"));
}
+ @Test
public void testConcurrentResolve() throws Exception {
// we use different settings because Ivy do not support multi thread resolve with the same
// settings yet and this is not what this test is about: the focus of this test is running
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/matcher/AbstractPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/matcher/AbstractPatternMatcherTest.java b/test/java/org/apache/ivy/plugins/matcher/AbstractPatternMatcherTest.java
index b4157f4..14a0ca6 100644
--- a/test/java/org/apache/ivy/plugins/matcher/AbstractPatternMatcherTest.java
+++ b/test/java/org/apache/ivy/plugins/matcher/AbstractPatternMatcherTest.java
@@ -17,20 +17,23 @@
*/
package org.apache.ivy.plugins.matcher;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Base test classes for PatternMatcher testcase implementation
*/
-public abstract class AbstractPatternMatcherTest extends TestCase {
+public abstract class AbstractPatternMatcherTest {
protected PatternMatcher patternMatcher;
- protected abstract void setUp() throws Exception;
-
+ // used by setUp() in subclasses
protected void setUp(PatternMatcher matcher) {
this.patternMatcher = matcher;
}
+ @Test
public void testAnyExpression() {
Matcher matcher = patternMatcher.getMatcher("*");
assertTrue(matcher.matches(""));
@@ -38,6 +41,7 @@ public abstract class AbstractPatternMatcherTest extends TestCase {
assertTrue(matcher.matches(" "));
}
+ @Test
public void testIsExact() {
// '*' is a special matcher
Matcher matcher = patternMatcher.getMatcher("*");
@@ -69,27 +73,22 @@ public abstract class AbstractPatternMatcherTest extends TestCase {
protected abstract String[] getInexactExpressions();
+ @Test(expected = NullPointerException.class)
public void testNullInput() {
Matcher matcher = patternMatcher.getMatcher("some expression");
- try {
- matcher.matches(null);
- fail("Should fail for null input");
- } catch (NullPointerException expected) {
-
- }
+ matcher.matches(null);
+ fail("Should fail for null input");
}
+ @Test(expected = NullPointerException.class)
public void testNullExpression() {
- try {
- patternMatcher.getMatcher(null);
- fail("Should fail for null expression");
- } catch (NullPointerException expected) {
-
- }
+ patternMatcher.getMatcher(null);
+ fail("Should fail for null expression");
}
public abstract void testImplementation();
+ @Test
public void testLoadTestMatches() {
Matcher matcher = patternMatcher.getMatcher("this.is.an.expression");
String[] inputs = {"this.is.an.expression", "this:is:an:expression",
@@ -100,6 +99,7 @@ public abstract class AbstractPatternMatcherTest extends TestCase {
}
}
+ @Test
public void testLoadTestGetMatcher() {
String[] inputs = {"this.is.an.expression", "this:is:an:expression",
"this is an expression", "whatever this is", "maybe, maybe not"};
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/matcher/ExactOrRegexpPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/matcher/ExactOrRegexpPatternMatcherTest.java b/test/java/org/apache/ivy/plugins/matcher/ExactOrRegexpPatternMatcherTest.java
index b332e47..d1c924b 100644
--- a/test/java/org/apache/ivy/plugins/matcher/ExactOrRegexpPatternMatcherTest.java
+++ b/test/java/org/apache/ivy/plugins/matcher/ExactOrRegexpPatternMatcherTest.java
@@ -17,14 +17,22 @@
*/
package org.apache.ivy.plugins.matcher;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.regex.PatternSyntaxException;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
*
*/
public class ExactOrRegexpPatternMatcherTest extends AbstractPatternMatcherTest {
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
setUp(new ExactOrRegexpPatternMatcher());
}
@@ -36,6 +44,7 @@ public class ExactOrRegexpPatternMatcherTest extends AbstractPatternMatcherTest
return new String[] {"abc+", "12.3", "abc-123*", "abc_123\\d"};
}
+ @Test(expected = PatternSyntaxException.class)
public void testImplementation() {
Matcher matcher = patternMatcher.getMatcher(".");
assertFalse(matcher.isExact());
@@ -54,11 +63,7 @@ public class ExactOrRegexpPatternMatcherTest extends AbstractPatternMatcherTest
matcher = patternMatcher.getMatcher("abc-123_ABC");
assertTrue(matcher.isExact());
- try {
- matcher = patternMatcher.getMatcher("(");
- fail("Should fail on invalid regexp syntax");
- } catch (PatternSyntaxException e) {
-
- }
+ matcher = patternMatcher.getMatcher("(");
+ fail("Should fail on invalid regexp syntax");
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/matcher/ExactPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/matcher/ExactPatternMatcherTest.java b/test/java/org/apache/ivy/plugins/matcher/ExactPatternMatcherTest.java
index 3879b46..729b6c3 100644
--- a/test/java/org/apache/ivy/plugins/matcher/ExactPatternMatcherTest.java
+++ b/test/java/org/apache/ivy/plugins/matcher/ExactPatternMatcherTest.java
@@ -17,12 +17,19 @@
*/
package org.apache.ivy.plugins.matcher;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* @see ExactPatternMatcher
*/
public class ExactPatternMatcherTest extends AbstractPatternMatcherTest {
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
setUp(new ExactPatternMatcher());
}
@@ -34,6 +41,7 @@ public class ExactPatternMatcherTest extends AbstractPatternMatcherTest {
return new String[0]; // there are no inexact expressions possible
}
+ @Test
public void testImplementation() {
Matcher matcher = patternMatcher.getMatcher(".");
assertFalse(matcher.matches(""));
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/matcher/GlobPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/matcher/GlobPatternMatcherTest.java b/test/java/org/apache/ivy/plugins/matcher/GlobPatternMatcherTest.java
index 999d021..f7a2584 100644
--- a/test/java/org/apache/ivy/plugins/matcher/GlobPatternMatcherTest.java
+++ b/test/java/org/apache/ivy/plugins/matcher/GlobPatternMatcherTest.java
@@ -17,14 +17,22 @@
*/
package org.apache.ivy.plugins.matcher;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.regex.PatternSyntaxException;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* @see GlobPatternMatcher
*/
public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
setUp(new GlobPatternMatcher());
}
@@ -36,6 +44,7 @@ public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
return new String[] {"abc*", "12?3", "abc[123]"};
}
+ @Test
public void testValidRegexpSyntaxAsNormalCharacter() {
Matcher matcher = patternMatcher.getMatcher(".");
assertTrue(matcher.isExact());
@@ -45,6 +54,7 @@ public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
assertFalse(matcher.matches("aa"));
}
+ @Test
public void testRegexpSyntaxAndGlob() {
Matcher matcher = patternMatcher.getMatcher(".*");
assertFalse(matcher.isExact());
@@ -56,11 +66,13 @@ public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
assertTrue(matcher.matches(".abcdef"));
}
+ @Test
public void testImplementation() {
Matcher matcher = patternMatcher.getMatcher("abc-123_ABC");
assertTrue(matcher.isExact());
}
+ @Test
public void testQuoteMeta() {
Matcher matcher = patternMatcher.getMatcher("\\*");
assertTrue(matcher.matches("*"));
@@ -68,11 +80,13 @@ public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
assertFalse(matcher.matches("Xsfsdfsd"));
}
+ @Test
public void testInvalidRegexpSyntaxAsNormalCharacter() {
Matcher matcher = patternMatcher.getMatcher("(");
assertTrue(matcher.matches("("));
}
+ @Test
public void testGlob() {
Matcher matcher = patternMatcher.getMatcher("*ivy*");
assertTrue(matcher.matches("ivy"));
@@ -81,12 +95,9 @@ public class GlobPatternMatcherTest extends AbstractPatternMatcherTest {
assertTrue(matcher.matches("abcdefivy"));
}
+ @Test(expected = PatternSyntaxException.class)
public void testInvalidSyntax() {
- try {
- patternMatcher.getMatcher("[");
- fail("Should fail on invalid regexp syntax");
- } catch (PatternSyntaxException e) {
-
- }
+ patternMatcher.getMatcher("[");
+ fail("Should fail on invalid regexp syntax");
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcherTest.java b/test/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcherTest.java
index 87bf5a3..8dba0ea 100644
--- a/test/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcherTest.java
+++ b/test/java/org/apache/ivy/plugins/matcher/RegexpPatternMatcherTest.java
@@ -17,14 +17,21 @@
*/
package org.apache.ivy.plugins.matcher;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.regex.PatternSyntaxException;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* @see RegexpPatternMatcher
*/
public class RegexpPatternMatcherTest extends AbstractPatternMatcherTest {
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
setUp(new RegexpPatternMatcher());
}
@@ -36,6 +43,7 @@ public class RegexpPatternMatcherTest extends AbstractPatternMatcherTest {
return new String[] {"abc+", "12.3", "abc-123*", "abc_123\\d"};
}
+ @Test(expected = PatternSyntaxException.class)
public void testImplementation() {
Matcher matcher = patternMatcher.getMatcher(".*");
assertTrue(matcher.matches(".*"));
@@ -43,11 +51,7 @@ public class RegexpPatternMatcherTest extends AbstractPatternMatcherTest {
assertTrue(matcher.matches("a"));
assertTrue(matcher.matches("aa"));
- try {
- matcher = patternMatcher.getMatcher("(");
- fail("Should fail on invalid syntax");
- } catch (PatternSyntaxException e) {
-
- }
+ matcher = patternMatcher.getMatcher("(");
+ fail("Should fail on invalid syntax");
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/namespace/MRIDTransformationRuleTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/namespace/MRIDTransformationRuleTest.java b/test/java/org/apache/ivy/plugins/namespace/MRIDTransformationRuleTest.java
index 2668368..ab645d1 100644
--- a/test/java/org/apache/ivy/plugins/namespace/MRIDTransformationRuleTest.java
+++ b/test/java/org/apache/ivy/plugins/namespace/MRIDTransformationRuleTest.java
@@ -18,11 +18,13 @@
package org.apache.ivy.plugins.namespace;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class MRIDTransformationRuleTest extends TestCase {
+public class MRIDTransformationRuleTest {
+ @Test
public void testTransformation() {
MRIDTransformationRule r = new MRIDTransformationRule();
r.addSrc(new MRIDRule("apache", "commons.+", null));
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java b/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
index f1ef074..bd880a5 100644
--- a/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
+++ b/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
@@ -24,10 +24,12 @@ import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.id.ArtifactRevisionId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class NameSpaceHelperTest extends TestCase {
+public class NameSpaceHelperTest {
+ @Test
public void testTransformArtifactWithExtraAttributes() throws Exception {
Artifact artifact = new DefaultArtifact(ArtifactRevisionId.newInstance(
ModuleRevisionId.parse("org.apache#test;1.0"), "test", "jar", "jar",
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java b/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java
index c50da89..d7d6987 100644
--- a/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java
+++ b/test/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParserTester.java
@@ -28,15 +28,17 @@ import org.apache.ivy.core.module.descriptor.ExcludeRule;
import org.apache.ivy.core.module.descriptor.IncludeRule;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-public abstract class AbstractModuleDescriptorParserTester extends TestCase {
+public abstract class AbstractModuleDescriptorParserTester {
protected DependencyDescriptor getDependency(DependencyDescriptor[] dependencies, String name) {
- for (int i = 0; i < dependencies.length; i++) {
- assertNotNull(dependencies[i]);
- assertNotNull(dependencies[i].getDependencyId());
- if (name.equals(dependencies[i].getDependencyId().getName())) {
- return dependencies[i];
+ for (DependencyDescriptor dependency : dependencies) {
+ assertNotNull(dependency);
+ assertNotNull(dependency.getDependencyId());
+ if (name.equals(dependency.getDependencyId().getName())) {
+ return dependency;
}
}
return null;
@@ -45,16 +47,16 @@ public abstract class AbstractModuleDescriptorParserTester extends TestCase {
protected void assertArtifacts(Artifact[] artifacts, String[] artifactsNames) {
assertNotNull(artifacts);
assertEquals(artifactsNames.length, artifacts.length);
- for (int i = 0; i < artifactsNames.length; i++) {
+ for (String artifactsName : artifactsNames) {
boolean found = false;
- for (int j = 0; j < artifacts.length; j++) {
- assertNotNull(artifacts[j]);
- if (artifacts[j].getName().equals(artifactsNames[i])) {
+ for (Artifact artifact : artifacts) {
+ assertNotNull(artifact);
+ if (artifact.getName().equals(artifactsName)) {
found = true;
break;
}
}
- assertTrue("artifact not found: " + artifactsNames[i], found);
+ assertTrue("artifact not found: " + artifactsName, found);
}
}
@@ -63,16 +65,16 @@ public abstract class AbstractModuleDescriptorParserTester extends TestCase {
DependencyArtifactDescriptor[] dads = dd.getDependencyArtifacts(confs);
assertNotNull(dads);
assertEquals(artifactsNames.length, dads.length);
- for (int i = 0; i < artifactsNames.length; i++) {
+ for (String artifactsName : artifactsNames) {
boolean found = false;
- for (int j = 0; j < dads.length; j++) {
- assertNotNull(dads[j]);
- if (dads[j].getName().equals(artifactsNames[i])) {
+ for (DependencyArtifactDescriptor dad : dads) {
+ assertNotNull(dad);
+ if (dad.getName().equals(artifactsName)) {
found = true;
break;
}
}
- assertTrue("dependency artifact not found: " + artifactsNames[i], found);
+ assertTrue("dependency artifact not found: " + artifactsName, found);
}
}
@@ -81,16 +83,16 @@ public abstract class AbstractModuleDescriptorParserTester extends TestCase {
IncludeRule[] dads = dd.getIncludeRules(confs);
assertNotNull(dads);
assertEquals(artifactsNames.length, dads.length);
- for (int i = 0; i < artifactsNames.length; i++) {
+ for (String artifactsName : artifactsNames) {
boolean found = false;
- for (int j = 0; j < dads.length; j++) {
- assertNotNull(dads[j]);
- if (dads[j].getId().getName().equals(artifactsNames[i])) {
+ for (IncludeRule dad : dads) {
+ assertNotNull(dad);
+ if (dad.getId().getName().equals(artifactsName)) {
found = true;
break;
}
}
- assertTrue("dependency include not found: " + artifactsNames[i], found);
+ assertTrue("dependency include not found: " + artifactsName, found);
}
}
@@ -99,16 +101,16 @@ public abstract class AbstractModuleDescriptorParserTester extends TestCase {
ExcludeRule[] rules = dd.getExcludeRules(confs);
assertNotNull(rules);
assertEquals(artifactsNames.length, rules.length);
- for (int i = 0; i < artifactsNames.length; i++) {
+ for (String artifactsName : artifactsNames) {
boolean found = false;
- for (int j = 0; j < rules.length; j++) {
- assertNotNull(rules[j]);
- if (rules[j].getId().getName().equals(artifactsNames[i])) {
+ for (ExcludeRule rule : rules) {
+ assertNotNull(rule);
+ if (rule.getId().getName().equals(artifactsName)) {
found = true;
break;
}
}
- assertTrue("dependency exclude not found: " + artifactsNames[i], found);
+ assertTrue("dependency exclude not found: " + artifactsName, found);
}
}
@@ -117,16 +119,16 @@ public abstract class AbstractModuleDescriptorParserTester extends TestCase {
ExcludeRule[] rules = dd.getExcludeRules(confs);
assertNotNull(rules);
assertEquals(moduleNames.length, rules.length);
- for (int i = 0; i < moduleNames.length; i++) {
+ for (String moduleName : moduleNames) {
boolean found = false;
- for (int j = 0; j < rules.length; j++) {
- assertNotNull(rules[j]);
- if (rules[j].getId().getModuleId().getName().equals(moduleNames[i])) {
+ for (ExcludeRule rule : rules) {
+ assertNotNull(rule);
+ if (rule.getId().getModuleId().getName().equals(moduleName)) {
found = true;
break;
}
}
- assertTrue("dependency module exclude not found: " + moduleNames[i], found);
+ assertTrue("dependency module exclude not found: " + moduleName, found);
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/ModuleDescriptorParserRegistryTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/ModuleDescriptorParserRegistryTest.java b/test/java/org/apache/ivy/plugins/parser/ModuleDescriptorParserRegistryTest.java
index 267ed74..9bf6afe 100644
--- a/test/java/org/apache/ivy/plugins/parser/ModuleDescriptorParserRegistryTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/ModuleDescriptorParserRegistryTest.java
@@ -28,10 +28,12 @@ import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.repository.Resource;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-public class ModuleDescriptorParserRegistryTest extends TestCase {
+public class ModuleDescriptorParserRegistryTest {
public static class MyParser extends AbstractModuleDescriptorParser {
public ModuleDescriptor parseDescriptor(ParserSettings ivy, URL descriptorURL,
Resource res, boolean validate) throws ParseException, IOException {
@@ -49,6 +51,7 @@ public class ModuleDescriptorParserRegistryTest extends TestCase {
}
+ @Test
public void testAddConfigured() throws Exception {
IvySettings settings = new IvySettings();
settings.addConfigured(new MyParser());
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
index f471401..0913551 100644
--- a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
@@ -44,6 +44,11 @@ import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest;
import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.MockResolver;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParserTester {
// junit test -- DO NOT REMOVE used by ant to know it's a junit test
@@ -55,8 +60,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
throws ParseException {
// TODO make it a real mock and check that dd and data are the one that are expected
final ModuleDescriptor moduleDesc = getModuleDescriptor(dd);
- ResolvedModuleRevision r = new ResolvedModuleRevision(this, this, moduleDesc, null);
- return r;
+ return new ResolvedModuleRevision(this, this, moduleDesc, null);
}
protected ModuleDescriptor getModuleDescriptor(final DependencyDescriptor dependencyDescriptor) {
@@ -68,9 +72,9 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
private MockResolver mockedResolver = new MockedDependencyResolver();
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
settings.setDictatorResolver(mockedResolver);
- super.setUp();
if (dest.exists()) {
dest.delete();
}
@@ -79,12 +83,14 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
}
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
if (dest.exists()) {
dest.delete();
}
}
+ @Test
public void testAccept() throws Exception {
assertTrue(PomModuleDescriptorParser.getInstance().accept(
new URLResource(getClass().getResource("test-simple.pom"))));
@@ -92,6 +98,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
new URLResource(XmlModuleDescriptorParserTest.class.getResource("test.xml"))));
}
+ @Test
public void testSimple() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-simple.pom"), false);
@@ -112,6 +119,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifact[0].getType());
}
+ @Test
public void testLargePom() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-large-pom.pom"), false);
@@ -121,6 +129,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(mrid, md.getModuleRevisionId());
}
+ @Test
public void testPackaging() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-packaging.pom"), false);
@@ -137,6 +146,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("war", artifact[0].getType());
}
+ @Test
public void testEjbPackaging() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-ejb-packaging.pom"), false);
@@ -153,6 +163,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("ejb", artifact[0].getType());
}
+ @Test
public void testEjbType() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-ejb-type.pom"), false);
@@ -173,6 +184,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("ejb", artifacts[0].getType());
}
+ @Test
public void testParent() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-parent.pom"), false);
@@ -187,16 +199,18 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("test", artifact[0].getName());
}
+ @Test
public void testParentNotFound() throws Exception {
try {
PomModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(),
getClass().getResource("test-parent-not-found.pom"), false);
fail("IOException should have been thrown!");
} catch (IOException e) {
- assertTrue(e.getMessage().indexOf("Impossible to load parent") != -1);
+ assertTrue(e.getMessage().contains("Impossible to load parent"));
}
}
+ @Test
public void testParent2() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-parent2.pom"), false);
@@ -211,6 +225,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("test", artifact[0].getName());
}
+ @Test
public void testParentVersion() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-parent.version.pom"), false);
@@ -225,6 +240,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("test", artifact[0].getName());
}
+ @Test
public void testParentGroupId() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-parent.groupid.pom"), false);
@@ -239,6 +255,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("test", artifact[0].getName());
}
+ @Test
public void testProjectParentVersion() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-project.parent.version.pom"), false);
@@ -253,6 +270,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("test", artifact[0].getName());
}
+ @Test
public void testDependencies() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies.pom"), false);
@@ -270,6 +288,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getAllDependencyArtifacts().length);
}
+ @Test
public void testDependenciesWithClassifier() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies-with-classifier.pom"), true);
@@ -307,6 +326,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(extraAtt, dds[0].getAllDependencyArtifacts()[0].getExtraAttributes());
}
+ @Test
public void testDependenciesWithType() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies-with-type.pom"), true);
@@ -325,6 +345,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("dll", dds[0].getAllDependencyArtifacts()[0].getType());
}
+ @Test
public void testWithVersionPropertyAndPropertiesTag() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-version.pom"), false);
@@ -340,6 +361,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
}
// IVY-392
+ @Test
public void testDependenciesWithInactiveProfile() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies-with-profile.pom"), false);
@@ -355,6 +377,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getDependencyRevisionId());
}
+ @Test
public void testWithoutVersion() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-without-version.pom"), false);
@@ -369,6 +392,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getDependencyRevisionId());
}
+ @Test
public void testProperties() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-properties.pom"), false);
@@ -384,6 +408,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getDependencyRevisionId());
}
+ @Test
public void testReal() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("commons-lang-1.0.pom"), false);
@@ -399,6 +424,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getDependencyRevisionId());
}
+ @Test
public void testReal2() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("wicket-1.3-incubating-SNAPSHOT.pom"), false);
@@ -409,6 +435,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
md.getModuleRevisionId());
}
+ @Test
public void testVariables() throws Exception {
// test case for IVY-425
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -426,6 +453,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[10].getDependencyRevisionId());
}
+ @Test
public void testDependenciesInProfile() throws Exception {
// test case for IVY-423
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -437,6 +465,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
md.getModuleRevisionId());
}
+ @Test
public void testIVY424() throws Exception {
// test case for IVY-424
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -448,6 +477,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
md.getModuleRevisionId());
}
+ @Test
public void testOptional() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-optional.pom"), false);
@@ -488,6 +518,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
new HashSet(Arrays.asList(dds[2].getDependencyConfigurations("runtime"))));
}
+ @Test
public void testDependenciesWithScope() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -526,6 +557,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
new HashSet(Arrays.asList(dds[2].getDependencyConfigurations("runtime"))));
}
+ @Test
public void testExclusion() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-exclusion.pom"), false);
@@ -582,6 +614,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertFalse("Dependency " + excludeAllTransitiveDepsDescriptor + " was expected to have transitive=false", excludeAllTransitiveDepsDescriptor.isTransitive());
}
+ @Test
public void testWithPlugins() throws Exception {
// test case for IVY-417
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -596,6 +629,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, dds.length);
}
+ @Test
public void testHomeAndDescription() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("mule-1.3.3.pom"), false);
@@ -613,6 +647,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
.replaceAll("\r\n", "\n").replace('\r', '\n'));
}
+ @Test
public void testLicense() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("spring-hibernate3-2.0.2.pom"), false);
@@ -625,11 +660,12 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
}
/**
- * Tests that if a module doesn't have a license specified, then parent pom's license (if any) is used for the child
- * module
+ * Tests that if a module doesn't have a license specified, then parent pom's license (if any)
+ * is used for the child module
*
* @throws Exception
*/
+ @Test
public void testLicenseFromParent() throws Exception {
final IvySettings customIvySettings = createIvySettingsForParentLicenseTesting("test-parent-with-licenses.pom",
"org.apache", "test-ivy-license-parent");
@@ -645,11 +681,12 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
}
/**
- * Tests that if a project explicitly specifies the licenses, then the licenses (if any) from its parent pom
- * aren't applied to the child project
+ * Tests that if a project explicitly specifies the licenses, then the licenses (if any) from
+ * its parent pom aren't applied to the child project
*
* @throws Exception
*/
+ @Test
public void testOverriddenLicense() throws Exception {
final IvySettings customIvySettings = createIvySettingsForParentLicenseTesting("test-parent-with-licenses.pom",
"org.apache", "test-ivy-license-parent");
@@ -664,8 +701,8 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("Unexpected license URL", "http://www.apache.org/licenses/LICENSE-2.0.txt", licenses[0].getUrl());
}
-
- public void testDependencyManagment() throws ParseException, IOException {
+ @Test
+ public void testDependencyManagement() throws ParseException, IOException {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencyMgt.pom"), false);
assertNotNull(md);
@@ -682,7 +719,8 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(4, md.getExtraInfos().size());
}
- public void testDependencyManagmentWithScope() throws ParseException, IOException {
+ @Test
+ public void testDependencyManagementWithScope() throws ParseException, IOException {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-dependencyMgt-with-scope.pom"), false);
assertNotNull(md);
@@ -701,6 +739,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("The configuration must be test", "test", dds[0].getModuleConfigurations()[0]);
}
+ @Test
public void testParentDependencyMgt() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -740,7 +779,9 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
- public void testOverrideParentVersionPropertyDependencyMgt() throws ParseException, IOException {
+ @Test
+ public void testOverrideParentVersionPropertyDependencyMgt()
+ throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
throws ParseException {
@@ -780,6 +821,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
+ @Test
public void testParentProperties() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -810,6 +852,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
// parent
}
+ @Test
public void testOverrideParentProperties() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -838,6 +881,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[1].getDependencyRevisionId());
}
+ @Test
public void testOverrideGrandparentProperties() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -873,12 +917,14 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[2].getDependencyRevisionId());
}
+ @Test
public void testPomWithEntity() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-entity.pom"), true);
assertNotNull(md);
}
+ @Test
public void testModel() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-model.pom"), false);
@@ -899,6 +945,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifact[0].getType());
}
+ @Test
public void testParentBomImport() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -928,6 +975,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[0].getDependencyRevisionId());
}
+ @Test
public void testGrandparentBomImport() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
@@ -960,6 +1008,7 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
dds[1].getDependencyRevisionId());
}
+ @Test
public void testParentProfileBomImport() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
index a060bf4..8eb1808 100644
--- a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
@@ -27,10 +27,14 @@ import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-public class PomModuleDescriptorWriterTest extends TestCase {
+public class PomModuleDescriptorWriterTest {
private static String LICENSE;
static {
try {
@@ -43,6 +47,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
private File _dest = new File("build/test/test-write.xml");
+ @Test
public void testSimple() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-simple.pom"), false);
@@ -56,6 +61,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testSimpleDependencies() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies.pom"), false);
@@ -69,6 +75,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testDependenciesWithScope() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -82,6 +89,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testDependenciesWithType() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-type.pom"), false);
@@ -95,6 +103,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testDependenciesWithClassifier() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-classifier.pom"),
@@ -109,6 +118,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testOptional() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-optional.pom"), false);
@@ -122,6 +132,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testTransitive() throws Exception {
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-transitive.xml"), false);
@@ -136,6 +147,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testPackaging() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-packaging.pom"), false);
@@ -149,6 +161,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testWriteCompileConfigurationOnly() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -163,6 +176,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testWriteRuntimeConfigurationOnly() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -177,6 +191,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testWriteAllConfiguration() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -190,6 +205,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testWriteAllExceptRuntimeConfiguration() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-dependencies-with-scope.pom"), false);
@@ -213,6 +229,7 @@ public class PomModuleDescriptorWriterTest extends TestCase {
return (new PomWriterOptions()).setLicenseHeader(LICENSE).setPrintIvyInfo(false);
}
+ @Before
public void setUp() {
if (_dest.exists()) {
_dest.delete();
@@ -222,7 +239,8 @@ public class PomModuleDescriptorWriterTest extends TestCase {
}
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
if (_dest.exists()) {
_dest.delete();
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
index 969c47b..3831ace 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
@@ -52,12 +52,16 @@ import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParserTester {
private IvySettings settings = null;
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() {
Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_WARN));
this.settings = new IvySettings();
@@ -65,6 +69,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
settings.setDefaultCache(new File("build/cache"));
}
+ @Test
public void testSimple() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-simple.xml"), true);
@@ -87,6 +92,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, md.getDependencies().length);
}
+ @Test
public void testNamespaces() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-namespaces.xml"), true);
@@ -102,6 +108,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("http://ant.apache.org/ivy/extra", md.getExtraAttributesNamespaces().get("e"));
}
+ @Test
public void testEmptyDependencies() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-empty-dependencies.xml"), true);
@@ -124,6 +131,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, md.getDependencies().length);
}
+ @Test
public void testBad() throws IOException {
try {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -132,11 +140,13 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
} catch (ParseException ex) {
if (XMLHelper.canUseSchemaValidation()) {
assertTrue("exception message not explicit. It should contain 'modul', but it's:"
- + ex.getMessage(), ex.getMessage().indexOf("'modul'") != -1);
+ + ex.getMessage(),
+ ex.getMessage().contains("'modul'"));
}
}
}
+ @Test
public void testBadOrg() throws IOException {
try {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -147,11 +157,12 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
} catch (ParseException ex) {
if (XMLHelper.canUseSchemaValidation()) {
assertTrue("invalid exception: " + ex.getMessage(),
- ex.getMessage().indexOf("organization") != -1);
+ ex.getMessage().contains("organization"));
}
}
}
+ @Test
public void testBadConfs() throws IOException {
try {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -160,10 +171,11 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
} catch (ParseException ex) {
ex.printStackTrace();
assertTrue("invalid exception: " + ex.getMessage(),
- ex.getMessage().indexOf("invalidConf") != -1);
+ ex.getMessage().contains("invalidConf"));
}
}
+ @Test
public void testCyclicConfs() throws IOException {
try {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -171,7 +183,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
fail("bad ivy file raised no error");
} catch (ParseException ex) {
assertTrue("invalid exception: " + ex.getMessage(),
- ex.getMessage().indexOf("A => B => A") != -1);
+ ex.getMessage().contains("A => B => A"));
}
try {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -179,25 +191,25 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
fail("bad ivy file raised no error");
} catch (ParseException ex) {
assertTrue("invalid exception: " + ex.getMessage(),
- ex.getMessage().indexOf("A => C => B => A") != -1);
+ ex.getMessage().contains("A => C => B => A"));
}
}
+ @Test
public void testNoValidate() throws IOException, ParseException {
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-novalidate.xml"), false);
}
- public void testBadVersion() throws IOException {
- try {
- XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ @Test(expected = ParseException.class)
+ public void testBadVersion() throws IOException, ParseException {
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-bad-version.xml"), true);
- fail("bad version ivy file raised no error");
- } catch (ParseException ex) {
- // ok
- }
+ fail("bad version ivy file raised no error");
}
+ @SuppressWarnings("deprecation")
+ @Test
public void testFull() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test.xml"), true);
@@ -491,6 +503,8 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(rules[1].getConfigurations()));
}
+ @SuppressWarnings("deprecation")
+ @Test
public void testFullNoValidation() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test.xml"), false);
@@ -499,6 +513,8 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("56576", md.getExtraInfo().get("e:someExtra"));
}
+ @SuppressWarnings("deprecation")
+ @Test
public void testExtraInfos() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extrainfo.xml"), true);
@@ -520,6 +536,8 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, secondExtraInfoElement.getNestedExtraInfoHolder().size());
}
+ @SuppressWarnings("deprecation")
+ @Test
public void testExtraInfosNested() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extrainfo-nested.xml"), true);
@@ -555,6 +573,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, yetAnotherExtraInfoElement.getNestedExtraInfoHolder().size());
}
+ @Test
public void testBug60() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-bug60.xml"), true);
@@ -572,6 +591,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertArtifacts(md.getArtifacts("default"), new String[] {"myartifact1", "myartifact2"});
}
+ @Test
public void testNoArtifact() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-noartifact.xml"), true);
@@ -592,6 +612,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(0, md.getDependencies().length);
}
+ @Test
public void testNoPublication() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-nopublication.xml"), true);
@@ -614,6 +635,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(1, md.getDependencies().length);
}
+ @Test
public void testArtifactsDefaults() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-artifacts-defaults.xml"), true);
@@ -632,6 +654,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
+ "/" + artifact.getExt());
}
+ @Test
public void testDefaultConfWithDefaultConfMapping() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-defaultconf-withdefaultconfmapping.xml"), true);
@@ -662,6 +685,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("test")));
}
+ @Test
public void testDefaultConf() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-defaultconf.xml"), true);
@@ -691,6 +715,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("default")));
}
+ @Test
public void testDefaultConf2() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-defaultconf2.xml"), true);
@@ -723,6 +748,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("test")));
}
+ @Test
public void testPublicationDefaultConf() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-publication-defaultconf.xml"), true);
@@ -741,6 +767,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(1, artifacts.length);
}
+ @Test
public void testDefaultConfMapping() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-defaultconfmapping.xml"), true);
@@ -772,6 +799,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("test")));
}
+ @Test
public void testExtraAttributes() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extra-attributes.xml"), false);
@@ -800,6 +828,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("depextravalue", dd.getDependencyRevisionId().getAttribute("depextra"));
}
+ @Test
public void testImportConfigurations1() throws Exception {
// import configurations
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -832,6 +861,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("conf1")));
}
+ @Test
public void testImportConfigurations2() throws Exception {
// import configurations and add another one
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -867,6 +897,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("conf3")));
}
+ @Test
public void testImportConfigurations3() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -901,6 +932,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("conf1")));
}
+ @Test
public void testImportConfigurations5() throws Exception {
// import configurations
settings.setVariable("base.dir", new File(".").getAbsolutePath());
@@ -934,6 +966,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("conf1")));
}
+ @Test
public void testExtendOtherConfigs() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -949,6 +982,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(Arrays.asList(new String[] {"default", "test"}), Arrays.asList(allPublicExt));
}
+ @Test
public void testImportConfigurationsWithExtendOtherConfigs() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -965,6 +999,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(allPublicExt));
}
+ @Test
public void testImportConfigurationsWithMappingOverride() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -993,6 +1028,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("conf2")));
}
+ @Test
public void testImportConfigurationsWithWildcardAndMappingOverride() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1021,6 +1057,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("all-public")));
}
+ @Test
public void testDefaultConfMappingWithSelectors() throws Exception {
// import configurations and default mapping
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1052,38 +1089,30 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
Arrays.asList(dd.getDependencyConfigurations("bla")));
}
+ // IVY-442
+ @Test(expected = ParseException.class)
public void testWithNonExistingConfigInDependency() throws Exception {
- // IVY-442
- try {
- XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-incorrectconf1.xml"), true);
- fail("ParseException hasn't been thrown");
- } catch (ParseException e) {
- // expected
- }
+ fail("ParseException hasn't been thrown");
}
+ @Test(expected = ParseException.class)
public void testWithNonExistingConfigInPublications() throws Exception {
- try {
- XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-incorrectconf2.xml"), true);
- fail("ParseException hasn't been thrown");
- } catch (ParseException e) {
- // expected
- }
+ fail("ParseException hasn't been thrown");
}
+ // IVY-441
+ @Test(expected = ParseException.class)
public void testWithExistingConfigsInPublicationsSeparatedBySemiColon() throws Exception {
- // IVY-441
- try {
- XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-incorrectconf3.xml"), true);
- fail("ParseException hasn't been thrown");
- } catch (ParseException e) {
- // expected
- }
+ fail("ParseException hasn't been thrown");
}
+ @Test
public void testExtendsAll() throws Exception {
Message.setDefaultLogger(new DefaultMessageLogger(99));
@@ -1133,6 +1162,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsDependencies() throws Exception {
// descriptor specifies that only parent dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1179,6 +1209,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsConfigurations() throws Exception {
// descriptor specifies that only parent configurations should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1219,6 +1250,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsDescription() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1258,6 +1290,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsDescriptionWithOverride() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1297,6 +1330,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsMixed() throws Exception {
// descriptor specifies that parent configurations and dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
@@ -1344,6 +1378,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals("jar", artifacts[0].getType());
}
+ @Test
public void testExtendsCached() throws Exception {
// configure a resolver to serve the parent descriptor, so that parse succeeds.
File resolveRoot = new File("build/tmp/xmlModuleDescriptorTest");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
index 8ed79d0..b085933 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
@@ -35,9 +35,17 @@ import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParserTest;
import org.apache.ivy.util.FileUtil;
-import org.custommonkey.xmlunit.XMLTestCase;
-public class XmlModuleDescriptorWriterTest extends XMLTestCase {
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class XmlModuleDescriptorWriterTest {
private static String LICENSE;
static {
try {
@@ -50,6 +58,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
private File dest = new File("build/test/test-write.xml");
+ @Test
public void testSimple() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser
.getInstance().parseDescriptor(new IvySettings(),
@@ -67,6 +76,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testInfo() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser
.getInstance().parseDescriptor(new IvySettings(),
@@ -84,6 +94,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testDependencies() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
@@ -98,6 +109,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testFull() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), XmlModuleDescriptorWriterTest.class.getResource("test.xml"), false);
@@ -111,6 +123,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testExtraInfos() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
@@ -125,6 +138,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testExtraInfosWithNestedElement() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
@@ -139,6 +153,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertEquals(expected, wrote);
}
+ @Test
public void testExtraInfosFromMaven() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
@@ -157,6 +172,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
assertXMLEqual(expected, wrote);
}
+ @Test
public void testExtends() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
@@ -178,6 +194,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
* @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
* @throws Exception
*/
+ @Test
public void testTransitiveAttributeForNonTransitiveConfs() throws Exception {
// Given a ModuleDescriptor with a non-transitive configuration
DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId(
@@ -193,7 +210,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
String writtenConf = output.substring(output.indexOf("<configurations>") + 16,
output.indexOf("</configurations>")).trim();
assertTrue("Transitive attribute not set to false: " + writtenConf,
- writtenConf.indexOf("transitive=\"false\"") >= 0);
+ writtenConf.contains("transitive=\"false\""));
}
/**
@@ -205,6 +222,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
* @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
* @throws Exception
*/
+ @Test
public void testTransitiveAttributeNotWrittenForTransitiveConfs() throws Exception {
// Given a ModuleDescriptor with a transitive configuration
DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId(
@@ -220,7 +238,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
String writtenConf = output.substring(output.indexOf("<configurations>") + 16,
output.indexOf("</configurations>")).trim();
assertFalse("Transitive attribute set: " + writtenConf,
- writtenConf.indexOf("transitive=") >= 0);
+ writtenConf.contains("transitive="));
}
private String readEntirely(String resource) throws IOException {
@@ -228,6 +246,7 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
XmlModuleDescriptorWriterTest.class.getResource(resource).openStream())));
}
+ @Before
public void setUp() {
if (dest.exists()) {
dest.delete();
@@ -237,7 +256,8 @@ public class XmlModuleDescriptorWriterTest extends XMLTestCase {
}
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
if (dest.exists()) {
dest.delete();
}