Convert tests to JUnit 4, clean up code Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/1543f528 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/1543f528 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/1543f528
Branch: refs/heads/master Commit: 1543f528963246eacfdc3228d716d78ceba824b3 Parents: 239bc0b Author: twogee <g.grigelio...@gmail.com> Authored: Thu May 25 17:25:59 2017 +0200 Committer: twogee <g.grigelio...@gmail.com> Committed: Thu May 25 17:25:59 2017 +0200 ---------------------------------------------------------------------- ivy.xml | 32 +- test/java/org/apache/ivy/IvyTest.java | 15 +- test/java/org/apache/ivy/MainTest.java | 23 +- test/java/org/apache/ivy/TestFixture.java | 18 +- test/java/org/apache/ivy/TestHelper.java | 7 +- .../apache/ivy/ant/AntBuildResolverTest.java | 23 +- .../org/apache/ivy/ant/AntBuildTriggerTest.java | 12 +- .../org/apache/ivy/ant/AntCallTriggerTest.java | 14 +- .../org/apache/ivy/ant/BuildOBRTaskTest.java | 24 +- .../org/apache/ivy/ant/FixDepsTaskTest.java | 20 +- .../ivy/ant/IvyAntSettingsBuildFileTest.java | 48 ++- .../apache/ivy/ant/IvyArtifactPropertyTest.java | 20 +- .../apache/ivy/ant/IvyArtifactReportTest.java | 16 +- .../org/apache/ivy/ant/IvyBuildListTest.java | 40 ++- .../org/apache/ivy/ant/IvyBuildNumberTest.java | 27 +- .../org/apache/ivy/ant/IvyCacheFilesetTest.java | 54 +-- .../org/apache/ivy/ant/IvyCachePathTest.java | 40 ++- .../org/apache/ivy/ant/IvyCleanCacheTest.java | 34 +- .../org/apache/ivy/ant/IvyConfigureTest.java | 31 +- .../org/apache/ivy/ant/IvyConvertPomTest.java | 5 +- .../java/org/apache/ivy/ant/IvyDeliverTest.java | 39 +- .../apache/ivy/ant/IvyDependencyTreeTest.java | 19 +- .../ivy/ant/IvyDependencyUpdateCheckerTest.java | 94 ++--- .../org/apache/ivy/ant/IvyFindRevisionTest.java | 18 +- .../apache/ivy/ant/IvyInfoRepositoryTest.java | 18 +- test/java/org/apache/ivy/ant/IvyInfoTest.java | 17 +- .../java/org/apache/ivy/ant/IvyInstallTest.java | 33 +- .../org/apache/ivy/ant/IvyListModulesTest.java | 17 +- .../apache/ivy/ant/IvyPostResolveTaskTest.java | 28 +- .../java/org/apache/ivy/ant/IvyPublishTest.java | 74 +++- test/java/org/apache/ivy/ant/IvyReportTest.java | 21 +- .../apache/ivy/ant/IvyRepositoryReportTest.java | 42 ++- .../java/org/apache/ivy/ant/IvyResolveTest.java | 60 +++- .../org/apache/ivy/ant/IvyResourcesTest.java | 25 +- .../ivy/ant/IvyRetrieveBuildFileTest.java | 25 +- .../org/apache/ivy/ant/IvyRetrieveTest.java | 76 ++-- test/java/org/apache/ivy/ant/IvyTaskTest.java | 12 +- test/java/org/apache/ivy/ant/IvyVarTest.java | 11 +- .../ivy/ant/testutil/AntTaskTestCase.java | 6 +- .../ivy/core/NormalRelativeUrlResolverTest.java | 13 +- .../org/apache/ivy/core/TestPerformance.java | 10 +- .../DefaultRepositoryCacheManagerTest.java | 34 +- .../cache/ModuleDescriptorMemoryCacheTest.java | 29 +- .../apache/ivy/core/deliver/DeliverTest.java | 22 +- .../ivy/core/event/IvyEventFilterTest.java | 13 +- .../apache/ivy/core/install/InstallTest.java | 25 +- .../DefaultDependencyDescriptorTest.java | 12 +- .../apache/ivy/core/module/id/ModuleIdTest.java | 18 +- .../core/module/id/ModuleRevisionIdTest.java | 12 +- .../ivy/core/module/id/ModuleRulesTest.java | 15 +- .../ivy/core/publish/PublishEngineTest.java | 17 +- .../ivy/core/publish/PublishEventsTest.java | 29 +- .../ivy/core/report/ResolveReportTest.java | 20 +- .../RepositoryManagementEngineTest.java | 16 +- .../ivy/core/resolve/ResolveEngineTest.java | 18 +- .../apache/ivy/core/resolve/ResolveTest.java | 352 +++++++++++++++---- .../apache/ivy/core/retrieve/RetrieveTest.java | 48 ++- .../org/apache/ivy/core/search/SearchTest.java | 9 +- .../apache/ivy/core/settings/ConfigureTest.java | 12 +- .../ivy/core/settings/IvySettingsTest.java | 8 +- .../settings/OnlineXmlSettingsParserTest.java | 11 +- .../core/settings/XmlSettingsParserTest.java | 32 +- .../java/org/apache/ivy/core/sort/SortTest.java | 66 ++-- .../osgi/core/AggregatedOSGiResolverTest.java | 15 +- .../ExecutionEnvironmentProfileLoaderTest.java | 7 +- .../ivy/osgi/core/ManifestHeaderTest.java | 12 +- .../ivy/osgi/core/ManifestParserTest.java | 16 +- .../ivy/osgi/core/OSGiManifestParserTest.java | 12 +- .../ivy/osgi/core/OsgiLatestStrategyTest.java | 11 +- .../apache/ivy/osgi/filter/OSGiFilterTest.java | 12 +- .../org/apache/ivy/osgi/obr/OBRParserTest.java | 12 +- .../apache/ivy/osgi/obr/OBRResolverTest.java | 32 +- .../apache/ivy/osgi/obr/OBRXMLWriterTest.java | 15 +- .../apache/ivy/osgi/p2/P2DescriptorTest.java | 24 +- .../apache/ivy/osgi/repo/BundleRepoTest.java | 9 +- .../UpdateSiteAndIbiblioResolverTest.java | 12 +- .../osgi/updatesite/UpdateSiteLoaderTest.java | 26 +- .../osgi/updatesite/UpdateSiteResolverTest.java | 16 +- .../org/apache/ivy/osgi/util/ParseUtilTest.java | 8 +- .../apache/ivy/osgi/util/VersionRangeTest.java | 10 +- .../org/apache/ivy/osgi/util/VersionTest.java | 9 +- .../IgnoreCircularDependencyStrategyTest.java | 11 +- .../WarnCircularDependencyStrategyTest.java | 12 +- .../LatestCompatibleConflictManagerTest.java | 67 ++-- .../conflict/LatestConflictManagerTest.java | 20 +- .../conflict/RegexpConflictManagerTest.java | 24 +- .../conflict/StrictConflictManagerTest.java | 19 +- .../latest/LatestRevisionStrategyTest.java | 11 +- .../plugins/lock/ArtifactLockStrategyTest.java | 15 +- .../matcher/AbstractPatternMatcherTest.java | 32 +- .../ExactOrRegexpPatternMatcherTest.java | 19 +- .../matcher/ExactPatternMatcherTest.java | 10 +- .../plugins/matcher/GlobPatternMatcherTest.java | 25 +- .../matcher/RegexpPatternMatcherTest.java | 18 +- .../namespace/MRIDTransformationRuleTest.java | 6 +- .../plugins/namespace/NameSpaceHelperTest.java | 6 +- .../AbstractModuleDescriptorParserTester.java | 66 ++-- .../ModuleDescriptorParserRegistryTest.java | 7 +- .../m2/PomModuleDescriptorParserTest.java | 77 +++- .../m2/PomModuleDescriptorWriterTest.java | 24 +- .../xml/XmlModuleDescriptorParserTest.java | 105 ++++-- .../xml/XmlModuleDescriptorWriterTest.java | 30 +- .../parser/xml/XmlModuleUpdaterTest.java | 32 +- .../ivy/plugins/report/XmlReportParserTest.java | 15 +- .../ivy/plugins/report/XmlReportWriterTest.java | 35 +- .../repository/vfs/VfsRepositoryTest.java | 28 +- .../plugins/repository/vfs/VfsResourceTest.java | 29 +- .../plugins/repository/vfs/VfsTestHelper.java | 2 +- .../ivy/plugins/repository/vfs/VfsURI.java | 20 +- .../AbstractDependencyResolverTest.java | 4 +- .../plugins/resolver/BintrayResolverTest.java | 27 +- .../ivy/plugins/resolver/ChainResolverTest.java | 159 +++++---- .../ivy/plugins/resolver/DualResolverTest.java | 38 +- .../resolver/FileSystemResolverTest.java | 44 ++- .../plugins/resolver/IBiblioResolverTest.java | 18 +- .../plugins/resolver/IvyRepResolverTest.java | 18 +- .../ivy/plugins/resolver/JarResolverTest.java | 17 +- .../ivy/plugins/resolver/Maven2LocalTest.java | 16 +- .../resolver/MirroredURLResolverTest.java | 18 +- .../ivy/plugins/resolver/MockResolver.java | 4 +- .../plugins/resolver/PackagerResolverTest.java | 17 +- .../plugins/resolver/ResolverTestHelper.java | 70 ++-- .../ivy/plugins/resolver/URLResolverTest.java | 22 +- .../ivy/plugins/resolver/VfsResolverTest.java | 10 + .../resolver/util/ResolverHelperTest.java | 8 +- .../ivy/plugins/trigger/LogTriggerTest.java | 17 +- .../version/LatestVersionMatcherTest.java | 21 +- .../version/PatternVersionMatcherTest.java | 12 +- .../version/VersionRangeMatcherTest.java | 13 +- test/java/org/apache/ivy/util/CacheCleaner.java | 2 +- .../org/apache/ivy/util/ConfiguratorTest.java | 89 +++-- .../apache/ivy/util/IvyPatternHelperTest.java | 13 +- .../org/apache/ivy/util/MockMessageLogger.java | 36 +- .../org/apache/ivy/util/StringUtilsTest.java | 15 +- .../ivy/util/url/AbstractURLHandlerTest.java | 10 +- .../ivy/util/url/ApacheURLListerTest.java | 14 +- .../ivy/util/url/ArtifactoryListingTest.java | 8 +- .../ivy/util/url/BasicURLHandlerTest.java | 17 +- .../ivy/util/url/HttpclientURLHandlerTest.java | 19 +- 139 files changed, 2697 insertions(+), 1081 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/ivy.xml ---------------------------------------------------------------------- diff --git a/ivy.xml b/ivy.xml index 80cae08..eef5feb 100644 --- a/ivy.xml +++ b/ivy.xml @@ -44,29 +44,27 @@ </publications> <dependencies> <dependency org="org.apache.ant" name="ant" rev="1.9.9" conf="default,ant->default"/> - <dependency org="commons-httpclient" name="commons-httpclient" rev="3.0" conf="default,httpclient->runtime,master" /> + <dependency org="commons-httpclient" name="commons-httpclient" rev="3.1" conf="default,httpclient->runtime,master"/> <dependency org="oro" name="oro" rev="2.0.8" conf="default,oro->default"/> - <dependency org="commons-vfs" name="commons-vfs" rev="1.0" conf="default,vfs->default" /> - <dependency org="com.jcraft" name="jsch" rev="0.1.54" conf="default,sftp->default" /> - <dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.9" conf="default,sftp->default" /> - <dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.9" conf="default,sftp->default" /> - <dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.9" conf="default,sftp->default" /> - <dependency org="org.bouncycastle" name="bcpg-jdk15on" rev="1.52" conf="default" /> - <dependency org="org.bouncycastle" name="bcprov-jdk15on" rev="1.52" conf="default" /> + <dependency org="commons-vfs" name="commons-vfs" rev="1.0" conf="default,vfs->default"/> + <dependency org="com.jcraft" name="jsch" rev="0.1.54" conf="default,sftp->default"/> + <dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.9" conf="default,sftp->default"/> + <dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.9" conf="default,sftp->default"/> + <dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.9" conf="default,sftp->default"/> + <dependency org="org.bouncycastle" name="bcpg-jdk15on" rev="1.52" conf="default"/> + <dependency org="org.bouncycastle" name="bcprov-jdk15on" rev="1.52" conf="default"/> <!-- Test dependencies --> - <dependency org="junit" name="junit" rev="3.8.2" conf="test->default" /> - <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="test->default" /> - <dependency org="org.apache.ant" name="ant-testutil" rev="1.9.9" conf="test->default" transitive="false" /> + <dependency org="junit" name="junit" rev="4.12" conf="test->default"/> + <dependency org="org.hamcrest" name="hamcrest-core" rev="1.3" conf="test->default"/> + <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="test->default"/> + <dependency org="org.apache.ant" name="ant-testutil" rev="1.9.9" conf="test->default" transitive="false"/> <dependency org="org.apache.ant" name="ant-launcher" rev="1.9.9" conf="test->default" transitive="false"/> <dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="test->default" transitive="false"/> <dependency org="xmlunit" name="xmlunit" rev="1.6" conf="test->default" transitive="false"/> - - <!-- This dependency is necessary for having validation in junit tests when running with JDK1.4 --> - <dependency org="xerces" name="xercesImpl" rev="2.6.2" conf="test->default" /> - <dependency org="xerces" name="xmlParserAPIs" rev="2.6.2" conf="test->default" /> - <!-- Global exclude for junit --> - <exclude org="junit" module="junit" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant" /> + <!-- Global exclude for junit and hamcrest --> + <exclude org="junit" module="junit" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant"/> + <exclude org="org.hamcrest" module="hamcrest-core" conf="core,default,httpclient,oro,vfs,sftp,standalone,ant"/> </dependencies> </ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/IvyTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/IvyTest.java b/test/java/org/apache/ivy/IvyTest.java index 5a525e6..abe5c13 100644 --- a/test/java/org/apache/ivy/IvyTest.java +++ b/test/java/org/apache/ivy/IvyTest.java @@ -25,13 +25,18 @@ import org.apache.ivy.core.resolve.ResolveOptions; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.MockMessageLogger; +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.assertNotNull; -public class IvyTest extends TestCase { +public class IvyTest { private File cache; - protected void setUp() throws Exception { + @Before + public void setUp() { createCache(); System.setProperty("ivy.cache.dir", cache.getAbsolutePath()); } @@ -41,10 +46,12 @@ public class IvyTest extends TestCase { cache.mkdirs(); } - protected void tearDown() throws Exception { + @After + public void tearDown() { CacheCleaner.deleteDir(cache); } + @Test public void testMultipleInstances() throws Exception { // this test checks that IvyContext is properly set and unset when using multiple instances // of Ivy. We also check logging, because it heavily relies on IvyContext. http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/MainTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/MainTest.java b/test/java/org/apache/ivy/MainTest.java index eeb026e..035b75c 100644 --- a/test/java/org/apache/ivy/MainTest.java +++ b/test/java/org/apache/ivy/MainTest.java @@ -23,25 +23,33 @@ import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.cli.CommandLine; import org.apache.ivy.util.cli.ParseException; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -public class MainTest extends TestCase { +import static org.junit.Assert.*; + +public class MainTest { private File cache; - protected void setUp() throws Exception { + @Before + public void setUp() { cache = new File("build/cache"); System.setProperty("ivy.cache.dir", cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { CacheCleaner.deleteDir(cache); } + @Test public void testHelp() throws Exception { run(new String[] {"-?"}); } + @Test public void testBadOption() throws Exception { try { run(new String[] {"-bad"}); @@ -51,6 +59,7 @@ public class MainTest extends TestCase { } } + @Test public void testMissingParameter() throws Exception { try { run(new String[] {"-ivy"}); @@ -60,24 +69,28 @@ public class MainTest extends TestCase { } } + @Test public void testResolveSimple() throws Exception { run(new String[] {"-settings", "test/repositories/ivysettings.xml", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"}); assertTrue(new File("build/cache/org1/mod1.2/ivy-2.0.xml").exists()); } + @Test public void testResolveSimpleWithConfs() throws Exception { run(new String[] {"-settings", "test/repositories/ivysettings.xml", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml", "-confs", "default"}); assertTrue(new File("build/cache/org1/mod1.2/ivy-2.0.xml").exists()); } + @Test public void testResolveSimpleWithConfs2() throws Exception { run(new String[] {"-settings", "test/repositories/ivysettings.xml", "-confs", "default", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"}); assertTrue(new File("build/cache/org1/mod1.2/ivy-2.0.xml").exists()); } + @Test public void testExtraParams1() throws Exception { String[] params = new String[] {"-settings", "test/repositories/ivysettings.xml", "-confs", "default", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml", "foo1", @@ -90,6 +103,7 @@ public class MainTest extends TestCase { assertEquals("foo2", leftOver[1]); } + @Test public void testExtraParams2() throws Exception { String[] params = new String[] {"-settings", "test/repositories/ivysettings.xml", "-confs", "default", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml", "--", @@ -102,6 +116,7 @@ public class MainTest extends TestCase { assertEquals("foo2", leftOver[1]); } + @Test public void testExtraParams3() throws Exception { String[] params = new String[] {"-settings", "test/repositories/ivysettings.xml", "-confs", "default", "-ivy", "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"}; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/TestFixture.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/TestFixture.java b/test/java/org/apache/ivy/TestFixture.java index 733be7f..3ebb13d 100644 --- a/test/java/org/apache/ivy/TestFixture.java +++ b/test/java/org/apache/ivy/TestFixture.java @@ -19,7 +19,6 @@ package org.apache.ivy; import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; @@ -38,18 +37,21 @@ import org.apache.ivy.plugins.resolver.util.ResolvedResource; * Example of use: * * <pre> - * public class MyTest extends TestCase { + * public class MyTest { * private TestFixture fixture; - * - * protected void setUp() throws Exception { + * + * @Before + * public void setUp() throws Exception { * fixture = new TestFixture(); * // additional setup here * } - * - * protected void tearDown() throws Exception { + * + * @After + * public void tearDown() throws Exception { * fixture.clean(); * } - * + * + * @Test * public void testXXX() throws Exception { * fixture.addMD("#A;1-> { #B;[1.5,1.6] #C;2.5 }").addMD("#B;1.5->#D;2.0") * .addMD("#B;1.6->#D;2.0").addMD("#C;2.5->#D;[1.0,1.6]").addMD("#D;1.5") @@ -115,7 +117,7 @@ public class TestFixture { return ((FileResource) r.getResource()).getFile(); } - public ResolveReport resolve(String mrid) throws MalformedURLException, ParseException, + public ResolveReport resolve(String mrid) throws ParseException, IOException { return ivy.resolve(getIvyFile(mrid), TestHelper.newResolveOptions(getSettings())); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/TestHelper.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/TestHelper.java b/test/java/org/apache/ivy/TestHelper.java index a68f4c0..e434cc9 100644 --- a/test/java/org/apache/ivy/TestHelper.java +++ b/test/java/org/apache/ivy/TestHelper.java @@ -48,7 +48,7 @@ import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Delete; -import junit.framework.Assert; +import static org.junit.Assert.assertEquals; public class TestHelper { @@ -97,7 +97,7 @@ public class TestHelper { public static void assertModuleRevisionIds(String expectedMrids, Collection/* <ModuleRevisionId> */mrids) { Collection expected = parseMrids(expectedMrids); - Assert.assertEquals(expected, mrids); + assertEquals(expected, mrids); } /** @@ -284,8 +284,7 @@ public class TestHelper { /** * Cleans up the test repository and cache. - * - * @see #newTestSettings() + * */ public static void cleanTest() { cleanTestRepository(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/AntBuildResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/AntBuildResolverTest.java b/test/java/org/apache/ivy/ant/AntBuildResolverTest.java index 95dd017..9e228a4 100644 --- a/test/java/org/apache/ivy/ant/AntBuildResolverTest.java +++ b/test/java/org/apache/ivy/ant/AntBuildResolverTest.java @@ -24,13 +24,18 @@ import org.apache.ivy.ant.AntWorkspaceResolver.WorkspaceArtifact; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.DownloadStatus; import org.apache.ivy.core.report.ResolveReport; + import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; -public class AntBuildResolverTest extends TestCase { +public class AntBuildResolverTest { private static final ModuleRevisionId MRID_MODULE1 = ModuleRevisionId.newInstance("org.acme", "module1", "1.1"); @@ -44,8 +49,8 @@ public class AntBuildResolverTest extends TestCase { private WorkspaceArtifact wa; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.cleanCache(); project = TestHelper.newProject(); project.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); @@ -67,11 +72,12 @@ public class AntBuildResolverTest extends TestCase { configure.execute(); } - @Override - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testNoProject() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -84,6 +90,7 @@ public class AntBuildResolverTest extends TestCase { assertEquals(MRID_MODULE1, report.getDependencies().get(0).getResolvedId()); } + @Test public void testProject() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -105,6 +112,7 @@ public class AntBuildResolverTest extends TestCase { report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); } + @Test public void testProjectFolder() throws Exception { wa.setPath("target/classes"); @@ -127,6 +135,7 @@ public class AntBuildResolverTest extends TestCase { report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); } + @Test public void testDependencyArtifact() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -148,6 +157,7 @@ public class AntBuildResolverTest extends TestCase { report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); } + @Test public void testCachePath() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -169,6 +179,7 @@ public class AntBuildResolverTest extends TestCase { path.list()[1]); } + @Test public void testCachePathFolder() throws Exception { wa.setPath("target/classes"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java b/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java index ac53b9e..4c55039 100644 --- a/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java +++ b/test/java/org/apache/ivy/ant/AntBuildTriggerTest.java @@ -23,9 +23,14 @@ import org.apache.ivy.Ivy; import org.apache.ivy.core.report.ResolveReport; import org.apache.ivy.util.FileUtil; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Test; -public class AntBuildTriggerTest extends TestCase { +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class AntBuildTriggerTest { + @Test public void test() throws Exception { assertFalse(new File("test/triggers/ant-build/A/A.jar").exists()); @@ -39,7 +44,8 @@ public class AntBuildTriggerTest extends TestCase { assertTrue(new File("test/triggers/ant-build/local/A/A.jar").exists()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { FileUtil.forceDelete(new File("test/triggers/ant-build/local/A")); FileUtil.forceDelete(new File("test/triggers/ant-build/cache")); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/AntCallTriggerTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/AntCallTriggerTest.java b/test/java/org/apache/ivy/ant/AntCallTriggerTest.java index 02a504a..c3a20a0 100644 --- a/test/java/org/apache/ivy/ant/AntCallTriggerTest.java +++ b/test/java/org/apache/ivy/ant/AntCallTriggerTest.java @@ -17,12 +17,16 @@ */ package org.apache.ivy.ant; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.InputStream; import java.io.PrintStream; import java.util.Vector; import org.apache.ivy.util.FileUtil; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.DefaultLogger; @@ -34,9 +38,11 @@ import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.input.DefaultInputHandler; import org.apache.tools.ant.input.InputHandler; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Test; -public class AntCallTriggerTest extends TestCase { +public class AntCallTriggerTest { + @Test public void test() throws Exception { assertFalse(new File("test/triggers/ant-call/A/out/foo.txt").exists()); runAnt(new File("test/triggers/ant-call/A/build.xml"), "resolve"); @@ -44,7 +50,8 @@ public class AntCallTriggerTest extends TestCase { assertTrue(new File("test/triggers/ant-call/A/out/foo.txt").exists()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { FileUtil.forceDelete(new File("test/triggers/ant-call/A/out")); FileUtil.forceDelete(new File("test/triggers/ant-call/cache")); } @@ -173,6 +180,7 @@ public class AntCallTriggerTest extends TestCase { * @param project * the project instance. * @param inputHandlerClassname + * String * @exception BuildException * if a specified InputHandler implementation could not be loaded. */ http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java b/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java index f9f1b79..38f17f3 100644 --- a/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java +++ b/test/java/org/apache/ivy/ant/BuildOBRTaskTest.java @@ -17,22 +17,26 @@ */ package org.apache.ivy.ant; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.text.ParseException; import org.apache.ivy.TestHelper; import org.apache.ivy.osgi.obr.xml.OBRXMLParser; import org.apache.ivy.osgi.repo.BundleRepoDescriptor; import org.apache.ivy.util.CollectionUtils; + import org.apache.tools.ant.Project; -import org.xml.sax.SAXException; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.xml.sax.SAXException; -public class BuildOBRTaskTest extends TestCase { +public class BuildOBRTaskTest { private File cache; @@ -40,7 +44,8 @@ public class BuildOBRTaskTest extends TestCase { private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { createCache(); project = TestHelper.newProject(); @@ -54,12 +59,12 @@ public class BuildOBRTaskTest extends TestCase { cache.mkdirs(); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } - private BundleRepoDescriptor readObr(File obrFile) throws FileNotFoundException, - ParseException, IOException, SAXException { + private BundleRepoDescriptor readObr(File obrFile) throws IOException, SAXException { BundleRepoDescriptor obr; FileInputStream in = new FileInputStream(obrFile); try { @@ -70,6 +75,7 @@ public class BuildOBRTaskTest extends TestCase { return obr; } + @Test public void testDir() throws Exception { buildObr.setBaseDir(new File("test/test-repo/bundlerepo")); File obrFile = new File("build/cache/obr.xml"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/FixDepsTaskTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/FixDepsTaskTest.java b/test/java/org/apache/ivy/ant/FixDepsTaskTest.java index 5825cc0..42a8037 100644 --- a/test/java/org/apache/ivy/ant/FixDepsTaskTest.java +++ b/test/java/org/apache/ivy/ant/FixDepsTaskTest.java @@ -26,17 +26,24 @@ import org.apache.ivy.TestHelper; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser; + import org.apache.tools.ant.Project; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -public class FixDepsTaskTest extends TestCase { +public class FixDepsTaskTest { private FixDepsTask fixDeps; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -46,10 +53,12 @@ public class FixDepsTaskTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); @@ -78,6 +87,7 @@ public class FixDepsTaskTest extends TestCase { assertEquals("2.0", md.getDependencies()[0].getDependencyRevisionId().getRevision()); } + @Test public void testMulticonf() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml"); @@ -124,6 +134,7 @@ public class FixDepsTaskTest extends TestCase { assertEquals("default", md.getDependencies()[1].getDependencyConfigurations("compile")[0]); } + @Test public void testTransitivity() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-transitive.xml"); @@ -181,6 +192,7 @@ public class FixDepsTaskTest extends TestCase { assertEquals("*", md.getDependencies()[2].getDependencyConfigurations("compile")[0]); } + @Test public void testFixedResolve() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-transitive.xml"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java b/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java index 092e64a..13d0cd8 100644 --- a/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java +++ b/test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileTest.java @@ -18,50 +18,66 @@ package org.apache.ivy.ant; import org.apache.ivy.core.report.ResolveReport; -import org.apache.tools.ant.BuildFileTest; -public class IvyAntSettingsBuildFileTest extends BuildFileTest { +import org.apache.tools.ant.BuildFileRule; - protected void setUp() throws Exception { - configureProject("test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml"); +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class IvyAntSettingsBuildFileTest { + + @Rule + public final BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("test/java/org/apache/ivy/ant/IvyAntSettingsBuildFile.xml"); } + @Test public void testOverrideNotSpecified() { - executeTarget("testOverrideNotSpecified"); - ResolveReport report = (ResolveReport) getProject().getReference("ivy.resolved.report"); + buildRule.executeTarget("testOverrideNotSpecified"); + ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report"); assertNotNull(report); assertFalse(report.hasError()); assertEquals(1, report.getDependencies().size()); } + @Test public void testOverrideSetToFalse() { - executeTarget("testOverrideSetToFalse"); - ResolveReport report = (ResolveReport) getProject().getReference("ivy.resolved.report"); + buildRule.executeTarget("testOverrideSetToFalse"); + ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report"); assertNotNull(report); assertFalse(report.hasError()); assertEquals(1, report.getDependencies().size()); } + @Test public void testUnnecessaryDefaultIvyInstance() { - executeTarget("testUnnecessaryDefaultIvyInstance"); - assertNull("Default ivy.instance settings shouldn't have been loaded", getProject() - .getReference("ivy.instance")); + buildRule.executeTarget("testUnnecessaryDefaultIvyInstance"); + assertNull("Default ivy.instance settings shouldn't have been loaded", + buildRule.getProject().getReference("ivy.instance")); } + @Test public void testSettingsWithIdIvyInstance() { // IVY-925 - executeTarget("testSettingsWithPropertyAsId"); - ResolveReport report = (ResolveReport) getProject().getReference("ivy.resolved.report"); + buildRule.executeTarget("testSettingsWithPropertyAsId"); + ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report"); assertNotNull(report); assertFalse(report.hasError()); assertEquals(1, report.getDependencies().size()); } + @Test public void testStackOverflow() { // IVY-924 - configureProject("test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileStackOverflow.xml"); - executeTarget("testStackOverflow"); - ResolveReport report = (ResolveReport) getProject().getReference("ivy.resolved.report"); + buildRule.configureProject("test/java/org/apache/ivy/ant/IvyAntSettingsBuildFileStackOverflow.xml"); + buildRule.executeTarget("testStackOverflow"); + ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report"); assertNotNull(report); assertFalse(report.hasError()); assertEquals(1, report.getDependencies().size()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyArtifactPropertyTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyArtifactPropertyTest.java b/test/java/org/apache/ivy/ant/IvyArtifactPropertyTest.java index 3aed282..ac476a3 100644 --- a/test/java/org/apache/ivy/ant/IvyArtifactPropertyTest.java +++ b/test/java/org/apache/ivy/ant/IvyArtifactPropertyTest.java @@ -20,18 +20,26 @@ package org.apache.ivy.ant; import java.io.File; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; -public class IvyArtifactPropertyTest extends TestCase { +public class IvyArtifactPropertyTest { private IvyArtifactProperty prop; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -41,10 +49,12 @@ public class IvyArtifactPropertyTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); prop.setName("[module].[artifact]-[revision]"); @@ -56,6 +66,7 @@ public class IvyArtifactPropertyTest extends TestCase { new File(val).getCanonicalPath()); } + @Test public void testWithResolveId() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -80,6 +91,7 @@ public class IvyArtifactPropertyTest extends TestCase { new File(val).getCanonicalPath()); } + @Test public void testWithResolveIdWithoutResolve() throws Exception { try { prop.setName("[module].[artifact]-[revision]"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyArtifactReportTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyArtifactReportTest.java b/test/java/org/apache/ivy/ant/IvyArtifactReportTest.java index 4938e79..c254cc6 100644 --- a/test/java/org/apache/ivy/ant/IvyArtifactReportTest.java +++ b/test/java/org/apache/ivy/ant/IvyArtifactReportTest.java @@ -20,17 +20,23 @@ package org.apache.ivy.ant; import java.io.File; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.Project; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; -public class IvyArtifactReportTest extends TestCase { +public class IvyArtifactReportTest { private IvyArtifactReport prop; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -40,10 +46,12 @@ public class IvyArtifactReportTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { prop.setTofile(new File("build/test-artifact-report.xml")); prop.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml")); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyBuildListTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyBuildListTest.java b/test/java/org/apache/ivy/ant/IvyBuildListTest.java index 23409cc..2599c70 100644 --- a/test/java/org/apache/ivy/ant/IvyBuildListTest.java +++ b/test/java/org/apache/ivy/ant/IvyBuildListTest.java @@ -24,16 +24,23 @@ import java.util.List; import org.apache.ivy.TestHelper; import org.apache.ivy.util.FileUtil; + import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; // CheckStyle:MagicNumber| OFF // The test very often use MagicNumber. Using a constant is less expressive. -public class IvyBuildListTest extends TestCase { +public class IvyBuildListTest { private File cache; @@ -41,7 +48,8 @@ public class IvyBuildListTest extends TestCase { private IvyBuildList buildlist; - protected void setUp() throws Exception { + @Before + public void setUp() { createCache(); project = TestHelper.newProject(); @@ -53,7 +61,8 @@ public class IvyBuildListTest extends TestCase { System.setProperty("ivy.cache.dir", cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { cleanCache(); } @@ -92,6 +101,7 @@ public class IvyBuildListTest extends TestCase { * C B has no dependency C -> B D -> A , B E has no dependency F -> G G -> F */ + @Test public void testSimple() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -108,6 +118,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files); } + @Test public void testReverse() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -125,6 +136,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"E", "D", "A", "C", "B"}, files); } + @Test public void testWithRoot() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -142,6 +154,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B", "C"}, files); } + @Test public void testWithRootCircular() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -156,6 +169,7 @@ public class IvyBuildListTest extends TestCase { assertEquals(2, files.length); // F and G should be in the list } + @Test public void testWithTwoRoots() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -173,6 +187,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B", "C", "E"}, files); } + @Test public void testWithRootExclude() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -191,6 +206,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B"}, files); } + @Test public void testWithRootAndOnlyDirectDep() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -209,6 +225,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files); } + @Test public void testWithLeaf() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -226,6 +243,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D"}, files); } + @Test public void testWithLeafCircular() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -240,6 +258,7 @@ public class IvyBuildListTest extends TestCase { assertEquals(2, files.length); } + @Test public void testWithTwoLeafs() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -257,6 +276,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files); } + @Test public void testWithLeafExclude() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -275,6 +295,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"A", "D"}, files); } + @Test public void testWithLeafAndOnlyDirectDep() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -293,6 +314,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files); } + @Test public void testRestartFrom() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -310,6 +332,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files); } + @Test public void testOnMissingDescriptor() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -326,6 +349,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E", "H"}, files); } + @Test public void testOnMissingDescriptor2() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -342,6 +366,7 @@ public class IvyBuildListTest extends TestCase { assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files); } + @Test public void testWithModuleWithSameNameAndDifferentOrg() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); @@ -368,6 +393,7 @@ public class IvyBuildListTest extends TestCase { other.get(1)); } + @Test public void testNoParents() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlists/testNoParents")); @@ -385,6 +411,7 @@ public class IvyBuildListTest extends TestCase { "ireland", "germany", "master-parent", "croatia"}, files); } + @Test public void testOneParent() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlists/testOneParent")); @@ -402,6 +429,7 @@ public class IvyBuildListTest extends TestCase { "master-parent", "croatia", "ireland", "germany"}, files); } + @Test public void testTwoParents() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlists/testTwoParents")); @@ -419,6 +447,7 @@ public class IvyBuildListTest extends TestCase { "master-parent", "croatia", "ireland", "germany"}, files); } + @Test public void testRelativePathToParent() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlists/testRelativePathToParent")); @@ -436,6 +465,7 @@ public class IvyBuildListTest extends TestCase { "bootstrap-parent", "master-parent", "croatia", "ireland", "germany"}, files); } + @Test public void testAbsolutePathToParent() { project.setProperty("master-parent.dir", new File( "test/buildlists/testAbsolutePathToParent/master-parent").getAbsolutePath()); @@ -457,4 +487,4 @@ public class IvyBuildListTest extends TestCase { } } -// CheckStyle:MagicNumber| ON \ No newline at end of file +// CheckStyle:MagicNumber| ON http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyBuildNumberTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyBuildNumberTest.java b/test/java/org/apache/ivy/ant/IvyBuildNumberTest.java index 565ecbc..73d4bff 100644 --- a/test/java/org/apache/ivy/ant/IvyBuildNumberTest.java +++ b/test/java/org/apache/ivy/ant/IvyBuildNumberTest.java @@ -18,15 +18,21 @@ package org.apache.ivy.ant; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.Project; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; -public class IvyBuildNumberTest extends TestCase { +public class IvyBuildNumberTest { private IvyBuildNumber buildNumber; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); Project project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -35,10 +41,12 @@ public class IvyBuildNumberTest extends TestCase { buildNumber.setProject(project); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testDefault() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("newmod"); @@ -49,6 +57,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("0", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testDefault2() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("newmod"); @@ -60,6 +69,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testDefault3() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("newmod"); @@ -71,6 +81,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals(null, buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testLatest() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.1"); @@ -81,6 +92,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testLatest2() throws Exception { buildNumber.setOrganisation("orgbn"); buildNumber.setModule("buildnumber"); @@ -91,6 +103,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testPrefix() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.1"); @@ -102,6 +115,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("test.new.build.number")); } + @Test public void testBuildNumber() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.1"); @@ -113,6 +127,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("2", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testBuildNumber2() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.5"); @@ -124,6 +139,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testBuildNumber3() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.1"); @@ -135,6 +151,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testBuildNumber4() throws Exception { buildNumber.setOrganisation("org1"); buildNumber.setModule("mod1.1"); @@ -146,6 +163,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("0", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testWithBadChecksum() throws Exception { Project project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings-checksums.xml"); @@ -162,6 +180,7 @@ public class IvyBuildNumberTest extends TestCase { assertEquals("1", buildNumber.getProject().getProperty("ivy.new.build.number")); } + @Test public void testChainResolver() throws Exception { // IVY-1037 Project project = TestHelper.newProject(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java b/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java index 2fd533b..0205518 100644 --- a/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java +++ b/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java @@ -20,21 +20,32 @@ package org.apache.ivy.ant; import java.io.File; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Delete; import org.apache.tools.ant.types.FileSet; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.junit.Assert.*; -public class IvyCacheFilesetTest extends TestCase { +public class IvyCacheFilesetTest { private IvyCacheFileset fileset; private Project project; - protected void setUp() throws Exception { + @Rule + public ExpectedException expExc = ExpectedException.none(); + + @Before + public void setUp() { TestHelper.createCache(); project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -44,10 +55,12 @@ public class IvyCacheFilesetTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); fileset.setSetid("simple-setid"); @@ -76,6 +89,7 @@ public class IvyCacheFilesetTest extends TestCase { revision, artifact, type, ext); } + @Test public void testEmptyConf() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml"); fileset.setSetid("emptyconf-setid"); @@ -90,30 +104,24 @@ public class IvyCacheFilesetTest extends TestCase { assertEquals(0, directoryScanner.getIncludedFiles().length); } + @Test(expected = BuildException.class) public void testFailure() throws Exception { - try { - project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); - fileset.setSetid("failure-setid"); - fileset.execute(); - fail("failure didn't raised an exception with default haltonfailure setting"); - } catch (BuildException ex) { - // ok => should raised an exception - } + project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); + fileset.setSetid("failure-setid"); + fileset.execute(); + fail("failure didn't raised an exception with default haltonfailure setting"); } + @Test(expected = BuildException.class) public void testInvalidPattern() throws Exception { - try { - project.setProperty("ivy.settings.file", - "test/repositories/ivysettings-invalidcachepattern.xml"); - project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); - fileset.setSetid("simple-setid"); - fileset.execute(); - fail("failure didn't raised an exception with default haltonfailure setting"); - } catch (BuildException ex) { - // ok => should raise an exception - } + project.setProperty("ivy.settings.file", "test/repositories/ivysettings-invalidcachepattern.xml"); + project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); + fileset.setSetid("simple-setid"); + fileset.execute(); + fail("failure didn't raised an exception with default haltonfailure setting"); } + @Test public void testHaltOnFailure() throws Exception { try { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); @@ -125,6 +133,7 @@ public class IvyCacheFilesetTest extends TestCase { } } + @Test public void testWithoutPreviousResolveAndNonDefaultCache() throws Exception { File cache2 = new File("build/cache2"); cache2.mkdirs(); @@ -152,6 +161,7 @@ public class IvyCacheFilesetTest extends TestCase { } } + @Test public void testGetBaseDir() { File base = null; base = fileset.getBaseDir(base, new File("x/aa/b/c")); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyCachePathTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyCachePathTest.java b/test/java/org/apache/ivy/ant/IvyCachePathTest.java index 092c6b2..bae894c 100644 --- a/test/java/org/apache/ivy/ant/IvyCachePathTest.java +++ b/test/java/org/apache/ivy/ant/IvyCachePathTest.java @@ -20,19 +20,25 @@ package org.apache.ivy.ant; import java.io.File; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Path; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; -public class IvyCachePathTest extends TestCase { +public class IvyCachePathTest { private IvyCachePath path; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); project = TestHelper.newProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -42,10 +48,12 @@ public class IvyCachePathTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml"); path.setPathid("simple-pathid"); @@ -59,6 +67,7 @@ public class IvyCachePathTest extends TestCase { .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); } + @Test public void testInline1() throws Exception { // we first resolve another ivy file IvyResolve resolve = new IvyResolve(); @@ -84,6 +93,7 @@ public class IvyCachePathTest extends TestCase { .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); } + @Test public void testInline2() throws Exception { // we first resolve a dependency directly path.setOrganisation("org1"); @@ -109,6 +119,7 @@ public class IvyCachePathTest extends TestCase { assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); } + @Test public void testEmptyConf() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml"); path.setPathid("emptyconf-pathid"); @@ -121,17 +132,15 @@ public class IvyCachePathTest extends TestCase { assertEquals(0, p.size()); } + @Test(expected = BuildException.class) public void testFailure() throws Exception { - try { - project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); - path.setPathid("failure-pathid"); - path.execute(); - fail("failure didn't raised an exception with default haltonfailure setting"); - } catch (BuildException ex) { - // ok => should raised an exception - } + project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); + path.setPathid("failure-pathid"); + path.execute(); + fail("failure didn't raised an exception with default haltonfailure setting"); } + @Test public void testHaltOnFailure() throws Exception { try { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-failure.xml"); @@ -143,6 +152,7 @@ public class IvyCachePathTest extends TestCase { } } + @Test public void testWithResolveId() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -169,6 +179,7 @@ public class IvyCachePathTest extends TestCase { .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); } + @Test public void testWithResolveIdWithoutResolve() throws Exception { Project otherProject = TestHelper.newProject(); otherProject.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -199,6 +210,7 @@ public class IvyCachePathTest extends TestCase { .getAbsolutePath(), new File(p.list()[0]).getAbsolutePath()); } + @Test public void testWithResolveIdAndMissingConfs() throws Exception { Project otherProject = TestHelper.newProject(); otherProject.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -225,6 +237,7 @@ public class IvyCachePathTest extends TestCase { path.execute(); } + @Test public void testUnpack() throws Exception { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module1/ivys/ivy-1.0.xml"); @@ -238,6 +251,7 @@ public class IvyCachePathTest extends TestCase { assertTrue(new File(p.list()[0]).isDirectory()); } + @Test public void testOSGi() throws Exception { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module5/ivys/ivy-1.0.xml"); @@ -257,6 +271,7 @@ public class IvyCachePathTest extends TestCase { assertEquals(new File(unpacked, "lib/ant-apache-log4j.jar"), new File(p.list()[3])); } + @Test public void testOSGi2() throws Exception { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module6/ivys/ivy-1.0.xml"); @@ -273,6 +288,7 @@ public class IvyCachePathTest extends TestCase { assertEquals(unpacked, new File(p.list()[0])); } + @Test public void testPackedOSGi() throws Exception { project.setProperty("ivy.dep.file", "test/repositories/1/packaging/module8/ivys/ivy-1.0.xml"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyCleanCacheTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyCleanCacheTest.java b/test/java/org/apache/ivy/ant/IvyCleanCacheTest.java index cf2dc8f..4c418aa 100644 --- a/test/java/org/apache/ivy/ant/IvyCleanCacheTest.java +++ b/test/java/org/apache/ivy/ant/IvyCleanCacheTest.java @@ -20,12 +20,21 @@ package org.apache.ivy.ant; import java.io.File; import org.apache.ivy.TestHelper; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -public class IvyCleanCacheTest extends TestCase { +public class IvyCleanCacheTest { private IvyCleanCache cleanCache; private File cacheDir; @@ -36,7 +45,11 @@ public class IvyCleanCacheTest extends TestCase { private File resolutionCache; - protected void setUp() throws Exception { + @Rule + public ExpectedException expExc = ExpectedException.none(); + + @Before + public void setUp() throws Exception { Project p = TestHelper.newProject(); cacheDir = new File("build/cache"); p.setProperty("cache", cacheDir.getAbsolutePath()); @@ -56,6 +69,7 @@ public class IvyCleanCacheTest extends TestCase { repoCache2.mkdirs(); } + @Test public void testCleanAll() throws Exception { cleanCache.perform(); assertFalse(resolutionCache.exists()); @@ -63,6 +77,7 @@ public class IvyCleanCacheTest extends TestCase { assertFalse(repoCache2.exists()); } + @Test public void testResolutionOnly() throws Exception { cleanCache.setCache(IvyCleanCache.NONE); cleanCache.perform(); @@ -71,6 +86,7 @@ public class IvyCleanCacheTest extends TestCase { assertTrue(repoCache2.exists()); } + @Test public void testRepositoryOnly() throws Exception { cleanCache.setResolution(false); cleanCache.perform(); @@ -79,6 +95,7 @@ public class IvyCleanCacheTest extends TestCase { assertFalse(repoCache2.exists()); } + @Test public void testOneRepositoryOnly() throws Exception { cleanCache.setResolution(false); cleanCache.setCache("mycache"); @@ -88,14 +105,13 @@ public class IvyCleanCacheTest extends TestCase { assertTrue(repoCache2.exists()); } + @Test public void testUnknownCache() throws Exception { + expExc.expect(BuildException.class); + expExc.expectMessage("unknown cache 'yourcache'"); cleanCache.setResolution(false); cleanCache.setCache("yourcache"); - try { - cleanCache.perform(); - fail("clean cache should have raised an exception with unkown cache"); - } catch (BuildException e) { - assertTrue(e.getMessage().indexOf("yourcache") != -1); - } + cleanCache.perform(); + fail("clean cache should have raised an exception with unknown cache"); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyConfigureTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyConfigureTest.java b/test/java/org/apache/ivy/ant/IvyConfigureTest.java index cea5d86..2ad60c4 100644 --- a/test/java/org/apache/ivy/ant/IvyConfigureTest.java +++ b/test/java/org/apache/ivy/ant/IvyConfigureTest.java @@ -25,18 +25,23 @@ import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.plugins.resolver.DependencyResolver; import org.apache.ivy.plugins.resolver.IBiblioResolver; import org.apache.ivy.plugins.resolver.IvyRepResolver; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Reference; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; -public class IvyConfigureTest extends TestCase { +public class IvyConfigureTest { private IvyConfigure configure; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { project = TestHelper.newProject(); project.setProperty("myproperty", "myvalue"); @@ -44,6 +49,7 @@ public class IvyConfigureTest extends TestCase { configure.setProject(project); } + @SuppressWarnings("deprecation") private Ivy getIvyInstance() { IvyTask task = new IvyTask() { public void doExecute() throws BuildException { @@ -58,6 +64,7 @@ public class IvyConfigureTest extends TestCase { return task.getIvyInstance(); } + @Test public void testDefaultCacheDir() { // test with an URL configure.setUrl(getClass().getResource("ivysettings-defaultCacheDir.xml")); @@ -90,6 +97,7 @@ public class IvyConfigureTest extends TestCase { assertNotNull(project.getProperty("ivy.cache.dir.test3")); } + @Test public void testDefault() throws Exception { // by default settings look in the current directory for an ivysettings.xml file... // but Ivy itself has one, and we don't want to use it @@ -106,6 +114,7 @@ public class IvyConfigureTest extends TestCase { assertTrue(ibiblio.isM2compatible()); } + @Test public void testDefault14() throws Exception { // by default settings look in the current directory for an ivysettings.xml file... // but Ivy itself has one, and we don't want to use it @@ -120,6 +129,7 @@ public class IvyConfigureTest extends TestCase { assertTrue(publicResolver instanceof IvyRepResolver); } + @Test public void testFile() throws Exception { configure.setFile(new File("test/repositories/ivysettings.xml")); @@ -141,6 +151,7 @@ public class IvyConfigureTest extends TestCase { assertEquals("myvalue", settings.getVariables().getVariable("myproperty")); } + @Test public void testURL() throws Exception { String confUrl = new File("test/repositories/ivysettings-url.xml").toURI().toURL() .toExternalForm(); @@ -160,6 +171,7 @@ public class IvyConfigureTest extends TestCase { assertEquals("myvalue", settings.getVariables().getVariable("myproperty")); } + @Test public void testAntProperties() throws Exception { String confUrl = IvyConfigureTest.class.getResource("ivysettings-test.xml") .toExternalForm(); @@ -174,6 +186,7 @@ public class IvyConfigureTest extends TestCase { assertEquals("myvalue", settings.getDefaultResolver().getName()); } + @Test public void testOverrideVariables() throws Exception { String confUrl = IvyConfigureTest.class.getResource("ivysettings-props.xml") .toExternalForm(); @@ -188,6 +201,7 @@ public class IvyConfigureTest extends TestCase { settings.getVariables().getVariable("ivy.retrieve.pattern")); } + @Test public void testExposeAntProperties() throws Exception { String confUrl = IvyConfigureTest.class.getResource("ivysettings-props.xml") .toExternalForm(); @@ -202,6 +216,7 @@ public class IvyConfigureTest extends TestCase { assertEquals("value", configure.getProject().getProperty("ivy.test.variable.this.id")); } + @Test public void testIncludeTwice() throws Exception { // IVY-601 configure.setFile(new File("test/java/org/apache/ivy/ant/ivysettings-include-twice.xml")); @@ -211,6 +226,7 @@ public class IvyConfigureTest extends TestCase { assertNotNull(getIvyInstance()); } + @Test public void testOverrideTrue() throws Exception { configure.setFile(new File("test/repositories/ivysettings.xml")); configure.execute(); @@ -228,6 +244,7 @@ public class IvyConfigureTest extends TestCase { assertTrue(ivy != getIvyInstance()); } + @Test public void testOverrideFalse() throws Exception { configure.setFile(new File("test/repositories/ivysettings.xml")); configure.execute(); @@ -244,6 +261,7 @@ public class IvyConfigureTest extends TestCase { assertTrue(ivy == getIvyInstance()); } + @Test public void testOverrideNotAllowed() throws Exception { configure.setFile(new File("test/repositories/ivysettings.xml")); configure.execute(); @@ -261,17 +279,18 @@ public class IvyConfigureTest extends TestCase { fail("calling settings twice with the same id with " + "override=notallowed should raise an exception"); } catch (BuildException e) { - assertTrue(e.getMessage().indexOf("notallowed") != -1); - assertTrue(e.getMessage().indexOf(configure.getSettingsId()) != -1); + assertTrue(e.getMessage().contains("notallowed")); + assertTrue(e.getMessage().contains(configure.getSettingsId())); } } + @Test public void testInvalidOverride() throws Exception { try { configure.setOverride("unknown"); fail("settings override with invalid value should raise an exception"); } catch (Exception e) { - assertTrue(e.getMessage().indexOf("unknown") != -1); + assertTrue(e.getMessage().contains("unknown")); } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyConvertPomTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyConvertPomTest.java b/test/java/org/apache/ivy/ant/IvyConvertPomTest.java index 1d6ca35..1c47dbb 100644 --- a/test/java/org/apache/ivy/ant/IvyConvertPomTest.java +++ b/test/java/org/apache/ivy/ant/IvyConvertPomTest.java @@ -21,9 +21,10 @@ import java.io.File; import org.apache.ivy.TestHelper; -import junit.framework.TestCase; +import org.junit.Test; -public class IvyConvertPomTest extends TestCase { +public class IvyConvertPomTest { + @Test public void testSimple() throws Exception { IvyConvertPom task = new IvyConvertPom(); task.setProject(TestHelper.newProject()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyDeliverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyDeliverTest.java b/test/java/org/apache/ivy/ant/IvyDeliverTest.java index d29c1c7..9418de9 100644 --- a/test/java/org/apache/ivy/ant/IvyDeliverTest.java +++ b/test/java/org/apache/ivy/ant/IvyDeliverTest.java @@ -35,18 +35,25 @@ import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser; import org.apache.ivy.util.FileUtil; + import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Delete; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -public class IvyDeliverTest extends TestCase { +public class IvyDeliverTest { private IvyDeliver deliver; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { cleanTestDir(); cleanRetrieveDir(); cleanRep(); @@ -61,7 +68,8 @@ public class IvyDeliverTest extends TestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); cleanTestDir(); cleanRetrieveDir(); @@ -89,6 +97,7 @@ public class IvyDeliverTest extends TestCase { del.execute(); } + @Test public void testMergeParent() throws IOException, ParseException { // publish the parent descriptor first, so that it can be found while // we are reading the child descriptor. @@ -148,6 +157,7 @@ public class IvyDeliverTest extends TestCase { } } + @Test public void testSimple() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml"); IvyResolve res = new IvyResolve(); @@ -173,6 +183,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDynamicConstraintDependencyRevisionId()); } + @Test public void testNotGenerateRevConstraint() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml"); IvyResolve res = new IvyResolve(); @@ -199,6 +210,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDynamicConstraintDependencyRevisionId()); } + @Test public void testWithResolveId() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -230,6 +242,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDependencyRevisionId()); } + @Test public void testWithResolveIdInAnotherBuild() throws Exception { // create a new build Project other = TestHelper.newProject(); @@ -267,6 +280,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDependencyRevisionId()); } + @Test public void testReplaceBranchInfo() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml"); IvyResolve res = new IvyResolve(); @@ -287,6 +301,7 @@ public class IvyDeliverTest extends TestCase { md.getModuleRevisionId()); } + @Test public void testWithBranch() throws Exception { // test case for IVY-404 project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest-branch.xml"); @@ -311,6 +326,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDependencyRevisionId()); } + @Test public void testReplaceBranch() throws Exception { IvyConfigure settings = new IvyConfigure(); settings.setProject(project); @@ -346,6 +362,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDynamicConstraintDependencyRevisionId()); } + @Test public void testWithExtraAttributes() throws Exception { // test case for IVY-415 project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest-extra.xml"); @@ -374,6 +391,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDependencyRevisionId()); } + @Test public void testWithDynEvicted() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-dyn-evicted.xml"); IvyResolve res = new IvyResolve(); @@ -419,6 +437,7 @@ public class IvyDeliverTest extends TestCase { expectedFileSet, actualFileSet); } + @Test public void testWithDynEvicted2() throws Exception { // same as previous but dynamic dependency is placed after the one causing the conflict // test case for IVY-707 @@ -467,6 +486,7 @@ public class IvyDeliverTest extends TestCase { list.delete(); } + @Test public void testReplaceImportedConfigurations() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-import-confs.xml"); IvyResolve res = new IvyResolve(); @@ -483,11 +503,12 @@ public class IvyDeliverTest extends TestCase { String deliveredFileContent = FileUtil.readEntirely(new BufferedReader(new FileReader( deliveredIvyFile))); assertTrue("import not replaced: import can still be found in file", - deliveredFileContent.indexOf("import") == -1); + !deliveredFileContent.contains("import")); assertTrue("import not replaced: conf1 cannot be found in file", - deliveredFileContent.indexOf("conf1") != -1); + deliveredFileContent.contains("conf1")); } + @Test public void testReplaceVariables() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-with-variables.xml"); IvyResolve res = new IvyResolve(); @@ -506,11 +527,12 @@ public class IvyDeliverTest extends TestCase { String deliveredFileContent = FileUtil.readEntirely(new BufferedReader(new FileReader( deliveredIvyFile))); assertTrue("variable not replaced: myvar can still be found in file", - deliveredFileContent.indexOf("myvar") == -1); + !deliveredFileContent.contains("myvar")); assertTrue("variable not replaced: myvalue cannot be found in file", - deliveredFileContent.indexOf("myvalue") != -1); + deliveredFileContent.contains("myvalue")); } + @Test public void testNoReplaceDynamicRev() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml"); IvyResolve res = new IvyResolve(); @@ -535,6 +557,7 @@ public class IvyDeliverTest extends TestCase { dds[0].getDependencyRevisionId()); } + @Test public void testDifferentRevisionsForSameModule() throws Exception { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-different-revisions.xml"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/ant/IvyDependencyTreeTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/ant/IvyDependencyTreeTest.java b/test/java/org/apache/ivy/ant/IvyDependencyTreeTest.java index adfe37c..b6d929b 100644 --- a/test/java/org/apache/ivy/ant/IvyDependencyTreeTest.java +++ b/test/java/org/apache/ivy/ant/IvyDependencyTreeTest.java @@ -21,16 +21,24 @@ import java.io.File; import org.apache.ivy.TestHelper; import org.apache.ivy.ant.testutil.AntTaskTestCase; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.fail; + public class IvyDependencyTreeTest extends AntTaskTestCase { private IvyDependencyTree dependencyTree; private Project project; - protected void setUp() throws Exception { + @Before + public void setUp() { TestHelper.createCache(); project = configureProject(); project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); @@ -40,10 +48,12 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { System.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSimple() throws Exception { dependencyTree.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml")); dependencyTree.execute(); @@ -51,6 +61,7 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { assertLogContaining("\\- org1#mod1.2;2.0"); } + @Test public void testEmpty() throws Exception { dependencyTree.setFile(new File("test/java/org/apache/ivy/ant/ivy-empty.xml")); dependencyTree.execute(); @@ -58,6 +69,7 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { assertLogNotContaining("\\-"); } + @Test public void testWithResolveId() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); @@ -76,6 +88,7 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { assertLogContaining("\\- org1#mod1.2;latest.integration"); } + @Test public void testWithResolveIdWithoutResolve() throws Exception { try { dependencyTree.execute(); @@ -85,6 +98,7 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { } } + @Test public void testWithEvictedModule() throws Exception { dependencyTree.setFile(new File("test/java/org/apache/ivy/ant/ivy-dyn-evicted.xml")); dependencyTree.execute(); @@ -95,6 +109,7 @@ public class IvyDependencyTreeTest extends AntTaskTestCase { assertLogContaining("\\- org1#mod1.2;2.2"); } + @Test public void testShowEvictedModule() throws Exception { dependencyTree.setFile(new File("test/java/org/apache/ivy/ant/ivy-dyn-evicted.xml")); dependencyTree.setShowEvicted(true);