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:40 UTC
[07/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/ant/IvyDependencyUpdateCheckerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java b/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
index 65b4523..18ae6f2 100644
--- a/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
+++ b/test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
@@ -22,14 +22,22 @@ import java.io.File;
import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
import org.apache.ivy.ant.testutil.AntTaskTestCase;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
private IvyDependencyUpdateChecker dependencyUpdateChecker;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = configureProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -39,10 +47,16 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
dependencyUpdateChecker.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ private Ivy getIvy() {
+ return dependencyUpdateChecker.getIvyInstance();
+ }
+
+ @Test
public void testSimple() throws Exception {
// depends on org="org1" name="mod1.1" rev="1.0"
// has transitive dependency on org="org1" name="mod1.2" rev="2.0"
@@ -57,6 +71,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
assertLogNotContaining("org1#mod1.2 (transitive)\t2.0 -> 2.1");
}
+ @Test
public void testSimpleAndShowTransitiveDependencies() throws Exception {
// depends on org="org1" name="mod1.1" rev="1.0"
// has transitive dependency on org="org1" name="mod1.2" rev="2.0"
@@ -72,6 +87,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
assertLogContaining("org1#mod1.2 (transitive)\t2.0 -> 2.1");
}
+ @Test
public void testResolveWithoutIvyFile() throws Exception {
// depends on org="org1" name="mod1.2" rev="2.0"
@@ -84,6 +100,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
assertLogContaining("org1#mod1.2\t2.0 -> 2.2");
}
+ @Test
public void testInline() throws Exception {
// same as before, but expressing dependency directly without ivy file
dependencyUpdateChecker.setOrganisation("org1");
@@ -97,31 +114,26 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
}
+ @Test(expected = BuildException.class)
public void testInlineForNonExistingModule() throws Exception {
- try {
- dependencyUpdateChecker.setOrganisation("org1XXYZ");
- dependencyUpdateChecker.setModule("mod1.2");
- dependencyUpdateChecker.setRevision("2.0");
- dependencyUpdateChecker.setInline(true);
- dependencyUpdateChecker.setHaltonfailure(true);
- dependencyUpdateChecker.execute();
- fail("failure didn't raised an exception with default haltonfailure setting");
- } catch (BuildException ex) {
- // ok => should raise an exception
- }
+ dependencyUpdateChecker.setOrganisation("org1XXYZ");
+ dependencyUpdateChecker.setModule("mod1.2");
+ dependencyUpdateChecker.setRevision("2.0");
+ dependencyUpdateChecker.setInline(true);
+ dependencyUpdateChecker.setHaltonfailure(true);
+ dependencyUpdateChecker.execute();
+ fail("failure didn't raised an exception with default haltonfailure setting");
}
+ @Test(expected = BuildException.class)
public void testFailure() throws Exception {
- try {
- dependencyUpdateChecker
- .setFile(new File("test/java/org/apache/ivy/ant/ivy-failure.xml"));
- dependencyUpdateChecker.execute();
- fail("failure didn't raised an exception with default haltonfailure setting");
- } catch (BuildException ex) {
- // ok => should raise an exception
- }
+ dependencyUpdateChecker
+ .setFile(new File("test/java/org/apache/ivy/ant/ivy-failure.xml"));
+ dependencyUpdateChecker.execute();
+ fail("failure didn't raised an exception with default haltonfailure setting");
}
+ @Test
public void testFailureWithMissingConfigurations() throws Exception {
try {
dependencyUpdateChecker
@@ -130,32 +142,27 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
dependencyUpdateChecker.execute();
fail("missing configurations didn't raised an exception");
} catch (BuildException ex) {
- assertTrue(ex.getMessage().indexOf("unknown") != -1);
+ assertTrue(ex.getMessage().contains("unknown"));
}
}
+ @Test(expected = BuildException.class)
public void testFailureOnBadDependencyIvyFile() throws Exception {
- try {
- dependencyUpdateChecker.setFile(new File(
- "test/java/org/apache/ivy/ant/ivy-failure2.xml"));
- dependencyUpdateChecker.execute();
- fail("failure didn't raised an exception with default haltonfailure setting");
- } catch (BuildException ex) {
- // ok => should raise an exception
- }
+ dependencyUpdateChecker.setFile(new File(
+ "test/java/org/apache/ivy/ant/ivy-failure2.xml"));
+ dependencyUpdateChecker.execute();
+ fail("failure didn't raised an exception with default haltonfailure setting");
}
+ @Test(expected = BuildException.class)
public void testFailureOnBadStatusInDependencyIvyFile() throws Exception {
- try {
- dependencyUpdateChecker.setFile(new File(
- "test/java/org/apache/ivy/ant/ivy-failure3.xml"));
- dependencyUpdateChecker.execute();
- fail("failure didn't raised an exception with default haltonfailure setting");
- } catch (BuildException ex) {
- // ok => should raise an exception
- }
+ dependencyUpdateChecker.setFile(new File(
+ "test/java/org/apache/ivy/ant/ivy-failure3.xml"));
+ dependencyUpdateChecker.execute();
+ fail("failure didn't raised an exception with default haltonfailure setting");
}
+ @Test
public void testHaltOnFailure() throws Exception {
try {
dependencyUpdateChecker
@@ -168,6 +175,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
}
}
+ @Test
public void testExcludedConf() throws Exception {
dependencyUpdateChecker.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
dependencyUpdateChecker.setConf("*,!default");
@@ -182,9 +190,10 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
assertLogContaining("All dependencies are up to date");
// test the properties
Project project = dependencyUpdateChecker.getProject();
- assertFalse(project.getProperty("ivy.resolved.configurations").indexOf("default") > -1);
+ assertFalse(project.getProperty("ivy.resolved.configurations").contains("default"));
}
+ @Test
public void testResolveWithAbsoluteFile() {
// IVY-396
File ivyFile = new File("test/java/org/apache/ivy/ant/ivy-simple.xml");
@@ -195,6 +204,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
// ModuleRevisionId.newInstance("apache", "resolve-simple", "1.0")).exists());
}
+ @Test
public void testResolveWithRelativeFile() {
// IVY-396
dependencyUpdateChecker.getProject().setProperty("ivy.dep.file",
@@ -208,10 +218,7 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
assertLogContaining("org1#mod1.2\t2.0 -> 2.2");
}
- private Ivy getIvy() {
- return dependencyUpdateChecker.getIvyInstance();
- }
-
+ @Test
public void testSimpleExtends() throws Exception {
dependencyUpdateChecker.setFile(new File(
"test/java/org/apache/ivy/ant/ivy-extends-multiconf.xml"));
@@ -233,7 +240,6 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
// inherited from parent
assertLogContaining("org1#mod1.2\t2.0 -> 2.2");
-
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyFindRevisionTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyFindRevisionTest.java b/test/java/org/apache/ivy/ant/IvyFindRevisionTest.java
index ca1c19c..4439dc6 100644
--- a/test/java/org/apache/ivy/ant/IvyFindRevisionTest.java
+++ b/test/java/org/apache/ivy/ant/IvyFindRevisionTest.java
@@ -18,15 +18,21 @@
package org.apache.ivy.ant;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
-public class IvyFindRevisionTest extends TestCase {
+public class IvyFindRevisionTest {
private IvyFindRevision findRevision;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -35,10 +41,12 @@ public class IvyFindRevisionTest extends TestCase {
findRevision.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testProperty() throws Exception {
findRevision.setOrganisation("org1");
findRevision.setModule("mod1.1");
@@ -48,6 +56,7 @@ public class IvyFindRevisionTest extends TestCase {
assertEquals("1.0", findRevision.getProject().getProperty("test.revision"));
}
+ @Test
public void testLatest() throws Exception {
findRevision.setOrganisation("org1");
findRevision.setModule("mod1.1");
@@ -56,6 +65,7 @@ public class IvyFindRevisionTest extends TestCase {
assertEquals("2.0", findRevision.getProject().getProperty("ivy.revision"));
}
+ @Test
public void testLatestSubversion() throws Exception {
findRevision.setOrganisation("org1");
findRevision.setModule("mod1.1");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyInfoRepositoryTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyInfoRepositoryTest.java b/test/java/org/apache/ivy/ant/IvyInfoRepositoryTest.java
index cc25c95..218f850 100644
--- a/test/java/org/apache/ivy/ant/IvyInfoRepositoryTest.java
+++ b/test/java/org/apache/ivy/ant/IvyInfoRepositoryTest.java
@@ -18,15 +18,21 @@
package org.apache.ivy.ant;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
-public class IvyInfoRepositoryTest extends TestCase {
+public class IvyInfoRepositoryTest {
private IvyInfo info;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -35,10 +41,12 @@ public class IvyInfoRepositoryTest extends TestCase {
info.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testProperty() throws Exception {
info.setOrganisation("org1");
info.setModule("mod1.1");
@@ -52,6 +60,7 @@ public class IvyInfoRepositoryTest extends TestCase {
assertEquals("default", info.getProject().getProperty("test.configurations"));
}
+ @Test
public void testLatest() throws Exception {
info.setOrganisation("org1");
info.setModule("mod1.1");
@@ -64,6 +73,7 @@ public class IvyInfoRepositoryTest extends TestCase {
assertEquals("default", info.getProject().getProperty("ivy.configurations"));
}
+ @Test
public void testLatestSubversion() throws Exception {
info.setOrganisation("org1");
info.setModule("mod1.1");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyInfoTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyInfoTest.java b/test/java/org/apache/ivy/ant/IvyInfoTest.java
index 967a881..3930a9d 100644
--- a/test/java/org/apache/ivy/ant/IvyInfoTest.java
+++ b/test/java/org/apache/ivy/ant/IvyInfoTest.java
@@ -20,20 +20,28 @@ package org.apache.ivy.ant;
import java.io.File;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-public class IvyInfoTest extends TestCase {
+public class IvyInfoTest {
private IvyInfo info;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
Project project = TestHelper.newProject();
info = new IvyInfo();
info.setProject(project);
}
+ @Test
public void testSimple() throws Exception {
info.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
info.execute();
@@ -45,6 +53,7 @@ public class IvyInfoTest extends TestCase {
assertEquals("default", info.getProject().getProperty("ivy.public.configurations"));
}
+ @Test
public void testAll() throws Exception {
info.setFile(new File("test/java/org/apache/ivy/ant/ivy-info-all.xml"));
info.execute();
@@ -66,6 +75,7 @@ public class IvyInfoTest extends TestCase {
assertNull(info.getProject().getProperty("ivy.configuration.private.desc"));
}
+ @Test
public void testIVY726() throws Exception {
info.setFile(new File("test/java/org/apache/ivy/ant/ivy-info-all.xml"));
info.execute();
@@ -73,6 +83,7 @@ public class IvyInfoTest extends TestCase {
assertTrue(info.getProject().getProperty("ivy.extra.branch") == null);
}
+ @Test
public void testIVY395() throws Exception {
info.setFile(new File("test/java/org/apache/ivy/ant/ivy-artifact-info.xml"));
info.execute();
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyInstallTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyInstallTest.java b/test/java/org/apache/ivy/ant/IvyInstallTest.java
index c1b65eb..a01a7c8 100644
--- a/test/java/org/apache/ivy/ant/IvyInstallTest.java
+++ b/test/java/org/apache/ivy/ant/IvyInstallTest.java
@@ -21,19 +21,28 @@ import java.io.File;
import org.apache.ivy.TestHelper;
import org.apache.ivy.util.FileUtil;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
-public class IvyInstallTest extends TestCase {
+public class IvyInstallTest {
private File cache;
private IvyInstall install;
private Project project;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
createCache();
cleanInstall();
@@ -49,7 +58,8 @@ public class IvyInstallTest extends TestCase {
cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
cleanCache();
cleanInstall();
}
@@ -63,6 +73,7 @@ public class IvyInstallTest extends TestCase {
FileUtil.forceDelete(new File("build/test/install2"));
}
+ @Test
public void testInstallDummyDefault() {
project.setProperty("ivy.settings.file",
"test/repositories/ivysettings-dummydefaultresolver.xml");
@@ -84,6 +95,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.2.jar").exists());
}
+ @Test
public void testInstallWithAnyType() {
project.setProperty("ivy.settings.file",
"test/repositories/ivysettings-dummydefaultresolver.xml");
@@ -99,6 +111,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/org8/mod8.1/a-1.1.txt").exists());
}
+ @Test
public void testInstallWithMultipleType() {
project.setProperty("ivy.settings.file",
"test/repositories/ivysettings-dummydefaultresolver.xml");
@@ -117,6 +130,7 @@ public class IvyInstallTest extends TestCase {
/**
* Normal case; no confs set (should use the default->* configuration).
*/
+ @Test
public void testInstallWithConfsDefaultSettings() {
project.setProperty("ivy.settings.file", "test/repositories/IVY-1313/ivysettings.xml");
install.setOrganisation("org1");
@@ -136,6 +150,7 @@ public class IvyInstallTest extends TestCase {
/**
* Test retrieving artifacts under only the master and runtime configuration.
*/
+ @Test
public void testInstallWithConfsRuntimeOnly() {
project.setProperty("ivy.settings.file", "test/repositories/IVY-1313/ivysettings.xml");
install.setOrganisation("org1");
@@ -153,6 +168,7 @@ public class IvyInstallTest extends TestCase {
assertFalse(new File("build/test/install/org1/mod3/jars/mod3-1.0.jar").exists());
}
+ @Test
public void testInstallWithClassifiers() throws Exception {
// IVY-1324
project.setProperty("ivy.settings.url", new File("test/repositories/m2/ivysettings.xml")
@@ -175,6 +191,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/org.apache/test-sources/ivy-1.0.xml").exists());
}
+ @Test
public void testInstallWithUnusedType() {
project.setProperty("ivy.settings.file",
"test/repositories/ivysettings-dummydefaultresolver.xml");
@@ -190,6 +207,7 @@ public class IvyInstallTest extends TestCase {
assertFalse(new File("build/test/install/org8/mod8.1/a-1.1.txt").exists());
}
+ @Test
public void testInstallWithOriginalMetadata() {
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
install.setOrganisation("org.apache");
@@ -219,6 +237,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
}
+ @Test
public void testIVY843() {
project.setProperty("ivy.settings.file", "test/repositories/ivysettings-IVY843.xml");
install.setOrganisation("org1");
@@ -238,6 +257,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install2/org1/mod1.4/ivy-1.0.1.xml").exists());
}
+ @Test
public void testInstallWithBranch() {
project.setProperty("ivy.settings.file", "test/repositories/branches/ivysettings.xml");
install.setOrganisation("foo");
@@ -252,6 +272,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/foo/foo1/branch1/ivy-2.xml").exists());
}
+ @Test
public void testInstallWithNamespace() {
project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
install.setOrganisation("systemorg");
@@ -267,6 +288,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/systemorg/systemmod/ivy-1.0.xml").exists());
}
+ @Test
public void testInstallWithNamespace2() {
project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
install.setOrganisation("A");
@@ -284,6 +306,7 @@ public class IvyInstallTest extends TestCase {
}
}
+ @Test
public void testInstallWithNamespace3() {
project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
install.setOrganisation("*");
@@ -299,6 +322,7 @@ public class IvyInstallTest extends TestCase {
assertTrue(new File("build/test/install/systemorg/systemmod/ivy-1.0.xml").exists());
}
+ @Test
public void testDependencyNotFoundFailure() {
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
install.setOrganisation("xxx");
@@ -315,6 +339,7 @@ public class IvyInstallTest extends TestCase {
}
}
+ @Test
public void testDependencyNotFoundSuccess() {
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
install.setOrganisation("xxx");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyListModulesTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyListModulesTest.java b/test/java/org/apache/ivy/ant/IvyListModulesTest.java
index 9fd62e9..fbb1d0e 100644
--- a/test/java/org/apache/ivy/ant/IvyListModulesTest.java
+++ b/test/java/org/apache/ivy/ant/IvyListModulesTest.java
@@ -18,15 +18,21 @@
package org.apache.ivy.ant;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
-public class IvyListModulesTest extends TestCase {
+public class IvyListModulesTest {
private IvyListModules findModules;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -35,10 +41,12 @@ public class IvyListModulesTest extends TestCase {
findModules.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testExact() throws Exception {
findModules.setOrganisation("org1");
findModules.setModule("mod1.1");
@@ -49,6 +57,7 @@ public class IvyListModulesTest extends TestCase {
assertEquals("org1/mod1.1/1.0", findModules.getProject().getProperty("found"));
}
+ @Test
public void testAllRevs() throws Exception {
findModules.setOrganisation("org1");
findModules.setModule("mod1.1");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java b/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
index 54cfc04..295fc1c 100644
--- a/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
+++ b/test/java/org/apache/ivy/ant/IvyPostResolveTaskTest.java
@@ -22,19 +22,25 @@ import java.io.File;
import org.apache.ivy.TestHelper;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.util.CacheCleaner;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
-public class IvyPostResolveTaskTest extends TestCase {
+public class IvyPostResolveTaskTest {
private File cache;
private IvyPostResolveTask task;
private Project project;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
createCache();
project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -53,10 +59,12 @@ public class IvyPostResolveTaskTest extends TestCase {
cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
CacheCleaner.deleteDir(cache);
}
+ @Test
public void testWithPreviousResolveInSameBuildAndLessConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -75,6 +83,7 @@ public class IvyPostResolveTaskTest extends TestCase {
reportAfter);
}
+ @Test
public void testWithPreviousResolveInSameBuildAndSameConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -93,6 +102,7 @@ public class IvyPostResolveTaskTest extends TestCase {
reportAfter);
}
+ @Test
public void testWithPreviousResolveInSameBuildAndWildcard() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -111,6 +121,7 @@ public class IvyPostResolveTaskTest extends TestCase {
reportAfter);
}
+ @Test
public void testWithPreviousResolveInSameBuildAndBothWildcard() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -129,6 +140,7 @@ public class IvyPostResolveTaskTest extends TestCase {
reportAfter);
}
+ @Test
public void testWithPreviousResolveInSameBuildAndMoreConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -150,6 +162,7 @@ public class IvyPostResolveTaskTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testWithoutKeep() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -172,6 +185,7 @@ public class IvyPostResolveTaskTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testInlineWithoutKeep() throws Exception {
task.setOrganisation("org1");
task.setModule("mod1.1");
@@ -187,6 +201,7 @@ public class IvyPostResolveTaskTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testInlineWithKeep() throws Exception {
task.setOrganisation("org1");
task.setModule("mod1.1");
@@ -203,6 +218,7 @@ public class IvyPostResolveTaskTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testWithResolveIdAndPreviousResolveInSameBuildAndLessConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -237,6 +253,7 @@ public class IvyPostResolveTaskTest extends TestCase {
report2);
}
+ @Test
public void testWithResolveIdAndPreviousResolveInSameBuildAndSameConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -271,6 +288,7 @@ public class IvyPostResolveTaskTest extends TestCase {
report2);
}
+ @Test
public void testWithResolveIdAndPreviousResolveInSameBuildAndWildcard() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -305,6 +323,7 @@ public class IvyPostResolveTaskTest extends TestCase {
report2);
}
+ @Test
public void testWithResolveIdAndPreviousResolveInSameBuildAndBothWildcard() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
@@ -339,6 +358,7 @@ public class IvyPostResolveTaskTest extends TestCase {
report2);
}
+ @Test
public void testWithResolveIdAndPreviousResolveInSameBuildAndMoreConfs() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyPublishTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyPublishTest.java b/test/java/org/apache/ivy/ant/IvyPublishTest.java
index 2020824..4cad340 100644
--- a/test/java/org/apache/ivy/ant/IvyPublishTest.java
+++ b/test/java/org/apache/ivy/ant/IvyPublishTest.java
@@ -31,21 +31,27 @@ import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
import org.apache.ivy.util.DefaultMessageLogger;
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Delete;
import org.apache.tools.ant.taskdefs.Echo;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
-public class IvyPublishTest extends TestCase {
+public class IvyPublishTest {
private File cache;
private IvyPublish publish;
private Project project;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
cleanTestDir();
cleanRep();
createCache();
@@ -66,7 +72,8 @@ public class IvyPublishTest extends TestCase {
cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
cleanCache();
cleanTestDir();
cleanRep();
@@ -88,6 +95,7 @@ public class IvyPublishTest extends TestCase {
del.execute();
}
+ @Test
public void testMergeParent() throws IOException, ParseException {
// publish the parent descriptor first, so that it can be found while
// we are reading the child descriptor.
@@ -126,6 +134,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-merged.xml")));
@@ -134,7 +143,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -147,6 +156,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testMergeParentWithoutPublishingParent() throws IOException, ParseException {
// here we directly publish a module extending ivy-multiconf.xml,
// the module parent is not published not yet in cache
@@ -174,6 +184,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-merged.xml")));
@@ -182,7 +193,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -195,8 +206,9 @@ public class IvyPublishTest extends TestCase {
}
}
- public void testMergeParentWithoutPublishingParentForceDeliver() throws IOException,
- ParseException {
+ @Test
+ public void testMergeParentWithoutPublishingParentForceDeliver()
+ throws IOException, ParseException {
// here we directly publish a module extending ivy-multiconf.xml,
// the module parent is not published not yet in cache
// See : IVY-1248
@@ -228,6 +240,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-merged.xml")));
@@ -236,7 +249,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -249,6 +262,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testMergeParentWithoutLocationAttribute() throws IOException, ParseException {
// See : IVY-XXX
@@ -276,6 +290,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("extends/child1/ivy-child1-merged.xml")));
@@ -284,7 +299,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -297,6 +312,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testMinimalMerge() throws IOException, ParseException {
// publish the parent descriptor first, so that it can be found while
// we are reading the child descriptor.
@@ -334,6 +350,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-minimal-merged.xml")));
@@ -342,7 +359,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -355,6 +372,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testMergeExtraAttributes() throws IOException, ParseException {
// publish the parent descriptor first, so that it can be found while
// we are reading the child descriptor.
@@ -398,6 +416,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-extra-attributes-merged.xml")));
@@ -406,7 +425,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -419,6 +438,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testMergeExtraAttributesFromParent() throws IOException, ParseException {
// publish the parent descriptor first, so that it can be found while
// we are reading the child descriptor.
@@ -463,6 +483,7 @@ public class IvyPublishTest extends TestCase {
int lineNo = 1;
+ @SuppressWarnings("resource")
BufferedReader merged = new BufferedReader(new FileReader(published));
BufferedReader expected = new BufferedReader(new InputStreamReader(getClass()
.getResourceAsStream("ivy-extends-extra-attributes-merged.xml")));
@@ -471,7 +492,7 @@ public class IvyPublishTest extends TestCase {
.readLine()) {
// strip timestamps for the comparison
- if (mergeLine.indexOf("<info") >= 0) {
+ if (mergeLine.contains("<info")) {
mergeLine = mergeLine.replaceFirst("\\s?publication=\"\\d+\"", "");
}
// discard whitespace-only lines
@@ -484,6 +505,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testSimple() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
IvyResolve res = new IvyResolve();
@@ -512,6 +534,7 @@ public class IvyPublishTest extends TestCase {
assertEquals("1.2", md.getModuleRevisionId().getRevision());
}
+ @Test
public void testHaltOnMissing() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
IvyResolve res = new IvyResolve();
@@ -525,8 +548,8 @@ public class IvyPublishTest extends TestCase {
publish.execute();
fail("publish with haltonmissing and a missing artifact should raise an exception");
} catch (BuildException ex) {
- assertTrue(ex.getMessage().indexOf("missing") != -1);
- assertTrue(ex.getMessage().indexOf("resolve-simple.jar") != -1);
+ assertTrue(ex.getMessage().contains("missing"));
+ assertTrue(ex.getMessage().contains("resolve-simple.jar"));
// should have do the ivy delivering
assertTrue(new File("build/test/publish/ivy-1.2.xml").exists());
@@ -539,6 +562,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testHaltOnMissing2() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-publish-multi.xml");
IvyResolve res = new IvyResolve();
@@ -556,8 +580,8 @@ public class IvyPublishTest extends TestCase {
publish.execute();
fail("publish with haltonmissing and a missing artifact should raise an exception");
} catch (BuildException ex) {
- assertTrue(ex.getMessage().indexOf("missing") != -1);
- assertTrue(ex.getMessage().indexOf("multi2.jar") != -1);
+ assertTrue(ex.getMessage().contains("missing"));
+ assertTrue(ex.getMessage().contains("multi2.jar"));
// should have do the ivy delivering
assertTrue(new File("build/test/publish/ivy-1.2.xml").exists());
@@ -567,6 +591,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testHaltOnMissing3() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-publish-multi.xml");
IvyResolve res = new IvyResolve();
@@ -584,8 +609,8 @@ public class IvyPublishTest extends TestCase {
publish.execute();
fail("publish with haltonmissing and a missing artifact should raise an exception");
} catch (BuildException ex) {
- assertTrue(ex.getMessage().indexOf("missing") != -1);
- assertTrue(ex.getMessage().indexOf("multi2.jar") != -1);
+ assertTrue(ex.getMessage().contains("missing"));
+ assertTrue(ex.getMessage().contains("multi2.jar"));
// should have do the ivy delivering
assertTrue(new File("build/test/publish/ivy-1.2.xml").exists());
@@ -595,6 +620,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testPublishNotAllConfigs() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
IvyResolve res = new IvyResolve();
@@ -630,6 +656,7 @@ public class IvyPublishTest extends TestCase {
assertEquals("Compile configuration not present", "compile", configs[0]);
}
+ @Test
public void testMultiPatterns() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-publish-multi.xml");
IvyResolve res = new IvyResolve();
@@ -655,6 +682,7 @@ public class IvyPublishTest extends TestCase {
assertTrue(new File("test/repositories/1/apache/multi/jars/multi2-1.2.jar").exists());
}
+ @Test
public void testPublishPublicConfigsByWildcard() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-publish-public.xml");
IvyResolve res = new IvyResolve();
@@ -678,6 +706,7 @@ public class IvyPublishTest extends TestCase {
.exists());
}
+ @Test
public void testCustom() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-custom.xml");
IvyResolve res = new IvyResolve();
@@ -720,6 +749,7 @@ public class IvyPublishTest extends TestCase {
}
+ @Test
public void testNoDeliver() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();
@@ -754,6 +784,7 @@ public class IvyPublishTest extends TestCase {
.getRevision());
}
+ @Test
public void testNoDeliverWithBranch() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();
@@ -791,6 +822,7 @@ public class IvyPublishTest extends TestCase {
.getRevision());
}
+ @Test
public void testForceDeliver() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();
@@ -822,6 +854,7 @@ public class IvyPublishTest extends TestCase {
assertEquals("1.3", md.getModuleRevisionId().getRevision());
}
+ @Test
public void testBadNoDeliver() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();
@@ -845,6 +878,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testReadonly() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
IvyResolve res = new IvyResolve();
@@ -885,6 +919,7 @@ public class IvyPublishTest extends TestCase {
}
}
+ @Test
public void testOverwrite() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
IvyResolve res = new IvyResolve();
@@ -920,6 +955,7 @@ public class IvyPublishTest extends TestCase {
reader.close();
}
+ @Test
public void testOverwriteReadOnly() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
IvyResolve res = new IvyResolve();
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyReportTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyReportTest.java b/test/java/org/apache/ivy/ant/IvyReportTest.java
index 445b82c..77c69eb 100644
--- a/test/java/org/apache/ivy/ant/IvyReportTest.java
+++ b/test/java/org/apache/ivy/ant/IvyReportTest.java
@@ -22,17 +22,23 @@ import java.util.Locale;
import org.apache.ivy.TestHelper;
import org.apache.ivy.util.FileUtil;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
-public class IvyReportTest extends TestCase {
+public class IvyReportTest {
private IvyReport report;
private Project project;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -43,10 +49,12 @@ public class IvyReportTest extends TestCase {
System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath());
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testSimple() throws Exception {
Locale oldLocale = Locale.getDefault();
@@ -70,6 +78,7 @@ public class IvyReportTest extends TestCase {
}
}
+ @Test
public void testWithLatest() throws Exception {
Locale oldLocale = Locale.getDefault();
@@ -99,6 +108,7 @@ public class IvyReportTest extends TestCase {
}
}
+ @Test
public void testCopyCssIfTodirNotSet() {
Locale oldLocale = Locale.getDefault();
@@ -123,6 +133,7 @@ public class IvyReportTest extends TestCase {
}
}
+ @Test
public void testNoRevisionInOutputPattern() throws Exception {
Locale oldLocale = Locale.getDefault();
@@ -147,6 +158,7 @@ public class IvyReportTest extends TestCase {
}
}
+ @Test
public void testMultipleConfigurations() throws Exception {
Locale oldLocale = Locale.getDefault();
@@ -171,6 +183,7 @@ public class IvyReportTest extends TestCase {
}
}
+ @Test
public void testRegularCircular() throws Exception {
Locale oldLocale = Locale.getDefault();
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java b/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
index a8999d1..ad98db9 100644
--- a/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
+++ b/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
@@ -23,15 +23,21 @@ import java.io.FileReader;
import org.apache.ivy.TestHelper;
import org.apache.ivy.util.FileUtil;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
-public class IvyRepositoryReportTest extends TestCase {
+public class IvyRepositoryReportTest {
private IvyRepositoryReport report;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings-1.xml");
@@ -41,10 +47,12 @@ public class IvyRepositoryReportTest extends TestCase {
System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath());
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testSimple() throws Exception {
report.setOrganisation("org1");
report.setOutputname("testsimple");
@@ -56,14 +64,15 @@ public class IvyRepositoryReportTest extends TestCase {
String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
// check presence of the modules
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.2\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.3\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.4\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.5\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.6\"") != -1);
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.1\""));
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.2\""));
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.3\""));
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.4\""));
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.5\""));
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.6\""));
}
+ @Test
public void testBranchBeforeModule() throws Exception {
report.getProject().setProperty("ivy.settings.file",
"test/repositories/IVY-716/ivysettings.xml");
@@ -76,13 +85,14 @@ public class IvyRepositoryReportTest extends TestCase {
String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
// check presence of the modules
- assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);
+ assertTrue(g.contains("<module organisation=\"org1\" name=\"mod1.1\""));
// check presence of the branches
- assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch1\"") != -1);
- assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch2\"") != -1);
+ assertTrue(g.contains("<revision name=\"1.0\" branch=\"branch1\""));
+ assertTrue(g.contains("<revision name=\"1.0\" branch=\"branch2\""));
}
+ @Test
public void testPatternWithoutOrganisation() throws Exception {
report.getProject().setProperty("ivy.settings.file",
"test/repositories/IVY-729/ivysettings.xml");
@@ -95,8 +105,8 @@ public class IvyRepositoryReportTest extends TestCase {
String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
// check presence of the modules
- assertTrue(g.indexOf("<module organisation=\"null\" name=\"a\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"null\" name=\"b\"") != -1);
- assertTrue(g.indexOf("<module organisation=\"null\" name=\"c\"") != -1);
+ assertTrue(g.contains("<module organisation=\"null\" name=\"a\""));
+ assertTrue(g.contains("<module organisation=\"null\" name=\"b\""));
+ assertTrue(g.contains("<module organisation=\"null\" name=\"c\""));
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyResolveTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyResolveTest.java b/test/java/org/apache/ivy/ant/IvyResolveTest.java
index c619949..ff1a466 100644
--- a/test/java/org/apache/ivy/ant/IvyResolveTest.java
+++ b/test/java/org/apache/ivy/ant/IvyResolveTest.java
@@ -23,19 +23,26 @@ import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ResolveReport;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Parallel;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
-public class IvyResolveTest extends TestCase {
+public class IvyResolveTest {
private Project project;
private IvyResolve resolve;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -45,10 +52,12 @@ public class IvyResolveTest extends TestCase {
resolve.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
+ @Test
public void testIVY1455() throws Exception {
project.setProperty("ivy.settings.file", "test/repositories/IVY-1455/ivysettings.xml");
resolve.setFile(new File("test/repositories/IVY-1455/ivy.xml"));
@@ -56,7 +65,9 @@ public class IvyResolveTest extends TestCase {
}
/* disabled: Ivy is not thread-safe, and this usage is not supported at this time */
- public void disabledIVY1454() throws Exception {
+ @Test
+ @Ignore
+ public void disabledIVY1454() {
// run init in parent thread, then resolve in children
project.setProperty("ivy.settings.file", "test/repositories/ivysettings-with-nio.xml");
project.setProperty("ivy.log.locking", "true");
@@ -71,6 +82,7 @@ public class IvyResolveTest extends TestCase {
parallel.execute();
}
+ @Test
public void testIVY779() throws Exception {
Project project = TestHelper.newProject();
project.setProperty("ivy.local.default.root",
@@ -90,6 +102,7 @@ public class IvyResolveTest extends TestCase {
assertEquals(1, report.getArtifacts().size());
}
+ @Test
public void testSimple() throws Exception {
// depends on org="org1" name="mod1.2" rev="2.0"
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
@@ -104,6 +117,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testResolveWithoutIvyFile() throws Exception {
// IVY-630
resolve.getProject().setProperty("ivy.settings.file",
@@ -133,6 +147,7 @@ public class IvyResolveTest extends TestCase {
return getIvy().getResolutionCacheManager().getResolvedIvyFileInCache(id);
}
+ @Test
public void testInline() throws Exception {
// same as before, but expressing dependency directly without ivy file
resolve.setOrganisation("org1");
@@ -147,6 +162,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testInlineWithResolveId() throws Exception {
// same as before, but expressing dependency directly without ivy file
resolve.setOrganisation("org1");
@@ -163,6 +179,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testInlineForNonExistingModule() throws Exception {
resolve.setOrganisation("org1XX");
resolve.setModule("mod1.2");
@@ -174,10 +191,10 @@ public class IvyResolveTest extends TestCase {
// the resolve must have failed -> the failure property must be set
String failure = resolve.getProject().getProperty("failure.property");
- assertTrue("Failure property must have been specified!", Boolean.valueOf(failure)
- .booleanValue());
+ assertTrue("Failure property must have been specified!", Boolean.valueOf(failure));
}
+ @Test
public void testWithSlashes() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/core/resolve/ivy-198.xml"));
resolve.execute();
@@ -197,6 +214,7 @@ public class IvyResolveTest extends TestCase {
"jar", "jar").exists());
}
+ @Test
public void testDepsChanged() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.execute();
@@ -208,6 +226,7 @@ public class IvyResolveTest extends TestCase {
assertEquals("false", getIvy().getVariable("ivy.deps.changed"));
}
+ @Test
public void testDontCheckIfChanged() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setCheckIfChanged(false);
@@ -219,6 +238,7 @@ public class IvyResolveTest extends TestCase {
// but this would require a too big refactoring to inject a mock object
}
+ @Test
public void testConflictingDepsChanged() throws Exception {
resolve.setFile(new File("test/repositories/2/mod4.1/ivy-4.1.xml"));
resolve.execute();
@@ -230,6 +250,7 @@ public class IvyResolveTest extends TestCase {
assertEquals("false", getIvy().getVariable("ivy.deps.changed"));
}
+ @Test
public void testDouble() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.execute();
@@ -244,6 +265,7 @@ public class IvyResolveTest extends TestCase {
assertEquals("1.1", getIvy().getVariable("ivy.revision"));
}
+ @Test
public void testFailure() throws Exception {
try {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-failure.xml"));
@@ -254,6 +276,7 @@ public class IvyResolveTest extends TestCase {
}
}
+ @Test
public void testIvyLogModulesInUseWithFailure() throws Exception {
resolve.getProject().setProperty("ivy.log.modules.in.use", "true");
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-failure.xml"));
@@ -263,6 +286,7 @@ public class IvyResolveTest extends TestCase {
// we did manage to get here, so no NPE has been thrown (IVY-961)
}
+ @Test
public void testFailureWithMissingConfigurations() throws Exception {
try {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
@@ -270,10 +294,11 @@ public class IvyResolveTest extends TestCase {
resolve.execute();
fail("missing configurations didn't raised an exception");
} catch (BuildException ex) {
- assertTrue(ex.getMessage().indexOf("unknown") != -1);
+ assertTrue(ex.getMessage().contains("unknown"));
}
}
+ @Test
public void testFailureOnBadDependencyIvyFile() throws Exception {
try {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-failure2.xml"));
@@ -284,6 +309,7 @@ public class IvyResolveTest extends TestCase {
}
}
+ @Test
public void testFailureOnBadStatusInDependencyIvyFile() throws Exception {
try {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-failure3.xml"));
@@ -294,6 +320,7 @@ public class IvyResolveTest extends TestCase {
}
}
+ @Test
public void testHaltOnFailure() throws Exception {
try {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-failure.xml"));
@@ -305,6 +332,7 @@ public class IvyResolveTest extends TestCase {
}
}
+ @Test
public void testWithResolveId() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setResolveId("testWithResolveId");
@@ -343,6 +371,7 @@ public class IvyResolveTest extends TestCase {
assertNotNull(project.getReference("ivy.resolved.configurations.ref.testWithResolveId"));
}
+ @Test
public void testDoubleResolveWithResolveId() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setResolveId("testWithResolveId");
@@ -376,6 +405,7 @@ public class IvyResolveTest extends TestCase {
assertNotNull(project.getReference("ivy.resolved.configurations.ref.testWithResolveId"));
}
+ @Test
public void testDifferentResolveWithSameResolveId() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setResolveId("testWithResolveId");
@@ -410,6 +440,7 @@ public class IvyResolveTest extends TestCase {
assertNotNull(project.getReference("ivy.resolved.configurations.ref.testWithResolveId"));
}
+ @Test
public void testExcludedConf() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
resolve.setConf("*,!default");
@@ -422,9 +453,10 @@ public class IvyResolveTest extends TestCase {
// test the properties
Project project = resolve.getProject();
- assertFalse(project.getProperty("ivy.resolved.configurations").indexOf("default") > -1);
+ assertFalse(project.getProperty("ivy.resolved.configurations").contains("default"));
}
+ @Test
public void testResolveWithAbsoluteFile() {
// IVY-396
File ivyFile = new File("test/java/org/apache/ivy/ant/ivy-simple.xml");
@@ -435,6 +467,7 @@ public class IvyResolveTest extends TestCase {
ModuleRevisionId.newInstance("apache", "resolve-simple", "1.0")).exists());
}
+ @Test
public void testResolveWithRelativeFile() {
// IVY-396
resolve.getProject().setProperty("ivy.dep.file",
@@ -449,6 +482,7 @@ public class IvyResolveTest extends TestCase {
return resolve.getIvyInstance();
}
+ @Test
public void testChildsSimple() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -460,6 +494,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
+ @Test
public void testChildsMultiple() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -480,6 +515,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
}
+ @Test
public void testChildsMultipleWithConf() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -499,6 +535,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.7", "mod2.1", "jar", "jar").exists());
}
+ @Test
public void testChildsMultipleWithConf2() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -519,6 +556,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
}
+ @Test
public void testChildsExclude() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -542,6 +580,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.7", "mod2.1", "jar", "jar").exists());
}
+ @Test
public void testChildsDependencyExclude() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -564,6 +603,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.7", "mod2.1", "jar", "jar").exists());
}
+ @Test
public void testChildsDependencyInclude() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -584,6 +624,7 @@ public class IvyResolveTest extends TestCase {
assertTrue(getArchiveFileInCache("org2", "mod2.2", "0.9", "art22-1", "jar", "jar").exists());
}
+ @Test
public void testChildsFail() throws Exception {
IvyDependency dependency = resolve.createDependency();
dependency.setOrg("org1");
@@ -598,6 +639,7 @@ public class IvyResolveTest extends TestCase {
}
}
+ @Test
public void testSimpleExtends() throws Exception {
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-extends-multiconf.xml"));
resolve.execute();
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyResourcesTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyResourcesTest.java b/test/java/org/apache/ivy/ant/IvyResourcesTest.java
index afc3590..bd3cbfc 100644
--- a/test/java/org/apache/ivy/ant/IvyResourcesTest.java
+++ b/test/java/org/apache/ivy/ant/IvyResourcesTest.java
@@ -24,17 +24,25 @@ import java.util.List;
import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.resources.FileResource;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-public class IvyResourcesTest extends TestCase {
+public class IvyResourcesTest {
private IvyResources resources;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
TestHelper.createCache();
Project project = TestHelper.newProject();
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
@@ -44,7 +52,8 @@ public class IvyResourcesTest extends TestCase {
resources.setProject(project);
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
TestHelper.cleanCache();
}
@@ -69,6 +78,7 @@ public class IvyResourcesTest extends TestCase {
return resources;
}
+ @Test
public void testSimple() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -81,6 +91,7 @@ public class IvyResourcesTest extends TestCase {
files.get(0));
}
+ @Test
public void testMultiple() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -106,6 +117,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testMultipleWithConf() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -128,6 +140,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testMultipleWithConf2() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -152,6 +165,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testExclude() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -178,6 +192,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testDependencyExclude() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -203,6 +218,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testDependencyInclude() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
@@ -225,6 +241,7 @@ public class IvyResourcesTest extends TestCase {
"jar")));
}
+ @Test
public void testFail() throws Exception {
IvyDependency dependency = resources.createDependency();
dependency.setOrg("org1");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyRetrieveBuildFileTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyRetrieveBuildFileTest.java b/test/java/org/apache/ivy/ant/IvyRetrieveBuildFileTest.java
index 19fd00c..6dc3b20 100644
--- a/test/java/org/apache/ivy/ant/IvyRetrieveBuildFileTest.java
+++ b/test/java/org/apache/ivy/ant/IvyRetrieveBuildFileTest.java
@@ -18,17 +18,30 @@
package org.apache.ivy.ant;
import org.apache.ivy.core.report.ResolveReport;
-import org.apache.tools.ant.BuildFileTest;
-public class IvyRetrieveBuildFileTest extends BuildFileTest {
+import org.apache.tools.ant.BuildFileRule;
- protected void setUp() throws Exception {
- configureProject("test/java/org/apache/ivy/ant/IvyRetrieveBuildFile.xml");
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+public class IvyRetrieveBuildFileTest {
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
+ public void setUp() {
+ buildRule.configureProject("test/java/org/apache/ivy/ant/IvyRetrieveBuildFile.xml");
}
+ @Test
public void testMultipleInlineRetrievesWithCacheCleaning() {
- executeTarget("testMultipleInlineRetrievesWithCacheCleaning");
- ResolveReport report = (ResolveReport) getProject().getReference("ivy.resolved.report");
+ buildRule.executeTarget("testMultipleInlineRetrievesWithCacheCleaning");
+ ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report");
assertNotNull(report);
assertFalse(report.hasError());
assertEquals(1, report.getDependencies().size());
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyRetrieveTest.java b/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
index 2a913ff..c57adfe 100644
--- a/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
+++ b/test/java/org/apache/ivy/ant/IvyRetrieveTest.java
@@ -23,12 +23,19 @@ import java.io.IOException;
import org.apache.ivy.TestHelper;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.util.CacheCleaner;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-public class IvyRetrieveTest extends TestCase {
+public class IvyRetrieveTest {
private static final String IVY_RETRIEVE_PATTERN = "build/test/lib/[organisation]/[module]/ivy-[revision].xml";
private static final String RETRIEVE_PATTERN = "build/test/lib/[conf]/[artifact]-[revision].[type]";
@@ -39,7 +46,8 @@ public class IvyRetrieveTest extends TestCase {
private Project project;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() {
createCache();
CacheCleaner.deleteDir(new File("build/test/lib"));
project = TestHelper.newProject();
@@ -56,11 +64,13 @@ public class IvyRetrieveTest extends TestCase {
cache.mkdirs();
}
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
CacheCleaner.deleteDir(cache);
CacheCleaner.deleteDir(new File("build/test/lib"));
}
+ @Test
public void testSimple() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
retrieve.execute();
@@ -68,6 +78,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar")).exists());
}
+ @Test
public void testRetrievePrivateWithWildcard() throws Exception {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-381.xml");
retrieve.setConf("*");
@@ -78,6 +89,7 @@ public class IvyRetrieveTest extends TestCase {
"mod3.2", "jar", "jar", "private")).exists());
}
+ @Test
public void testValidateInIvySettings() throws Exception {
// cfr IVY-992
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest-extra.xml");
@@ -88,6 +100,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar", "default")).exists());
}
+ @Test
public void testInline() throws Exception {
// we first resolve another ivy file
IvyResolve resolve = new IvyResolve();
@@ -107,6 +120,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar")).exists());
}
+ @Test
public void testWithConf() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
retrieve.execute();
@@ -119,6 +133,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar", "extension")).exists());
}
+ @Test
public void testSync() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
retrieve.setSync(true);
@@ -133,8 +148,8 @@ public class IvyRetrieveTest extends TestCase {
new File(IvyPatternHelper.substitute(RETRIEVE_PATTERN, "org6", "mod6.1", "unknown",
"mod6.1", "jar", "jar", "default")), // unknown revision
};
- for (int i = 0; i < old.length; i++) {
- touch(old[i]);
+ for (File of : old) {
+ touch(of);
}
retrieve.execute();
@@ -144,13 +159,14 @@ public class IvyRetrieveTest extends TestCase {
"mod6.1", "jar", "jar", "extension")).exists());
assertTrue(new File(IvyPatternHelper.substitute(RETRIEVE_PATTERN, "org1", "mod1.2", "2.1",
"mod1.2", "jar", "jar", "extension")).exists());
- for (int i = 0; i < old.length; i++) {
- assertFalse(old[i] + " should have been deleted by sync", old[i].exists());
+ for (File of : old) {
+ assertFalse(of + " should have been deleted by sync", of.exists());
}
assertFalse(new File("build/test/lib/unknown").exists()); // even conf directory should
// have been deleted
}
+ @Test
public void testSyncWithIgnoreList() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
retrieve.setSync(true);
@@ -164,6 +180,7 @@ public class IvyRetrieveTest extends TestCase {
assertTrue(new File("build/test/lib/.svn/test.txt").exists());
}
+ @Test
public void testWithAPreviousResolve() throws Exception {
// first we do a resolve in another project
Project project = TestHelper.newProject();
@@ -183,6 +200,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar")).exists());
}
+ @Test
public void testWithAPreviousResolveAndResolveId() throws Exception {
// first we do a resolve in another project
Project project = TestHelper.newProject();
@@ -204,6 +222,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar")).exists());
}
+ @Test
public void testUseOrigin() throws Exception {
// test case for IVY-304
// first we do a resolve with useOrigin=true in another project
@@ -227,6 +246,7 @@ public class IvyRetrieveTest extends TestCase {
"mod1.2", "jar", "jar")).exists());
}
+ @Test
public void testUseOriginWithIvyPattern() throws Exception {
// mod2.5 depends on virtual mod2.3 which depends on mod2.1 which depends on mod1.1 which
// depends on mod1.2
@@ -248,6 +268,7 @@ public class IvyRetrieveTest extends TestCase {
"ivy", "ivy", "xml")).exists());
}
+ @Test
public void testRetrieveWithOriginalNamePattern() throws Exception {
retrieve.setFile(new File("test/java/org/apache/ivy/ant/ivy-631.xml"));
retrieve.setConf("default");
@@ -258,29 +279,24 @@ public class IvyRetrieveTest extends TestCase {
assertTrue(new File("build/test/lib/default/mod1.2-2.2.jar").exists());
}
+ @Test(expected = BuildException.class)
public void testFailureWithoutAPreviousResolve() throws Exception {
// we do a retrieve with the module information whereas no resolve has been previously done
- try {
- retrieve.setOrganisation("apache");
- retrieve.setModule("resolve-simple");
- retrieve.setConf("default");
- retrieve.execute();
- fail("retrieve without previous resolve should have thrown an exception");
- } catch (Exception ex) {
- // OK
- }
+ retrieve.setOrganisation("apache");
+ retrieve.setModule("resolve-simple");
+ retrieve.setConf("default");
+ retrieve.execute();
+ fail("retrieve without previous resolve should have thrown an exception");
}
+ @Test(expected = BuildException.class)
public void testFailure() throws Exception {
- try {
- project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml");
- retrieve.execute();
- fail("failure didn't raised an exception with default haltonfailure setting");
- } catch (BuildException ex) {
- // ok => should raised an exception
- }
+ project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml");
+ retrieve.execute();
+ fail("failure didn't raised an exception with default haltonfailure setting");
}
+ @Test
public void testHaltOnFailure() throws Exception {
try {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml");
@@ -292,6 +308,7 @@ public class IvyRetrieveTest extends TestCase {
}
}
+ @Test
public void testCustomIvyPattern() throws Exception {
// mod2.5 depends on virtual mod2.3 which depends on mod2.1 which depends on mod1.1 which
// depends on mod1.2
@@ -312,6 +329,7 @@ public class IvyRetrieveTest extends TestCase {
"ivy", "ivy", "xml")).exists());
}
+ @Test
public void testCustomIvyPatternWithConf() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
@@ -328,6 +346,7 @@ public class IvyRetrieveTest extends TestCase {
"ivy", "ivy", "xml", "extension")).exists());
}
+ @Test
public void testSyncWithIvyPattern() throws Exception {
project.setProperty("ivy.dep.file", "test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml");
@@ -347,8 +366,8 @@ public class IvyRetrieveTest extends TestCase {
new File(IvyPatternHelper.substitute(ivyPattern, "unknown", "mod6.1", "0.4", "ivy",
"ivy", "xml", "default")), // unknown organisation for ivy
};
- for (int i = 0; i < old.length; i++) {
- touch(old[i]);
+ for (File of : old) {
+ touch(of);
}
retrieve.execute();
@@ -359,14 +378,15 @@ public class IvyRetrieveTest extends TestCase {
"ivy", "xml", "extension")).exists());
assertFalse(new File(IvyPatternHelper.substitute(ivyPattern, "org1", "mod1.2", "2.1",
"ivy", "ivy", "xml", "extension")).exists());
- for (int i = 0; i < old.length; i++) {
- assertFalse(old[i] + " should have been deleted by sync", old[i].exists());
+ for (File of : old) {
+ assertFalse(of + " should have been deleted by sync", of.exists());
}
assertFalse(new File("build/test/lib/unknown").exists());
assertFalse(new File("build/test/lib/unk").exists());
assertFalse(new File("build/test/lib/default/unknown").exists());
}
+ @Test
public void testDoubleRetrieveWithDifferentConfigurations() {
// IVY-315
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-doubleretrieve.xml");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyTaskTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyTaskTest.java b/test/java/org/apache/ivy/ant/IvyTaskTest.java
index 53c5238..ab23d3e 100644
--- a/test/java/org/apache/ivy/ant/IvyTaskTest.java
+++ b/test/java/org/apache/ivy/ant/IvyTaskTest.java
@@ -23,14 +23,19 @@ import java.net.MalformedURLException;
import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
import org.apache.ivy.core.settings.IvySettings;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Reference;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-public class IvyTaskTest extends TestCase {
+public class IvyTaskTest {
+ @Test
public void testDefaultSettings() throws MalformedURLException {
Project p = TestHelper.newProject();
p.setBasedir("test/repositories");
@@ -60,6 +65,8 @@ public class IvyTaskTest extends TestCase {
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
+ @SuppressWarnings("deprecation")
+ @Test
public void testReferencedSettings() throws MalformedURLException {
Project p = TestHelper.newProject();
p.setProperty("myproperty", "myvalue");
@@ -92,6 +99,7 @@ public class IvyTaskTest extends TestCase {
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
+ @Test
public void testIvyVersionAsAntProperty() {
Project p = TestHelper.newProject();
p.setBasedir("test/repositories");
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyVarTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/IvyVarTest.java b/test/java/org/apache/ivy/ant/IvyVarTest.java
index 05a2f2d..af5be17 100644
--- a/test/java/org/apache/ivy/ant/IvyVarTest.java
+++ b/test/java/org/apache/ivy/ant/IvyVarTest.java
@@ -20,9 +20,13 @@ package org.apache.ivy.ant;
import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class IvyVarTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class IvyVarTest {
+ @Test
public void testSimple() {
IvyVar task = new IvyVar();
task.setProject(TestHelper.newProject());
@@ -34,6 +38,7 @@ public class IvyVarTest extends TestCase {
assertEquals("myvalue", ivy.getVariable("mytest"));
}
+ @Test
public void testPrefix() {
IvyVar task = new IvyVar();
task.setProject(TestHelper.newProject());
@@ -46,6 +51,7 @@ public class IvyVarTest extends TestCase {
assertEquals("myvalue", ivy.getVariable("myprefix.mytest"));
}
+ @Test
public void testURL() {
IvyVar task = new IvyVar();
task.setProject(TestHelper.newProject());
@@ -57,6 +63,7 @@ public class IvyVarTest extends TestCase {
assertEquals("myvalue2", ivy.getVariable("mytest2"));
}
+ @Test
public void testURLPrefix() {
IvyVar task = new IvyVar();
task.setProject(TestHelper.newProject());
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/testutil/AntTaskTestCase.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/ant/testutil/AntTaskTestCase.java b/test/java/org/apache/ivy/ant/testutil/AntTaskTestCase.java
index ecc568a..65ef929 100644
--- a/test/java/org/apache/ivy/ant/testutil/AntTaskTestCase.java
+++ b/test/java/org/apache/ivy/ant/testutil/AntTaskTestCase.java
@@ -18,11 +18,13 @@
package org.apache.ivy.ant.testutil;
import org.apache.ivy.TestHelper;
+
import org.apache.tools.ant.Project;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
-public class AntTaskTestCase extends TestCase {
+public class AntTaskTestCase {
private AntTestListener antTestListener;
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/NormalRelativeUrlResolverTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/NormalRelativeUrlResolverTest.java b/test/java/org/apache/ivy/core/NormalRelativeUrlResolverTest.java
index c96889f..e846fd5 100644
--- a/test/java/org/apache/ivy/core/NormalRelativeUrlResolverTest.java
+++ b/test/java/org/apache/ivy/core/NormalRelativeUrlResolverTest.java
@@ -17,31 +17,37 @@
*/
package org.apache.ivy.core;
+import org.junit.Test;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
-public class NormalRelativeUrlResolverTest extends TestCase {
+public class NormalRelativeUrlResolverTest {
private NormalRelativeUrlResolver t = new NormalRelativeUrlResolver();
+ @Test
public void testRelativeHttpURL() throws MalformedURLException {
URL base = new URL("http://xxx/file.txt");
assertEquals(new URL("http://xxx/file2.txt"), t.getURL(base, "file2.txt"));
}
+ @Test
public void testRelativeFileURL() throws MalformedURLException {
URL base = new URL("file://xxx/file.txt");
assertEquals(new URL("file://xxx/file2.txt"), t.getURL(base, "file2.txt"));
}
+ @Test
public void testRelativeMixedURL() throws MalformedURLException {
URL base = new URL("http://xxx/file.txt");
assertEquals(new URL("file://file2.txt"), t.getURL(base, "file://file2.txt"));
}
+ @Test
public void testFileAndUrlWithAbsoluteFile() throws MalformedURLException {
URL base = new URL("file://xxx/file.txt");
File absFile = new File(".").getAbsoluteFile();
@@ -50,6 +56,7 @@ public class NormalRelativeUrlResolverTest extends TestCase {
assertEquals(absFile.toURI().toURL(), t.getURL(base, absFile.toString(), "somthing.txt"));
}
+ @Test
public void testFileAndUrlWithRelativeFile() throws MalformedURLException {
URL base = new URL("file://xxx/file.txt");
assertEquals(new URL("file://xxx/file2.txt"), t.getURL(base, "file2.txt", null));
@@ -58,6 +65,7 @@ public class NormalRelativeUrlResolverTest extends TestCase {
t.getURL(base, "sub/file2.txt", "something"));
}
+ @Test
public void testFileAndUrlWithAbsoluteUrl() throws MalformedURLException {
URL base = new URL("file://xxx/file.txt");
URL otherBase = new URL("http://localhost:80/otherfile.txt");
@@ -66,6 +74,7 @@ public class NormalRelativeUrlResolverTest extends TestCase {
assertEquals(new URL(absUrl), t.getURL(otherBase, null, absUrl));
}
+ @Test
public void testFileAndUrlWithRelativeUrl() throws MalformedURLException {
URL base = new URL("file://xxx/file.txt");
URL otherBase = new URL("http://localhost:80/otherfile.txt");