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:39 UTC

[06/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/core/TestPerformance.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/TestPerformance.java b/test/java/org/apache/ivy/core/TestPerformance.java
index c380380..29a9176 100644
--- a/test/java/org/apache/ivy/core/TestPerformance.java
+++ b/test/java/org/apache/ivy/core/TestPerformance.java
@@ -34,6 +34,9 @@ import org.apache.ivy.plugins.resolver.FileSystemResolver;
 import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Not a Junit test, performance depends on the machine on which the test is run...
@@ -56,11 +59,13 @@ public class TestPerformance {
         ivy.getSettings().setDefaultResolver("def");
     }
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() {
         TestHelper.createCache();
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         TestHelper.cleanCache();
     }
 
@@ -118,6 +123,7 @@ public class TestPerformance {
         }
     }
 
+    @Test
     public void testPerfs() throws Exception {
         generateModules(70, 2, 5, 2, 15);
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManagerTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManagerTest.java b/test/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManagerTest.java
index 794d5b7..0b29645 100644
--- a/test/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManagerTest.java
+++ b/test/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManagerTest.java
@@ -45,20 +45,26 @@ import org.apache.ivy.util.DefaultMessageLogger;
 import org.apache.ivy.util.Message;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @see DefaultResolutionCacheManager
  */
-public class DefaultRepositoryCacheManagerTest extends TestCase {
+public class DefaultRepositoryCacheManagerTest {
     
     private DefaultRepositoryCacheManager cacheManager;
     private Artifact artifact;
     private ArtifactOrigin origin;
     private Ivy ivy;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         File f = File.createTempFile("ivycache", ".dir");
         ivy = new Ivy();
         ivy.configureDefault();
@@ -81,7 +87,8 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         cacheManager.saveArtifactOrigin(artifact, origin);
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         IvyContext.popContext();
         Delete del = new Delete();
         del.setProject(new Project());
@@ -89,6 +96,7 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         del.execute();
     }
 
+    @Test
     public void testArtifactOrigin() {
         ArtifactOrigin found = cacheManager.getSavedArtifactOrigin(artifact);
         assertEquals(origin, found);
@@ -99,6 +107,7 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         assertTrue(ArtifactOrigin.isUnknown(found));
     }
 
+    @Test
     public void testUniqueness() {
         cacheManager.saveArtifactOrigin(artifact, origin);
 
@@ -127,8 +136,9 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         assertTrue(ArtifactOrigin.isUnknown(found));
     }
 
-    //TODO
-    public void disableTestLatestIntegrationIsCachedPerResolver() throws Exception {
+    @Test
+    @Ignore
+    public void testLatestIntegrationIsCachedPerResolver() throws Exception {
         // given a module org#module
         ModuleId mi = new ModuleId("org", "module");
 
@@ -140,10 +150,10 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         CacheMetadataOptions options = new CacheMetadataOptions().setCheckTTL(false);
 
         // setup resolver1 to download the static content so we can call cacheModuleDescriptor
-        MockResolver resolver1 = new MockResolver();
-        resolver1.setName("resolver1");
-        resolver1.setSettings(ivy.getSettings());
-        ivy.getSettings().addResolver(resolver1);
+        MockResolver resolver = new MockResolver();
+        resolver.setName("resolver1");
+        resolver.setSettings(ivy.getSettings());
+        ivy.getSettings().addResolver(resolver);
         ResourceDownloader downloader = new ResourceDownloader() {
             public void download(Artifact artifact, Resource resource, File dest)
                     throws IOException {
@@ -170,8 +180,8 @@ public class DefaultRepositoryCacheManagerTest extends TestCase {
         ResolvedResource mdRef11 = new ResolvedResource(resource11, "1.1");
 
         // tell the cache about 1.1
-        ResolvedModuleRevision rmr11 = cacheManager.cacheModuleDescriptor(resolver1, mdRef11, dd11, artifact11, downloader, options);
-        cacheManager.originalToCachedModuleDescriptor(resolver1, mdRef11, artifact11, rmr11, writer);
+        ResolvedModuleRevision rmr11 = cacheManager.cacheModuleDescriptor(resolver, mdRef11, dd11, artifact11, downloader, options);
+        cacheManager.originalToCachedModuleDescriptor(resolver, mdRef11, artifact11, rmr11, writer);
         // and use the new overload that passes in resolver name
         cacheManager.saveResolvedRevision("resolver1", mridLatest, "1.1");
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCacheTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCacheTest.java b/test/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCacheTest.java
index 0558a14..36647a0 100644
--- a/test/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCacheTest.java
+++ b/test/java/org/apache/ivy/core/cache/ModuleDescriptorMemoryCacheTest.java
@@ -26,11 +26,13 @@ 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.parser.ParserSettings;
+import org.junit.Test;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-public class ModuleDescriptorMemoryCacheTest extends TestCase {
+
+public class ModuleDescriptorMemoryCacheTest {
 
     ModuleDescriptorMemoryCache cache = new ModuleDescriptorMemoryCache(2);
 
@@ -38,11 +40,11 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
 
     IvySettings ivySettings2 = new IvySettings();
 
-    File url1 = new File("file://cached/file.txt");;
+    File url1 = new File("file://cached/file.txt");
 
-    File url2 = new File("file://cached/file2.txt");;
+    File url2 = new File("file://cached/file2.txt");
 
-    File url3 = new File("file://cached/file3.txt");;
+    File url3 = new File("file://cached/file3.txt");
 
     ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("org", "name", "rev");
 
@@ -56,6 +58,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
 
     ModuleDescriptor md3 = DefaultModuleDescriptor.newDefaultInstance(mrid3);
 
+    @Test
     public void testUseModuleDescriptorProviderWhenModuleNotCached() throws ParseException,
             IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
@@ -63,6 +66,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         providerMock.assertCalled();
     }
 
+    @Test
     public void testCacheResultOfModuleDescriptorProvider() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = null;
@@ -70,15 +74,16 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         assertEquals(md1, cache.get(url1, ivySettings, false, providerMock2));
     }
 
+    @Test
     public void testValidationClearInvalidatedCache() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = new ModuleDescriptorProviderMock(md1);
-        ;
         assertEquals(md1, cache.get(url1, ivySettings, false, providerMock));
         assertEquals(md1, cache.get(url1, ivySettings, true, providerMock2));
         providerMock2.assertCalled();
     }
 
+    @Test
     public void testValidationDontClearvalidatedCache() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = null;
@@ -86,7 +91,8 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         assertEquals(md1, cache.get(url1, ivySettings, false, providerMock2));
     }
 
-    public void testSizeIsLimitied() throws ParseException, IOException {
+    @Test
+    public void testSizeIsLimited() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock1b = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = new ModuleDescriptorProviderMock(md2);
@@ -98,6 +104,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         providerMock1b.assertCalled();
     }
 
+    @Test
     public void testLastRecentlyUsedIsFlushedWhenSizeExceed() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = new ModuleDescriptorProviderMock(md2);
@@ -112,6 +119,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         providerMock2b.assertCalled();
     }
 
+    @Test
     public void testVariableChangeInvalidateEntry() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = new ModuleDescriptorProviderMock(md1);
@@ -121,6 +129,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         providerMock2.assertCalled();
     }
 
+    @Test
     public void testGetStaleDontReadFromCache() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = new ModuleDescriptorProviderMock(md2);
@@ -129,6 +138,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         providerMock2.assertCalled();
     }
 
+    @Test
     public void testGetStaleStoreResultInCache() throws ParseException, IOException {
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
         ModuleDescriptorProviderMock providerMock2 = null;
@@ -136,6 +146,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         assertEquals(md1, cache.get(url1, ivySettings, false, providerMock2));
     }
 
+    @Test
     public void testASizeOf0MeansNoCache() throws ParseException, IOException {
         cache = new ModuleDescriptorMemoryCache(0);
         ModuleDescriptorProviderMock providerMock = new ModuleDescriptorProviderMock(md1);
@@ -165,7 +176,7 @@ public class ModuleDescriptorMemoryCacheTest extends TestCase {
         }
 
         public void assertCalled() {
-            Assert.assertTrue(called);
+            assertTrue(called);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/deliver/DeliverTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/deliver/DeliverTest.java b/test/java/org/apache/ivy/core/deliver/DeliverTest.java
index fa6b240..8ee0e57 100644
--- a/test/java/org/apache/ivy/core/deliver/DeliverTest.java
+++ b/test/java/org/apache/ivy/core/deliver/DeliverTest.java
@@ -28,17 +28,21 @@ import org.apache.ivy.ant.IvyDeliver;
 import org.apache.ivy.ant.IvyResolve;
 import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.Project;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
 
-public class DeliverTest extends TestCase {
+public class DeliverTest {
     private File cache;
 
     private File deliverDir;
 
     private IvyDeliver ivyDeliver;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() {
         cache = new File("build/cache");
         System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
         createCache();
@@ -55,7 +59,8 @@ public class DeliverTest extends TestCase {
                 + "/[type]s/[artifact]-[revision](-[classifier]).[ext]");
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         FileUtil.forceDelete(cache);
         FileUtil.forceDelete(deliverDir);
     }
@@ -64,6 +69,7 @@ public class DeliverTest extends TestCase {
         cache.mkdirs();
     }
 
+    @Test
     public void testIVY1111() throws Exception {
         Project project = ivyDeliver.getProject();
         project.setProperty("ivy.settings.file", "test/repositories/IVY-1111/ivysettings.xml");
@@ -75,8 +81,8 @@ public class DeliverTest extends TestCase {
         ivyDeliver.doExecute();
 
         String deliverContent = readFile(deliverDir.getAbsolutePath() + "/ivys/ivy-1.0.xml");
-        assertTrue(deliverContent.indexOf("rev=\"latest.integration\"") == -1);
-        assertTrue(deliverContent.indexOf("name=\"b\" rev=\"1.5\"") >= 0);
+        assertTrue(!deliverContent.contains("rev=\"latest.integration\""));
+        assertTrue(deliverContent.contains("name=\"b\" rev=\"1.5\""));
     }
 
     private void resolve(File ivyFile) {
@@ -87,14 +93,14 @@ public class DeliverTest extends TestCase {
     }
 
     private String readFile(String fileName) throws IOException {
-        StringBuffer retval = new StringBuffer();
+        StringBuilder retval = new StringBuilder();
 
         File ivyFile = new File(fileName);
         BufferedReader reader = new BufferedReader(new FileReader(ivyFile));
 
         String line = null;
         while ((line = reader.readLine()) != null) {
-            retval.append(line + "\n");
+            retval.append(line).append("\n");
         }
 
         reader.close();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/event/IvyEventFilterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/event/IvyEventFilterTest.java b/test/java/org/apache/ivy/core/event/IvyEventFilterTest.java
index 2dcbac2..688b6af 100644
--- a/test/java/org/apache/ivy/core/event/IvyEventFilterTest.java
+++ b/test/java/org/apache/ivy/core/event/IvyEventFilterTest.java
@@ -25,10 +25,13 @@ import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-public class IvyEventFilterTest extends TestCase {
+public class IvyEventFilterTest {
 
     private ModuleDescriptor md = null;
 
@@ -38,6 +41,7 @@ public class IvyEventFilterTest extends TestCase {
 
     private ModuleDescriptor md4 = null;
 
+    @Before
     public void setUp() throws Exception {
         md = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo", "bar", "1.0"),
                 "integration", new Date());
@@ -49,6 +53,7 @@ public class IvyEventFilterTest extends TestCase {
                 "integration", new Date());
     }
 
+    @Test
     public void testSimple() {
         IvyEventFilter f = new IvyEventFilter("pre-resolve", null, null);
 
@@ -57,6 +62,7 @@ public class IvyEventFilterTest extends TestCase {
                 new ResolveReport(md))));
     }
 
+    @Test
     public void testSimpleExpression() {
         IvyEventFilter f = new IvyEventFilter("pre-resolve", "organisation = foo", null);
 
@@ -79,6 +85,7 @@ public class IvyEventFilterTest extends TestCase {
         assertTrue(f.accept(new StartResolveEvent(md4, new String[] {"default"})));
     }
 
+    @Test
     public void testAndExpression() {
         IvyEventFilter f = new IvyEventFilter("pre-resolve", "organisation = foo AND module = bar",
                 null);
@@ -95,6 +102,7 @@ public class IvyEventFilterTest extends TestCase {
         assertFalse(f.accept(new StartResolveEvent(md4, new String[] {"default"})));
     }
 
+    @Test
     public void testOrExpression() {
         IvyEventFilter f = new IvyEventFilter("pre-resolve", "organisation = foo3 OR module = bar",
                 null);
@@ -105,6 +113,7 @@ public class IvyEventFilterTest extends TestCase {
         assertFalse(f.accept(new StartResolveEvent(md4, new String[] {"default"})));
     }
 
+    @Test
     public void testNotExpression() {
         IvyEventFilter f = new IvyEventFilter("pre-resolve", "NOT organisation = foo", null);
 

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/install/InstallTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/install/InstallTest.java b/test/java/org/apache/ivy/core/install/InstallTest.java
index c57188a..85f2d39 100644
--- a/test/java/org/apache/ivy/core/install/InstallTest.java
+++ b/test/java/org/apache/ivy/core/install/InstallTest.java
@@ -26,11 +26,16 @@ import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-public class InstallTest extends TestCase {
+public class InstallTest {
 
+    @Test
     public void testSimple() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -42,6 +47,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists());
     }
 
+    @Test
     public void testValidate() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -54,10 +60,12 @@ public class InstallTest extends TestCase {
                 .exists());
     }
 
+    @Test
     public void testMaven() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
 
+        @SuppressWarnings("unused")
         ResolveReport rr = ivy.install(ModuleRevisionId.newInstance("org.apache", "test", "1.0"),
             ivy.getSettings().getDefaultResolver().getName(), "install", new InstallOptions());
 
@@ -75,6 +83,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
     }
 
+    @Test
     public void testNoValidate() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -87,6 +96,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/orgfailure/modfailure/modfailure-1.0.jar").exists());
     }
 
+    @Test
     public void testSimpleWithoutDefaultResolver() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings-nodefaultresolver.xml"));
@@ -98,6 +108,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists());
     }
 
+    @Test
     public void testDependencies() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -112,6 +123,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists());
     }
 
+    @Test
     public void testLatestDependenciesNoDefaultResolver() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings-nodefaultresolver.xml"));
@@ -128,6 +140,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.2.jar").exists());
     }
 
+    @Test
     public void testLatestDependenciesDummyDefaultResolver() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings-dummydefaultresolver.xml"));
@@ -144,6 +157,7 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.2.jar").exists());
     }
 
+    @Test
     public void testNotTransitive() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -159,6 +173,7 @@ public class InstallTest extends TestCase {
         assertFalse(new File("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists());
     }
 
+    @Test
     public void testRegexpMatcher() throws Exception {
         Ivy ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
@@ -185,11 +200,13 @@ public class InstallTest extends TestCase {
         assertTrue(new File("build/test/install/org1/mod1.4/ivy-1.0.1.xml").exists());
     }
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() {
         TestHelper.createCache();
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         TestHelper.cleanCache();
         cleanInstall();
     }

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptorTest.java b/test/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptorTest.java
index 1f76c97..d89813d 100644
--- a/test/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptorTest.java
+++ b/test/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptorTest.java
@@ -18,18 +18,23 @@
 
 package org.apache.ivy.core.module.descriptor;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.JUnitCore;
 
-public class DefaultDependencyDescriptorTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class DefaultDependencyDescriptorTest {
 
     public static void main(String[] args) {
-        junit.textui.TestRunner.run(DefaultDependencyDescriptorTest.class);
+        JUnitCore.runClasses(DefaultDependencyDescriptorTest.class);
     }
 
     /*
      * Test method for
      * 'org.apache.ivy.DefaultDependencyDescriptor.replaceSelfFallbackPattern(String, String)'
      */
+    @Test
     public void testReplaceSelfFallbackPattern() {
         String replacedConf = DefaultDependencyDescriptor.replaceSelfFallbackPattern("@(default)",
             "compile");
@@ -47,6 +52,7 @@ public class DefaultDependencyDescriptorTest extends TestCase {
      * Test method for
      * 'org.apache.ivy.DefaultDependencyDescriptor.replaceThisFallbackPattern(String, String)'
      */
+    @Test
     public void testReplaceThisFallbackPattern() {
         String replacedConf = DefaultDependencyDescriptor.replaceThisFallbackPattern("#(default)",
             "compile");

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java b/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java
index 9910ac9..ecdc2c1 100644
--- a/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java
+++ b/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java
@@ -17,10 +17,13 @@
  */
 package org.apache.ivy.core.module.id;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
-public class ModuleIdTest extends TestCase {
+import static org.junit.Assert.*;
 
+public class ModuleIdTest {
+
+    @Test
     public void testModuleId() {
         String org = "apache";
         String name = "some-new-module";
@@ -30,6 +33,7 @@ public class ModuleIdTest extends TestCase {
         assertEquals(name, moduleId.getName());
     }
 
+    @Test
     public void testModuleIdIllegalArgumentException() {
         String org = "apache";
         String name = "some-new-module";
@@ -48,6 +52,7 @@ public class ModuleIdTest extends TestCase {
         }
     }
 
+    @Test
     public void testEqualsObjectTrue() {
         String org = "apache";
         String name = "some-new-module";
@@ -59,6 +64,7 @@ public class ModuleIdTest extends TestCase {
         assertTrue(moduleId2.equals(moduleId));
     }
 
+    @Test
     public void testEqualsObjectFalse() {
         String org = "apache";
         String name = "some-new-module";
@@ -70,6 +76,7 @@ public class ModuleIdTest extends TestCase {
         assertFalse(moduleId2.equals(moduleId));
     }
 
+    @Test
     public void testEncodeToString() {
         String org = "apache";
         String name = "some-new-module";
@@ -78,6 +85,7 @@ public class ModuleIdTest extends TestCase {
         assertEquals(org + ModuleId.ENCODE_SEPARATOR + name, moduleId.encodeToString());
     }
 
+    @Test
     public void testDecode() {
         String org = "apache";
         String name = "some-new-module";
@@ -87,6 +95,7 @@ public class ModuleIdTest extends TestCase {
         assertEquals(moduleId, moduleId2);
     }
 
+    @Test
     public void testCompareToNullObject() {
         String org = "apache";
         String name = "some-new-module";
@@ -100,6 +109,7 @@ public class ModuleIdTest extends TestCase {
         }
     }
 
+    @Test
     public void testCompareToEqual() {
         String org = "apache";
         String name = "some-new-module";
@@ -108,6 +118,7 @@ public class ModuleIdTest extends TestCase {
         assertTrue(moduleId.compareTo(new ModuleId(org, name)) == 0);
     }
 
+    @Test
     public void testCompareToLessThan() {
         String org = "apache";
         String name = "some-new-module";
@@ -119,7 +130,8 @@ public class ModuleIdTest extends TestCase {
         assertTrue(moduleId.compareTo(moduleId2) < 0);
     }
 
-    public void testCompareToGreatherThan() {
+    @Test
+    public void testCompareToGreaterThan() {
         String org = "apache";
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java b/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java
index 61e641c..490822c 100644
--- a/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java
+++ b/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java
@@ -17,13 +17,18 @@
  */
 package org.apache.ivy.core.module.id;
 
+import org.junit.Test;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-public class ModuleRevisionIdTest extends TestCase {
+public class ModuleRevisionIdTest {
 
+    @Test
     public void testParse() throws Exception {
         testParse("#A;1.0");
         testParse("org#module;2.0");
@@ -44,10 +49,11 @@ public class ModuleRevisionIdTest extends TestCase {
             ModuleRevisionId.parse(mrid);
             fail("ModuleRevisionId.parse is supposed to raise an exception with " + mrid);
         } catch (IllegalArgumentException ex) {
-            assertTrue(ex.getMessage().indexOf(mrid) != -1);
+            assertTrue(ex.getMessage().contains(mrid));
         }
     }
 
+    @Test
     public void testEncodeDecodeToString() {
         testEncodeDecodeToString(ModuleRevisionId.newInstance("org", "name", "revision"));
         testEncodeDecodeToString(ModuleRevisionId.newInstance("org", "name", ""));

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java b/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java
index 8d92f9f..0968438 100644
--- a/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java
+++ b/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java
@@ -17,6 +17,8 @@
  */
 package org.apache.ivy.core.module.id;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -26,15 +28,16 @@ import org.apache.ivy.plugins.matcher.MapMatcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.util.filter.Filter;
 import org.apache.ivy.util.filter.NoFilter;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class ModuleRulesTest extends TestCase {
+public class ModuleRulesTest {
     private ModuleRules rules;
 
     private Object[] rule;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() {
         rules = new ModuleRules();
         rule = new Object[10];
         for (int i = 0; i < rule.length; i++) {
@@ -42,8 +45,7 @@ public class ModuleRulesTest extends TestCase {
         }
     }
 
-    // tests
-
+    @Test
     public void testGetRule() throws Exception {
         // fixture
         rules.defineRule(mapMatcher().organization("apache").build(), rule[0]);
@@ -56,6 +58,7 @@ public class ModuleRulesTest extends TestCase {
         assertRule(null, "unknown#module1;1.5");
     }
 
+    @Test
     public void testGetRuleWithFilter() throws Exception {
         // fixture
         rules.defineRule(mapMatcher().organization("apache").build(), rule[0]);

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/publish/PublishEngineTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/publish/PublishEngineTest.java b/test/java/org/apache/ivy/core/publish/PublishEngineTest.java
index cd87d5d..d383305 100644
--- a/test/java/org/apache/ivy/core/publish/PublishEngineTest.java
+++ b/test/java/org/apache/ivy/core/publish/PublishEngineTest.java
@@ -37,18 +37,27 @@ import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
 import org.apache.ivy.plugins.resolver.FileSystemResolver;
 import org.apache.ivy.util.FileUtil;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class PublishEngineTest extends TestCase {
-    protected void setUp() throws Exception {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class PublishEngineTest {
+    @Before
+    public void setUp() {
         System.setProperty("ivy.cache.dir", new File("build/test/publish/cache").getAbsolutePath());
         FileUtil.forceDelete(new File("build/test/publish"));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         FileUtil.forceDelete(new File("build/test/publish"));
     }
 
+    @Test
     public void testAtomicity() throws Exception {
         IvySettings settings = new IvySettings();
         final PublishEngine engine = new PublishEngine(settings, new EventManager());

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/publish/PublishEventsTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/publish/PublishEventsTest.java b/test/java/org/apache/ivy/core/publish/PublishEventsTest.java
index d886ff5..6062441 100644
--- a/test/java/org/apache/ivy/core/publish/PublishEventsTest.java
+++ b/test/java/org/apache/ivy/core/publish/PublishEventsTest.java
@@ -38,9 +38,13 @@ import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
 import org.apache.ivy.plugins.resolver.MockResolver;
 import org.apache.ivy.plugins.trigger.AbstractTrigger;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class PublishEventsTest extends TestCase {
+import static org.junit.Assert.*;
+
+public class PublishEventsTest {
 
     // maps ArtifactRevisionId to PublishTestCase instance.
     private HashMap expectedPublications;
@@ -82,9 +86,8 @@ public class PublishEventsTest extends TestCase {
 
     private PublishEngine publishEngine;
 
-    protected void setUp() throws Exception {
-        super.setUp();
-
+    @Before
+    public void setUp() throws Exception {
         // reset test case state.
         resetCounters();
 
@@ -134,9 +137,8 @@ public class PublishEventsTest extends TestCase {
         IvyContext.getContext().push(PublishEventsTest.class.getName(), this);
     }
 
-    protected void tearDown() throws Exception {
-        super.tearDown();
-
+    @After
+    public void tearDown() {
         // reset test state.
         resetCounters();
 
@@ -173,6 +175,7 @@ public class PublishEventsTest extends TestCase {
     /**
      * Test a simple artifact publish, without errors or overwrite settings.
      */
+    @Test
     public void testPublishNoOverwrite() throws IOException {
         // no modifications to input required for this case -- call out to the resolver, and verify
         // that
@@ -191,6 +194,7 @@ public class PublishEventsTest extends TestCase {
     /**
      * Test a simple artifact publish, with overwrite set to true.
      */
+    @Test
     public void testPublishWithOverwrite() throws IOException {
         // we expect the overwrite settings to be passed through the event listeners and into the
         // publisher.
@@ -213,6 +217,7 @@ public class PublishEventsTest extends TestCase {
     /**
      * Test an attempted publish with an invalid data file path.
      */
+    @Test
     public void testPublishMissingFile() throws IOException {
         // delete the datafile. the publish should fail
         // and the ivy artifact should still publish successfully.
@@ -237,6 +242,7 @@ public class PublishEventsTest extends TestCase {
     /**
      * Test an attempted publish in which the target resolver throws an IOException.
      */
+    @Test
     public void testPublishWithException() {
         // set an error to be thrown during publication of the data file.
         this.publishError = new IOException("boom!");
@@ -347,9 +353,8 @@ public class PublishEventsTest extends TestCase {
                     assertEquals("event declares correct value for " + attributes[i], values[i],
                         event.getAttributes().get(attributes[i]));
                 }
-                // we test file separately, since it is hard to guaranteean exact path match, but we
-                // want
-                // to make sure that both paths point to the same canonical location on the
+                // we test file separately, since it is hard to guarantee an exact path match, but we
+                // want to make sure that both paths point to the same canonical location on the
                 // filesystem
                 String filePath = event.getAttributes().get("file").toString();
                 assertEquals("event declares correct value for file",
@@ -487,4 +492,4 @@ public class PublishEventsTest extends TestCase {
         }
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/report/ResolveReportTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/report/ResolveReportTest.java b/test/java/org/apache/ivy/core/report/ResolveReportTest.java
index d96a2a6..8890c75 100644
--- a/test/java/org/apache/ivy/core/report/ResolveReportTest.java
+++ b/test/java/org/apache/ivy/core/report/ResolveReportTest.java
@@ -31,9 +31,13 @@ import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.util.CacheCleaner;
 import org.apache.ivy.util.FileUtil;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class ResolveReportTest extends TestCase {
+import static org.junit.Assert.*;
+
+public class ResolveReportTest {
 
     private Ivy ivy;
 
@@ -43,7 +47,8 @@ public class ResolveReportTest extends TestCase {
 
     private File workDir;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         cache = new File("build/cache");
         System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
         createCache();
@@ -62,7 +67,8 @@ public class ResolveReportTest extends TestCase {
         cache.mkdirs();
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         CacheCleaner.deleteDir(cache);
         FileUtil.forceDelete(deliverDir);
         FileUtil.forceDelete(workDir);
@@ -84,6 +90,7 @@ public class ResolveReportTest extends TestCase {
             new HashSet<String>(Arrays.asList(dep.getDependencyConfigurations(conf))));
     }
 
+    @Test
     public void testFixedMdSimple() throws Exception {
         ResolveReport report = ivy.resolve(new File(
                 "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"),
@@ -103,6 +110,7 @@ public class ResolveReportTest extends TestCase {
             new String[] {"*"});
     }
 
+    @Test
     public void testFixedMdTransitiveDependencies() throws Exception {
         // mod2.1 depends on mod1.1 which depends on mod1.2
         ResolveReport report = ivy.resolve(new File(
@@ -126,6 +134,7 @@ public class ResolveReportTest extends TestCase {
             new String[] {"*"});
     }
 
+    @Test
     public void testFixedMdMultipleExtends() throws Exception {
         // mod6.2 has two confs default and extension
         // mod6.2 depends on mod6.1 in conf (default->extension)
@@ -158,6 +167,7 @@ public class ResolveReportTest extends TestCase {
             new String[] {"default"});
     }
 
+    @Test
     public void testFixedMdRange() throws Exception {
         ResolveReport report = ivy.resolve(new File(
                 "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"),
@@ -180,6 +190,7 @@ public class ResolveReportTest extends TestCase {
             new String[] {"default"});
     }
 
+    @Test
     public void testFixedMdKeep() throws Exception {
         ResolveReport report = ivy.resolve(new File(
                 "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"),
@@ -203,6 +214,7 @@ public class ResolveReportTest extends TestCase {
             "compile", new String[] {"default"});
     }
 
+    @Test
     public void testFixedMdTransitiveKeep() throws Exception {
         ResolveReport report = ivy.resolve(new File(
                 "test/repositories/1/org2/mod2.9/ivys/ivy-0.6.xml"),

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java b/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java
index 7d90a12..a77a6c6 100644
--- a/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java
+++ b/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java
@@ -25,24 +25,31 @@ import org.apache.ivy.core.search.SearchEngine;
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.core.sort.SortEngine;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class RepositoryManagementEngineTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+
+public class RepositoryManagementEngineTest {
     private RepositoryManagementEngine repository;
 
     private TestFixture fixture;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() {
         fixture = new TestFixture();
         IvySettings settings = fixture.getSettings();
         repository = new RepositoryManagementEngine(settings, new SearchEngine(settings),
                 new ResolveEngine(settings, new EventManager(), new SortEngine(settings)));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         fixture.clean();
     }
 
+    @Test
     public void testLoad() throws Exception {
         fixture.addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3").addMD("o1#B;1")
                 .addMD("o1#B;2->o1#A;2").addMD("o2#C;1->{o1#B;1 o1#A;1}").init();
@@ -52,6 +59,7 @@ public class RepositoryManagementEngineTest extends TestCase {
         assertEquals(6, repository.getRevisionsNumber());
     }
 
+    @Test
     public void testOrphans() throws Exception {
         fixture.addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3").addMD("o1#B;1")
                 .addMD("o1#B;2->o1#A;2").addMD("o2#C;1->{o1#B;1 o1#A;1}").init();

http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java b/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java
index a830254..6ed2c5f 100644
--- a/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java
+++ b/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java
@@ -30,15 +30,22 @@ import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.util.CacheCleaner;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class ResolveEngineTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ResolveEngineTest {
 
     private Ivy ivy;
 
     private File cache;
 
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         cache = new File("build/cache");
         System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
         createCache();
@@ -47,10 +54,12 @@ public class ResolveEngineTest extends TestCase {
         ivy.configure(new File("test/repositories/ivysettings.xml"));
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         CacheCleaner.deleteDir(cache);
     }
 
+    @Test
     public void testInlineResolveWithNonExistingModule() throws Exception {
         ResolveEngine engine = new ResolveEngine(ivy.getSettings(), ivy.getEventManager(),
                 ivy.getSortEngine());
@@ -65,6 +74,7 @@ public class ResolveEngineTest extends TestCase {
         assertTrue(report.hasError());
     }
 
+    @Test
     public void testLocateThenDownload() throws Exception {
         ResolveEngine engine = new ResolveEngine(ivy.getSettings(), ivy.getEventManager(),
                 ivy.getSortEngine());