You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2013/11/22 09:15:09 UTC

svn commit: r1544431 - in /ant/easyant/core/trunk/src: main/java/org/apache/easyant/tasks/ test/java/org/apache/easyant/tasks/

Author: jlboudart
Date: Fri Nov 22 08:15:08 2013
New Revision: 1544431

URL: http://svn.apache.org/r1544431
Log:
Refactor some tests to use ExpectedException and TemporaryFolder rules

Modified:
    ant/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CheckResolverTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ConfigureBuildScopedRepositoryTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CoreRevisionCheckerTaskTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportDeferredTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/LoadModuleTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ParameterTaskTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/PathTaskTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/RegisterArtifactTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ResolvePluginsTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SearchModuleTest.java
    ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SubModuleTest.java

Modified: ant/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java (original)
+++ ant/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java Fri Nov 22 08:15:08 2013
@@ -104,20 +104,11 @@ public class LoadModule extends Abstract
 
     public void execute() throws BuildException {
         if (buildModule != null && buildModule.exists()) {
-            IvyInfo info = new IvyInfo();
-            info.setFile(buildModule);
-            // Not sure we should bound IvyInfo to easyantIvyInstance
-            info.setSettingsRef(IvyInstanceHelper.buildEasyAntIvyReference(getProject()));
-            initTask(info).execute();
-            getProject().setName(getProject().getProperty("ivy.module"));
-        }
-        if (buildModule != null && buildModule.exists()) {
             // make sure it's not a directory (this falls into the ultra
             // paranoid lets check everything category
 
             if (buildModule.isDirectory()) {
-                log("What? buildModule: " + buildModule + " is a dir!");
-                throw new BuildException("Build failed");
+                throw new BuildException("What? buildModule: " + buildModule + " is a dir!");
             }
             // load override buildFile before buildModule to allow target/extension-point
             // override
@@ -129,6 +120,13 @@ public class LoadModule extends Abstract
 
             log("Loading build module : " + buildModule.getAbsolutePath());
             loadBuildModule(buildModule);
+
+            IvyInfo info = new IvyInfo();
+            info.setFile(buildModule);
+            // Not sure we should bound IvyInfo to easyantIvyInstance
+            info.setSettingsRef(IvyInstanceHelper.buildEasyAntIvyReference(getProject()));
+            initTask(info).execute();
+            getProject().setName(getProject().getProperty("ivy.module"));
         }
 
         if (buildFile != null && buildFile.exists()) {
@@ -136,8 +134,7 @@ public class LoadModule extends Abstract
             // paranoid lets check everything category
 
             if (buildFile.isDirectory()) {
-                log("What? buildFile: " + buildFile + " is a dir!");
-                throw new BuildException("Build failed");
+                throw new BuildException("What? buildFile: " + buildFile + " is a dir!");
             }
 
             log("Loading build file : " + buildFile.getAbsolutePath());

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CheckResolverTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CheckResolverTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CheckResolverTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CheckResolverTest.java Fri Nov 22 08:15:08 2013
@@ -18,30 +18,35 @@
 package org.apache.easyant.tasks;
 
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.ProjectUtils;
 import org.apache.easyant.core.ivy.IvyInstanceHelper;
 import org.apache.ivy.ant.IvyConfigure;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class CheckResolverTest {
 
-    private File cache;
     private CheckResolver checkResolver = new CheckResolver();
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws IOException, URISyntaxException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -58,30 +63,15 @@ public class CheckResolverTest {
         checkResolver.setProject(project);
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributesAreSet() {
+        expectedException.expectMessage("resolver attribute is mandatory");
         checkResolver.execute();
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfResolverDoesntExists() {
+        expectedException.expectMessage("resolver unknown does not exist in current project");
         checkResolver.getProject().setProperty("resolver.to.check", "unknown");
         checkResolver.setResolver("resolver.to.check");
         checkResolver.execute();

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ConfigureBuildScopedRepositoryTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ConfigureBuildScopedRepositoryTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ConfigureBuildScopedRepositoryTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ConfigureBuildScopedRepositoryTest.java Fri Nov 22 08:15:08 2013
@@ -23,7 +23,7 @@ import static org.hamcrest.CoreMatchers.
 import static org.junit.Assert.assertThat;
 
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
@@ -35,22 +35,25 @@ import org.apache.ivy.core.cache.EasyAnt
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.resolver.FileSystemResolver;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class ConfigureBuildScopedRepositoryTest {
-    private File cache;
     private ConfigureBuildScopedRepository configureBuildScopeRepository = new ConfigureBuildScopedRepository();
     private Ivy configuredIvyInstance;
     private int originalNbResolvers;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws IOException, URISyntaxException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -74,23 +77,6 @@ public class ConfigureBuildScopedReposit
 
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
     @Test
     public void shouldCreateBuildScopeRepository() {
         configureBuildScopeRepository.execute();

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CoreRevisionCheckerTaskTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CoreRevisionCheckerTaskTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CoreRevisionCheckerTaskTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/CoreRevisionCheckerTaskTest.java Fri Nov 22 08:15:08 2013
@@ -18,29 +18,34 @@
 package org.apache.easyant.tasks;
 
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.ProjectUtils;
 import org.apache.ivy.ant.IvyConfigure;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class CoreRevisionCheckerTaskTest {
 
-    private File cache;
     private CoreRevisionCheckerTask coreRevisionChecker = new CoreRevisionCheckerTask();
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -56,30 +61,15 @@ public class CoreRevisionCheckerTaskTest
         coreRevisionChecker.setProject(project);
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributesAreSet() {
+        expectedException.expectMessage("requiredRevision argument is required");
         coreRevisionChecker.execute();
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfRequiredRevisionDoesntMatch() {
+        expectedException.expectMessage("This module requires easyant 9999");
         coreRevisionChecker.setRequiredRevision("9999");
         coreRevisionChecker.execute();
     }

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java Fri Nov 22 08:15:08 2013
@@ -57,13 +57,13 @@ public class GoOfflineTest extends AntTa
 
     @Before
     public void setUp() throws URISyntaxException, IOException {
-        File cache = folder.newFolder("build-cache");
-
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
-        project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
         configureBuildLogger(project, Project.MSG_VERBOSE);
 
+        File cache = folder.newFolder("build-cache");
+        project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
+
         IvyConfigure configure = new IvyConfigure();
         configure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
         configure.setProject(project);

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportDeferredTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportDeferredTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportDeferredTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportDeferredTest.java Fri Nov 22 08:15:08 2013
@@ -17,34 +17,43 @@
  */
 package org.apache.easyant.tasks;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.ProjectUtils;
 import org.apache.ivy.ant.IvyConfigure;
 import org.apache.ivy.ant.IvyDependency;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.types.Path;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class ImportDeferredTest {
-    private File cache;
 
     private ImportDeferred importTask;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -75,25 +84,10 @@ public class ImportDeferredTest {
         importTask.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributeAreSet() {
+        expectedException
+                .expectMessage("The module to import is not properly specified, you must set set organisation / module attributes");
         importTask.execute();
     }
 
@@ -106,8 +100,8 @@ public class ImportDeferredTest {
 
         Path pluginClasspath = importTask.getProject().getReference("mycompany#simpleplugin.classpath");
         org.junit.Assert.assertNotNull(pluginClasspath);
-        Assert.assertNotNull(pluginClasspath);
-        Assert.assertEquals(0, pluginClasspath.list().length);
+        assertNotNull(pluginClasspath);
+        assertEquals(0, pluginClasspath.list().length);
     }
 
     @Test
@@ -117,8 +111,8 @@ public class ImportDeferredTest {
         importTask.execute();
 
         Path pluginClasspath = importTask.getProject().getReference("mycompany#simpleplugin.classpath");
-        Assert.assertNotNull(pluginClasspath);
-        Assert.assertEquals(0, pluginClasspath.list().length);
+        assertNotNull(pluginClasspath);
+        assertEquals(0, pluginClasspath.list().length);
     }
 
     @Test
@@ -132,25 +126,25 @@ public class ImportDeferredTest {
 
     private void verifySimplePluginWithPropertiesIsImported() {
         Path pluginClasspath = importTask.getProject().getReference("mycompany#simplepluginwithproperties.classpath");
-        Assert.assertNotNull(pluginClasspath);
-        Assert.assertEquals(0, pluginClasspath.list().length);
+        assertNotNull(pluginClasspath);
+        assertEquals(0, pluginClasspath.list().length);
 
         String propertiesFileLocation = importTask.getProject().getProperty(
                 "mycompany#simplepluginwithproperties.properties.file");
-        Assert.assertNotNull(propertiesFileLocation);
+        assertNotNull(propertiesFileLocation);
 
         String srcMainJavaProperty = importTask.getProject().getProperty("src.main.java");
-        Assert.assertNotNull(srcMainJavaProperty);
-        Assert.assertEquals(importTask.getProject().getBaseDir() + "/src/main/java", srcMainJavaProperty);
+        assertNotNull(srcMainJavaProperty);
+        assertEquals(importTask.getProject().getBaseDir() + "/src/main/java", srcMainJavaProperty);
 
         // imported from property file
         String aProperty = importTask.getProject().getProperty("aproperty");
-        Assert.assertNotNull(aProperty);
-        Assert.assertEquals("value", aProperty);
+        assertNotNull(aProperty);
+        assertEquals("value", aProperty);
 
         String anotherJavaProperty = importTask.getProject().getProperty("anotherproperty");
-        Assert.assertNotNull(anotherJavaProperty);
-        Assert.assertEquals("value", anotherJavaProperty);
+        assertNotNull(anotherJavaProperty);
+        assertEquals("value", anotherJavaProperty);
     }
 
     @Test
@@ -170,17 +164,17 @@ public class ImportDeferredTest {
 
         String propertiesFileLocation = importTask.getProject().getProperty(
                 "mycompany#simplepluginwithproperties.properties.file");
-        Assert.assertNull(propertiesFileLocation);
+        assertNull(propertiesFileLocation);
 
         String srcMainJavaProperty = importTask.getProject().getProperty("src.main.java");
-        Assert.assertNull(srcMainJavaProperty);
+        assertNull(srcMainJavaProperty);
 
         // imported from property file
         String aProperty = importTask.getProject().getProperty("aproperty");
-        Assert.assertNull(aProperty);
+        assertNull(aProperty);
 
         String anotherJavaProperty = importTask.getProject().getProperty("anotherproperty");
-        Assert.assertNull(anotherJavaProperty);
+        assertNull(anotherJavaProperty);
     }
 
     @Test
@@ -224,12 +218,13 @@ public class ImportDeferredTest {
         importTask.execute();
 
         // as attribute is preconfigured with module name
-        Assert.assertNotNull(importTask.getAs());
-        Assert.assertEquals("simpleplugin", importTask.getAs());
+        assertNotNull(importTask.getAs());
+        assertEquals("simpleplugin", importTask.getAs());
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailBuildConfAreFound() {
+        expectedException.expectMessage("there is no available build configuration");
         importTask.setOrg("mycompany");
         importTask.setModule("simplepluginwithproperties");
         importTask.setBuildConfigurations("amissingConf");

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ImportTest.java Fri Nov 22 08:15:08 2013
@@ -17,33 +17,42 @@
  */
 package org.apache.easyant.tasks;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.ProjectUtils;
 import org.apache.ivy.ant.IvyConfigure;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.types.Path;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class ImportTest {
-    private File cache;
 
     private Import importTask;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -61,25 +70,10 @@ public class ImportTest {
         importTask.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    @Test(expected = BuildException.class)
-    public void shouldFailIfNoMandatoryAttributeAreSet() {
+    @Test
+    public void shouldFailIfNoMandatoryAttribute() {
+        expectedException
+                .expectMessage("The module to import is not properly specified, you must set the mrid attribute or set organisation / module / revision attributes");
         importTask.execute();
     }
 
@@ -92,8 +86,8 @@ public class ImportTest {
         importTask.execute();
 
         Path pluginClasspath = importTask.getProject().getReference("mycompany#simpleplugin.classpath");
-        Assert.assertNotNull(pluginClasspath);
-        Assert.assertEquals(0, pluginClasspath.list().length);
+        assertNotNull(pluginClasspath);
+        assertEquals(0, pluginClasspath.list().length);
     }
 
     @Test
@@ -103,8 +97,8 @@ public class ImportTest {
         importTask.execute();
 
         // as attribute is preconfigured with module name
-        Assert.assertNotNull(importTask.getAs());
-        Assert.assertEquals("simpleplugin", importTask.getAs());
+        assertNotNull(importTask.getAs());
+        assertEquals("simpleplugin", importTask.getAs());
     }
 
     @Test
@@ -115,8 +109,8 @@ public class ImportTest {
         importTask.execute();
 
         Path pluginClasspath = importTask.getProject().getReference("mycompany#simpleplugin.classpath");
-        Assert.assertNotNull(pluginClasspath);
-        Assert.assertEquals(0, pluginClasspath.list().length);
+        assertNotNull(pluginClasspath);
+        assertEquals(0, pluginClasspath.list().length);
     }
 
     @Test
@@ -139,17 +133,17 @@ public class ImportTest {
         Assert.assertNotNull(propertiesFileLocation);
 
         String srcMainJavaProperty = importTask.getProject().getProperty("src.main.java");
-        Assert.assertNotNull(srcMainJavaProperty);
-        Assert.assertEquals(importTask.getProject().getBaseDir() + "/src/main/java", srcMainJavaProperty);
+        assertNotNull(srcMainJavaProperty);
+        assertEquals(importTask.getProject().getBaseDir() + "/src/main/java", srcMainJavaProperty);
 
         // imported from property file
         String aProperty = importTask.getProject().getProperty("aproperty");
-        Assert.assertNotNull(aProperty);
-        Assert.assertEquals("value", aProperty);
+        assertNotNull(aProperty);
+        assertEquals("value", aProperty);
 
         String anotherJavaProperty = importTask.getProject().getProperty("anotherproperty");
-        Assert.assertNotNull(anotherJavaProperty);
-        Assert.assertEquals("value", anotherJavaProperty);
+        assertNotNull(anotherJavaProperty);
+        assertEquals("value", anotherJavaProperty);
     }
 
     @Test
@@ -170,17 +164,17 @@ public class ImportTest {
 
         String propertiesFileLocation = importTask.getProject().getProperty(
                 "mycompany#simplepluginwithproperties.properties.file");
-        Assert.assertNull(propertiesFileLocation);
+        assertNull(propertiesFileLocation);
 
         String srcMainJavaProperty = importTask.getProject().getProperty("src.main.java");
-        Assert.assertNull(srcMainJavaProperty);
+        assertNull(srcMainJavaProperty);
 
         // imported from property file
         String aProperty = importTask.getProject().getProperty("aproperty");
-        Assert.assertNull(aProperty);
+        assertNull(aProperty);
 
         String anotherJavaProperty = importTask.getProject().getProperty("anotherproperty");
-        Assert.assertNull(anotherJavaProperty);
+        assertNull(anotherJavaProperty);
     }
 
     @Test
@@ -228,18 +222,18 @@ public class ImportTest {
         importTask.execute();
 
         // as attribute is preconfigured with module name
-        Assert.assertNotNull(importTask.getAs());
-        Assert.assertEquals("simpleplugin", importTask.getAs());
+        assertNotNull(importTask.getAs());
+        assertEquals("simpleplugin", importTask.getAs());
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailBuildConfAreFound() {
+        expectedException.expectMessage("there is no available build configuration");
         importTask.setOrg("mycompany");
         importTask.setModule("simplepluginwithproperties");
         importTask.setRev("0.1");
         importTask.setBuildConfigurations("amissingConf");
         importTask.execute();
-        //
     }
 
     @Test

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/LoadModuleTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/LoadModuleTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/LoadModuleTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/LoadModuleTest.java Fri Nov 22 08:15:08 2013
@@ -24,7 +24,7 @@ import static org.hamcrest.CoreMatchers.
 import static org.junit.Assert.assertThat;
 
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.List;
 
@@ -39,25 +39,29 @@ import org.apache.ivy.ant.IvyConfigure;
 import org.apache.ivy.core.module.id.ModuleId;
 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.Location;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class LoadModuleTest extends AntTaskBaseTest {
 
-    private File cache;
-
     private LoadModule loadModule;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -77,23 +81,6 @@ public class LoadModuleTest extends AntT
         loadModule.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
     @Test
     public void shouldLoadModuleWithCustomBuildModule() throws URISyntaxException {
         Project project = loadModule.getProject();
@@ -154,13 +141,13 @@ public class LoadModuleTest extends AntT
 
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfBuildModuleIsADirectory() throws URISyntaxException {
-
         File moduleIvyFile = new File(this.getClass().getResource("simple").toURI());
+        expectedException.expectMessage("What? buildModule: " + moduleIvyFile.getAbsolutePath() + " is a dir!");
+
         loadModule.setBuildModule(moduleIvyFile);
         loadModule.execute();
-
     }
 
     @Test
@@ -205,10 +192,10 @@ public class LoadModuleTest extends AntT
 
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfBuildFileIsADirectory() throws URISyntaxException {
-
         File moduleAntFile = new File(this.getClass().getResource("simple").toURI());
+        expectedException.expectMessage("What? buildFile: " + moduleAntFile.getAbsolutePath() + " is a dir!");
         loadModule.setBuildFile(moduleAntFile);
         loadModule.execute();
 

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ParameterTaskTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ParameterTaskTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ParameterTaskTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ParameterTaskTest.java Fri Nov 22 08:15:08 2013
@@ -16,25 +16,30 @@
  *
  */package org.apache.easyant.tasks;
 
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 public class ParameterTaskTest {
 
     private ParameterTask parameterTask;
 
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Before
     public void setUp() {
         parameterTask = new ParameterTask();
         parameterTask.setProject(new Project());
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributesAreSet() {
+        expectedException.expectMessage("at least one of these attributes is required: property, path");
         parameterTask.execute();
     }
 
@@ -62,16 +67,18 @@ public class ParameterTaskTest {
         Assert.assertEquals("a-value", property);
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfPropertyIsRequired() {
+        expectedException.expectMessage("expected property 'a-property': null");
         parameterTask.setProperty("a-property");
         parameterTask.setRequired(true);
         parameterTask.execute();
 
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfPropertyIsRequiredWithDescription() {
+        expectedException.expectMessage("expected property 'a-property': a property can be documented");
         parameterTask.setProperty("a-property");
         parameterTask.setDescription("a property can be documented");
         parameterTask.setRequired(true);
@@ -92,23 +99,28 @@ public class ParameterTaskTest {
 
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailToSetPropertyWithANonPossibleValue() {
+        expectedException
+                .expectMessage("current value of property 'a-property' doesn't match with possible values : [true, false]");
+
         parameterTask.getProject().setProperty("a-property", "a-value");
         parameterTask.setProperty("a-property");
         parameterTask.setPossibleValues("true,false");
         parameterTask.execute();
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfRequiredPathIsMissing() {
+        expectedException.expectMessage("expected path 'a-path-id': null");
         parameterTask.setPath("a-path-id");
         parameterTask.setRequired(true);
         parameterTask.execute();
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfGivenPathIdIsNotAPath() {
+        expectedException.expectMessage("reference 'a-path-id' must be a path");
         parameterTask.getProject().addReference("a-path-id", true);
         parameterTask.setPath("a-path-id");
         parameterTask.execute();

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/PathTaskTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/PathTaskTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/PathTaskTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/PathTaskTest.java Fri Nov 22 08:15:08 2013
@@ -17,15 +17,16 @@
  */
 package org.apache.easyant.tasks;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.ant.ProjectUtils;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -46,8 +47,9 @@ public class PathTaskTest {
         pathTask.setProject(project);
     }
 
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributesAreSet() {
+        expectedException.expectMessage("pathid is mandatory");
         pathTask.execute();
     }
 
@@ -57,8 +59,8 @@ public class PathTaskTest {
         pathTask.setPathid(classpathName);
         pathTask.execute();
         Path classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(0, classpath.size());
+        assertNotNull(classpath);
+        assertEquals(0, classpath.size());
     }
 
     @Test
@@ -71,8 +73,8 @@ public class PathTaskTest {
         pathTask.getProject().addReference(classpathName, originalClasspath);
 
         Path classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
 
         pathTask.setPathid(classpathName);
         File file2 = new File("anotherfile");
@@ -81,10 +83,10 @@ public class PathTaskTest {
         pathTask.execute();
 
         classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(2, classpath.list().length);
-        Assert.assertEquals(file2.getAbsolutePath(), classpath.list()[0]);
-        Assert.assertEquals(file1.getAbsolutePath(), classpath.list()[1]);
+        assertNotNull(classpath);
+        assertEquals(2, classpath.list().length);
+        assertEquals(file2.getAbsolutePath(), classpath.list()[0]);
+        assertEquals(file1.getAbsolutePath(), classpath.list()[1]);
 
     }
 
@@ -98,8 +100,8 @@ public class PathTaskTest {
         pathTask.getProject().addReference(classpathName, originalClasspath);
 
         Path classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
 
         pathTask.setPathid(classpathName);
         File file2 = new File("anotherfile");
@@ -107,10 +109,10 @@ public class PathTaskTest {
         pathTask.execute();
 
         classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(2, classpath.list().length);
-        Assert.assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
-        Assert.assertEquals(file2.getAbsolutePath(), classpath.list()[1]);
+        assertNotNull(classpath);
+        assertEquals(2, classpath.list().length);
+        assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
+        assertEquals(file2.getAbsolutePath(), classpath.list()[1]);
 
     }
 
@@ -124,9 +126,9 @@ public class PathTaskTest {
         pathTask.getProject().addReference(classpathName, originalClasspath);
 
         Path classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
-        Assert.assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
+        assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
 
         pathTask.setPathid(classpathName);
         File file2 = new File("anotherfile");
@@ -135,9 +137,9 @@ public class PathTaskTest {
         pathTask.execute();
 
         classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
-        Assert.assertEquals(file2.getAbsolutePath(), classpath.list()[0]);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
+        assertEquals(file2.getAbsolutePath(), classpath.list()[0]);
 
     }
 
@@ -151,9 +153,9 @@ public class PathTaskTest {
         pathTask.getProject().addReference(classpathName, originalClasspath);
 
         Path classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
-        Assert.assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
+        assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
 
         pathTask.setPathid(classpathName);
         File file2 = new File("anotherfile");
@@ -162,9 +164,9 @@ public class PathTaskTest {
         pathTask.execute();
 
         classpath = pathTask.getProject().getReference(classpathName);
-        Assert.assertNotNull(classpath);
-        Assert.assertEquals(1, classpath.list().length);
-        Assert.assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
+        assertNotNull(classpath);
+        assertEquals(1, classpath.list().length);
+        assertEquals(file1.getAbsolutePath(), classpath.list()[0]);
     }
 
     @Test

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/RegisterArtifactTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/RegisterArtifactTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/RegisterArtifactTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/RegisterArtifactTest.java Fri Nov 22 08:15:08 2013
@@ -17,30 +17,34 @@
  */
 package org.apache.easyant.tasks;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.ivy.ant.IvyConfigure;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class RegisterArtifactTest {
-    private File cache;
 
     private RegisterArtifact registerArtifact;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
 
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -56,23 +60,6 @@ public class RegisterArtifactTest {
         registerArtifact.setProject(project);
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
     @Test
     public void shouldRegisterArtifact() {
         registerArtifact.setInline(true);
@@ -89,15 +76,15 @@ public class RegisterArtifactTest {
         registerArtifact.execute();
 
         ResolveReport resolveReport = registerArtifact.getProject().getReference("ivy.resolved.report.myResolve");
-        Assert.assertNotNull(resolveReport);
-        Assert.assertEquals(1, resolveReport.getModuleDescriptor().getAllArtifacts().length);
-        Assert.assertEquals("my-artifact-name", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getName());
-        Assert.assertEquals("my-ext", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getExt());
-        Assert.assertEquals("my-type", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getType());
+        assertNotNull(resolveReport);
+        assertEquals(1, resolveReport.getModuleDescriptor().getAllArtifacts().length);
+        assertEquals("my-artifact-name", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getName());
+        assertEquals("my-ext", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getExt());
+        assertEquals("my-type", resolveReport.getModuleDescriptor().getAllArtifacts()[0].getType());
         String classifierAttribute = resolveReport.getModuleDescriptor().getAllArtifacts()[0]
                 .getExtraAttribute("classifier");
-        Assert.assertNotNull(classifierAttribute);
+        assertNotNull(classifierAttribute);
 
-        Assert.assertEquals("my-classifier", classifierAttribute);
+        assertEquals("my-classifier", classifierAttribute);
     }
 }

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ResolvePluginsTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ResolvePluginsTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ResolvePluginsTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/ResolvePluginsTest.java Fri Nov 22 08:15:08 2013
@@ -17,8 +17,11 @@
  */
 package org.apache.easyant.tasks;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
@@ -26,22 +29,23 @@ import org.apache.ivy.ant.IvyConfigure;
 import org.apache.ivy.ant.IvyDependency;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
-import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class ResolvePluginsTest {
-    private File cache;
 
     private ResolvePlugins resolvePlugins;
 
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
 
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -57,30 +61,13 @@ public class ResolvePluginsTest {
         resolvePlugins.setProject(project);
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
     @Test
     public void shouldCreateEmptyResolveReport() {
         resolvePlugins.execute();
         ResolveReport report = resolvePlugins.getProject().getReference(
                 EasyAntMagicNames.IMPORTED_MODULES_RESOLVE_REPORT_REF);
-        Assert.assertNotNull(report);
-        Assert.assertEquals(0, report.getDependencies().size());
+        assertNotNull(report);
+        assertEquals(0, report.getDependencies().size());
     }
 
     @Test
@@ -92,9 +79,9 @@ public class ResolvePluginsTest {
         resolvePlugins.execute();
         ResolveReport report = resolvePlugins.getProject().getReference(
                 EasyAntMagicNames.IMPORTED_MODULES_RESOLVE_REPORT_REF);
-        Assert.assertNotNull(report);
-        Assert.assertEquals(1, report.getDependencies().size());
-        Assert.assertEquals(1, report.getUnresolvedDependencies().length);
+        assertNotNull(report);
+        assertEquals(1, report.getDependencies().size());
+        assertEquals(1, report.getUnresolvedDependencies().length);
     }
 
     @Test
@@ -106,9 +93,9 @@ public class ResolvePluginsTest {
         resolvePlugins.execute();
         ResolveReport report = resolvePlugins.getProject().getReference(
                 EasyAntMagicNames.IMPORTED_MODULES_RESOLVE_REPORT_REF);
-        Assert.assertNotNull(report);
-        Assert.assertEquals(1, report.getDependencies().size());
-        Assert.assertEquals(0, report.getUnresolvedDependencies().length);
+        assertNotNull(report);
+        assertEquals(1, report.getDependencies().size());
+        assertEquals(0, report.getUnresolvedDependencies().length);
     }
 
 }

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SearchModuleTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SearchModuleTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SearchModuleTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SearchModuleTest.java Fri Nov 22 08:15:08 2013
@@ -47,16 +47,15 @@ public class SearchModuleTest {
 
     @Rule
     public TemporaryFolder folder = new TemporaryFolder();
-
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
 
     @Before
     public void setUp() throws URISyntaxException, IOException {
-        File cache = folder.newFolder("build-cache");
-
         Project project = new Project();
         ProjectUtils.configureProjectHelper(project);
+
+        File cache = folder.newFolder("build-cache");
         project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
 
         IvyConfigure configure = new IvyConfigure();
@@ -72,7 +71,6 @@ public class SearchModuleTest {
         searchModule.setOwningTarget(ProjectUtils.createTopLevelTarget());
         searchModule.setLocation(new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath()));
         searchModule.setSettingsRef(IvyInstanceHelper.buildEasyAntIvyReference(project));
-
     }
 
     @Test

Modified: ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SubModuleTest.java
URL: http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SubModuleTest.java?rev=1544431&r1=1544430&r2=1544431&view=diff
==============================================================================
--- ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SubModuleTest.java (original)
+++ ant/easyant/core/trunk/src/test/java/org/apache/easyant/tasks/SubModuleTest.java Fri Nov 22 08:15:08 2013
@@ -22,36 +22,36 @@ import static org.hamcrest.CoreMatchers.
 import static org.junit.Assert.assertThat;
 
 import java.io.File;
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.listerners.BuildExecutionTimer;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
 
 public class SubModuleTest extends AntTaskBaseTest {
-    private File cache;
 
     private SubModule submodule;
+
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
 
     @Before
-    public void setUp() throws MalformedURLException, URISyntaxException {
-        createCache();
+    public void setUp() throws URISyntaxException, IOException {
         Project project = new Project();
 
-        // FIXME: property are not yet inherited
+        File cache = folder.newFolder("build-cache");
         project.setUserProperty("ivy.cache.dir", cache.getAbsolutePath());
+
         File f = new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI());
         // FIXME: property are not yet inherited
         project.setUserProperty(EasyAntMagicNames.USER_EASYANT_IVYSETTINGS, f.getAbsolutePath());
@@ -60,25 +60,9 @@ public class SubModuleTest extends AntTa
         submodule.setProject(project);
     }
 
-    private void createCache() {
-        cache = new File("build/cache");
-        cache.mkdirs();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cleanCache();
-    }
-
-    private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
-    }
-
-    @Test(expected = BuildException.class)
+    @Test
     public void shouldFailIfNoMandatoryAttributesAreSet() {
+        expectedException.expectMessage("No buildpath specified");
         submodule.execute();
     }
 
@@ -97,7 +81,6 @@ public class SubModuleTest extends AntTa
 
     @Test
     public void shouldFailIfPathContainsInvalidFile() {
-        expectedException.expect(BuildException.class);
         expectedException.expectMessage("Invalid file:");
 
         configureBuildLogger(submodule.getProject(), Project.MSG_WARN);