http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java index 89e3b57..7b844d6 100644 --- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java +++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java @@ -41,18 +41,22 @@ import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.plugins.repository.BasicResource; import org.apache.ivy.util.FileUtil; -import org.xml.sax.SAXParseException; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Test; + +import org.xml.sax.SAXParseException; -public class XmlModuleUpdaterTest extends TestCase { +import static org.junit.Assert.*; - protected void tearDown() throws Exception { - super.tearDown(); +public class XmlModuleUpdaterTest { + @After + public void tearDown() { XmlModuleDescriptorUpdater.LINE_SEPARATOR = System.getProperty("line.separator"); } + @Test public void testUpdate() throws Exception { /* * For updated file to be equals to updated.xml, we have to fix the line separator to the @@ -93,6 +97,7 @@ public class XmlModuleUpdaterTest extends TestCase { assertEquals(expected, updated); } + @Test public void testUpdateWithComments() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -110,6 +115,7 @@ public class XmlModuleUpdaterTest extends TestCase { assertEquals(3, dependencies.length); } + @Test public void testVariableReplacement() throws Exception { /* * For updated file to be equals to updated.xml, we have to fix the line separator to the @@ -191,6 +197,7 @@ public class XmlModuleUpdaterTest extends TestCase { assertEquals(expected, updated); } + @Test public void testUpdateWithImportedMappingOverride() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -202,9 +209,10 @@ public class XmlModuleUpdaterTest extends TestCase { // just make sure that 'confmappingoverride="true"' is declared somewhere in the XML. assertTrue("Updated XML doesn't define the confmappingoverride attribute", - updatedXml.indexOf("confmappingoverride=\"true\"") != -1); + updatedXml.contains("confmappingoverride=\"true\"")); } + @Test public void testUpdateWithExcludeConfigurations1() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -231,6 +239,7 @@ public class XmlModuleUpdaterTest extends TestCase { assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4")); } + @Test public void testUpdateWithExcludeConfigurations2() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingFile = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -247,6 +256,7 @@ public class XmlModuleUpdaterTest extends TestCase { } } + @Test public void testUpdateWithExcludeConfigurations3() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -279,6 +289,7 @@ public class XmlModuleUpdaterTest extends TestCase { assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4")); } + @Test public void testUpdateWithExcludeConfigurations4() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -305,6 +316,7 @@ public class XmlModuleUpdaterTest extends TestCase { } } + @Test public void testUpdateWithExcludeConfigurations5() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" @@ -333,6 +345,7 @@ public class XmlModuleUpdaterTest extends TestCase { } // IVY-1356 + @Test public void testMergedUpdateWithExtendsAndExcludes() throws Exception { URL url = XmlModuleUpdaterTest.class.getResource("test-extends-dependencies-exclude.xml"); @@ -354,10 +367,9 @@ public class XmlModuleUpdaterTest extends TestCase { // test indentation String updatedXml = buffer.toString(); System.out.println(updatedXml); - assertTrue(updatedXml - .indexOf(XmlModuleDescriptorUpdater.LINE_SEPARATOR - + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\" conf=\"default->default\"/>" - + XmlModuleDescriptorUpdater.LINE_SEPARATOR) != -1); + assertTrue(updatedXml.contains(XmlModuleDescriptorUpdater.LINE_SEPARATOR + + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\" conf=\"default->default\"/>" + + XmlModuleDescriptorUpdater.LINE_SEPARATOR)); } private UpdateOptions getUpdateOptions(String status, String revision) {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/report/XmlReportParserTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/report/XmlReportParserTest.java b/test/java/org/apache/ivy/plugins/report/XmlReportParserTest.java index 8a80a3f..339215c 100644 --- a/test/java/org/apache/ivy/plugins/report/XmlReportParserTest.java +++ b/test/java/org/apache/ivy/plugins/report/XmlReportParserTest.java @@ -24,23 +24,30 @@ import org.apache.ivy.TestHelper; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.ResolveReport; import org.apache.ivy.core.resolve.ResolveOptions; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; -public class XmlReportParserTest extends TestCase { +public class XmlReportParserTest { private Ivy ivy; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { ivy = new Ivy(); ivy.configure(new File("test/repositories/ivysettings.xml")); TestHelper.createCache(); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testGetResolvedModule() throws Exception { ResolveReport report = ivy.resolve( new File("test/java/org/apache/ivy/plugins/report/ivy-with-info.xml"), http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/report/XmlReportWriterTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/report/XmlReportWriterTest.java b/test/java/org/apache/ivy/plugins/report/XmlReportWriterTest.java index 1ba7d4b..638e8c0 100644 --- a/test/java/org/apache/ivy/plugins/report/XmlReportWriterTest.java +++ b/test/java/org/apache/ivy/plugins/report/XmlReportWriterTest.java @@ -26,16 +26,21 @@ import org.apache.ivy.core.report.ResolveReport; import org.apache.ivy.core.resolve.ResolveOptions; import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.XMLHelper; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.xml.sax.helpers.DefaultHandler; -import junit.framework.TestCase; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; -public class XmlReportWriterTest extends TestCase { +public class XmlReportWriterTest { private Ivy _ivy; private File _cache; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { _ivy = new Ivy(); _ivy.configure(new File("test/repositories/ivysettings.xml")); createCache(); @@ -46,7 +51,8 @@ public class XmlReportWriterTest extends TestCase { _cache.mkdirs(); } - protected void tearDown() throws Exception { + @After + public void tearDown() { cleanCache(); } @@ -54,6 +60,7 @@ public class XmlReportWriterTest extends TestCase { CacheCleaner.deleteDir(_cache); } + @Test public void testWriteOrigin() throws Exception { ResolveReport report = _ivy.resolve(new File( "test/repositories/1/special-encoding-root-ivy.xml"), @@ -73,16 +80,17 @@ public class XmlReportWriterTest extends TestCase { String expectedOrg = "organisation=\"sp\u00E9cial\""; assertTrue("XML doesn't contain artifact location attribute", - xml.indexOf(expectedLocation) != -1); + xml.contains(expectedLocation)); assertTrue("XML doesn't contain artifact is-local attribute", - xml.indexOf(expectedIsLocal) != -1); - assertTrue("XML doesn't contain the organisation", xml.indexOf(expectedOrg) != -1); + xml.contains(expectedIsLocal)); + assertTrue("XML doesn't contain the organisation", xml.contains(expectedOrg)); // check that the XML is valid XMLHelper.parse(new ByteArrayInputStream(buffer.toByteArray()), null, new DefaultHandler(), null); } + @Test public void testEscapeXml() throws Exception { _ivy.configure(new File("test/repositories/IVY-635/ivysettings.xml")); ResolveReport report = _ivy.resolve(new File( @@ -98,9 +106,10 @@ public class XmlReportWriterTest extends TestCase { String expectedArtName = "art1&_.txt"; - assertTrue("XML doesn't contain escaped artifact name", xml.indexOf(expectedArtName) != -1); + assertTrue("XML doesn't contain escaped artifact name", xml.contains(expectedArtName)); } + @Test public void testWriteModuleInfo() throws Exception { ResolveReport report = _ivy.resolve(new File( "test/java/org/apache/ivy/plugins/report/ivy-with-info.xml"), @@ -119,11 +128,11 @@ public class XmlReportWriterTest extends TestCase { String extra1Attribute = "extra-blabla=\"abc\""; String extra2Attribute = "extra-blabla2=\"123\""; - assertTrue("XML doesn't contain organisation attribute", xml.indexOf(orgAttribute) != -1); - assertTrue("XML doesn't contain module attribute", xml.indexOf(modAttribute) != -1); - assertTrue("XML doesn't contain revision attribute", xml.indexOf(revAttribute) != -1); - assertTrue("XML doesn't contain extra attribute 1", xml.indexOf(extra1Attribute) != -1); - assertTrue("XML doesn't contain extra attribute 2", xml.indexOf(extra2Attribute) != -1); + assertTrue("XML doesn't contain organisation attribute", xml.contains(orgAttribute)); + assertTrue("XML doesn't contain module attribute", xml.contains(modAttribute)); + assertTrue("XML doesn't contain revision attribute", xml.contains(revAttribute)); + assertTrue("XML doesn't contain extra attribute 1", xml.contains(extra1Attribute)); + assertTrue("XML doesn't contain extra attribute 2", xml.contains(extra2Attribute)); } private ResolveOptions getResolveOptions(String[] confs) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/repository/vfs/VfsRepositoryTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/repository/vfs/VfsRepositoryTest.java b/test/java/org/apache/ivy/plugins/repository/vfs/VfsRepositoryTest.java index ec70ba8..684496d 100644 --- a/test/java/org/apache/ivy/plugins/repository/vfs/VfsRepositoryTest.java +++ b/test/java/org/apache/ivy/plugins/repository/vfs/VfsRepositoryTest.java @@ -23,7 +23,12 @@ import java.util.Iterator; import org.apache.ivy.util.FileUtil; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; /** * Testing Testing was the single biggest hurdle I faced. I have tried to provide a complete test @@ -40,19 +45,15 @@ import junit.framework.TestCase; * (http://jsystemtest.sourceforge.net/) in other projects and am finding it a much better solution * than straight junit. Stephen Nesbitt */ -public class VfsRepositoryTest extends TestCase { +public class VfsRepositoryTest { private VfsRepository repo = null; private VfsTestHelper helper = null; private File scratchDir = null; - public VfsRepositoryTest(String arg0) throws Exception { - super(arg0); - } - - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { helper = new VfsTestHelper(); repo = new VfsRepository(); scratchDir = new File(FileUtil.concat(VfsTestHelper.TEST_REPO_DIR, @@ -60,8 +61,8 @@ public class VfsRepositoryTest extends TestCase { scratchDir.mkdir(); } - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() { repo = null; if (scratchDir.exists()) { FileUtil.forceDelete(scratchDir); @@ -73,6 +74,7 @@ public class VfsRepositoryTest extends TestCase { * * @throws Exception */ + @Test public void testPutValid() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; String srcFile = FileUtil.concat(VfsTestHelper.TEST_REPO_DIR, testResource); @@ -104,6 +106,7 @@ public class VfsRepositoryTest extends TestCase { * * @throws Exception */ + @Test public void testPutOverwriteTrue() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; String srcFile = FileUtil.concat(VfsTestHelper.TEST_REPO_DIR, testResource); @@ -144,6 +147,7 @@ public class VfsRepositoryTest extends TestCase { * * @throws Exception */ + @Test public void testPutOverwriteFalse() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; String srcFile = FileUtil.concat(VfsTestHelper.TEST_REPO_DIR, testResource); @@ -169,6 +173,7 @@ public class VfsRepositoryTest extends TestCase { * * @throws Exception */ + @Test public void testGetNoExisting() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; String testFile = FileUtil.concat(scratchDir.getAbsolutePath(), testResource); @@ -198,6 +203,7 @@ public class VfsRepositoryTest extends TestCase { * * @throws Exception */ + @Test public void testGetOverwriteExisting() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; File testFile = new File(FileUtil.concat(scratchDir.getAbsolutePath(), testResource)); @@ -233,6 +239,7 @@ public class VfsRepositoryTest extends TestCase { * Validate that we get a non null Resource instance when passed a well-formed VfsURI pointing * to an existing file */ + @Test public void testGetResourceValidExist() throws Exception { String testResource = VfsTestHelper.TEST_IVY_XML; @@ -253,6 +260,7 @@ public class VfsRepositoryTest extends TestCase { * Validate that we get a non null Resource instance when passed a well-formed VfsURI pointing * to a non-existent file. */ + @Test public void testGetResourceValidNoExist() throws Exception { String testResource = VfsTestHelper.SCRATCH_DIR + "/nosuchfile.jar"; http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/repository/vfs/VfsResourceTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/repository/vfs/VfsResourceTest.java b/test/java/org/apache/ivy/plugins/repository/vfs/VfsResourceTest.java index d79e4d9..7695a63 100644 --- a/test/java/org/apache/ivy/plugins/repository/vfs/VfsResourceTest.java +++ b/test/java/org/apache/ivy/plugins/repository/vfs/VfsResourceTest.java @@ -26,23 +26,21 @@ import java.util.List; import org.apache.commons.lang.StringUtils; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -public class VfsResourceTest extends TestCase { - private VfsTestHelper helper = null; - - public VfsResourceTest() { - super(); - } +import static org.junit.Assert.fail; - public VfsResourceTest(String arg0) { - super(arg0); - } +public class VfsResourceTest { + private VfsTestHelper helper = null; + @Before public void setUp() throws Exception { helper = new VfsTestHelper(); } + @After public void tearDown() { helper = null; } @@ -50,6 +48,8 @@ public class VfsResourceTest extends TestCase { /** * Validate VFSResource creation for a valid VFS URI pointing to an physically existing file */ + @SuppressWarnings("unused") + @Test public void testCreateResourceThatExists() throws Exception { Iterator vfsURIs = helper.createVFSUriSet(VfsTestHelper.TEST_IVY_XML).iterator(); while (vfsURIs.hasNext()) { @@ -89,7 +89,7 @@ public class VfsResourceTest extends TestCase { * Escape invalid URL characters (Copied from Wicket, just use StringUtils instead of Strings) * * @param queryString - * The orginal querystring + * The original querystring * @return url The querystring with invalid characters escaped */ private String escapeUrl(String queryString) { @@ -109,6 +109,8 @@ public class VfsResourceTest extends TestCase { * Validating that resource can be created for files which don't physically exists - e.g. * resources that are going to created. */ + @SuppressWarnings("unused") + @Test public void testCreateResourceThatDoesntExist() throws Exception { Iterator vfsURIs = helper.createVFSUriSet("zzyyxx.zzyyxx").iterator(); while (vfsURIs.hasNext()) { @@ -148,6 +150,8 @@ public class VfsResourceTest extends TestCase { /** * Validate VFSResource creation when given a poorly formed VFS identifier */ + @SuppressWarnings("unused") + @Test public void testBadURI() throws Exception { String vfsURI = "smb1:/goobeldygook"; VfsResource res = new VfsResource(vfsURI, helper.fsManager); @@ -181,6 +185,7 @@ public class VfsResourceTest extends TestCase { /** * Validate getChildren when given a VFS URI for a directory */ + @Test public void testListFolderChildren() throws Exception { final String testFolder = "2/mod10.1"; final List expectedFiles = Arrays.asList(new String[] {"ivy-1.0.xml", "ivy-1.1.xml", @@ -219,6 +224,7 @@ public class VfsResourceTest extends TestCase { * Validate that we don't get any results when we query a VFSResource file object for its * children */ + @Test public void testListFileChildren() throws Exception { Iterator testSet = helper.createVFSUriSet(VfsTestHelper.TEST_IVY_XML).iterator(); while (testSet.hasNext()) { @@ -235,6 +241,7 @@ public class VfsResourceTest extends TestCase { * Validate that we don't get any results if we ask an IMAGINARY VFSResource - a nonexistent * file - for a list of its children */ + @Test public void testListImaginary() throws Exception { Iterator testSet = helper.createVFSUriSet("idontexistzzxx").iterator(); while (testSet.hasNext()) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/repository/vfs/VfsTestHelper.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/repository/vfs/VfsTestHelper.java b/test/java/org/apache/ivy/plugins/repository/vfs/VfsTestHelper.java index 89c5d40..9bbe0a0 100644 --- a/test/java/org/apache/ivy/plugins/repository/vfs/VfsTestHelper.java +++ b/test/java/org/apache/ivy/plugins/repository/vfs/VfsTestHelper.java @@ -73,7 +73,7 @@ public class VfsTestHelper { * * @param resource * name of the resource - * @return <class>List</class> of well-formed VFS reosurce identifiers + * @return <class>List</class> of well-formed VFS resource identifiers */ public List createVFSUriSet(String resource) { List set = new ArrayList(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/repository/vfs/VfsURI.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/repository/vfs/VfsURI.java b/test/java/org/apache/ivy/plugins/repository/vfs/VfsURI.java index 1ae03ac..0247373 100644 --- a/test/java/org/apache/ivy/plugins/repository/vfs/VfsURI.java +++ b/test/java/org/apache/ivy/plugins/repository/vfs/VfsURI.java @@ -51,10 +51,12 @@ public class VfsURI { /** * Create a set of valid VFS URIs for the file access protocol - * - * @param resourcePath + * + * @param scheme String + * @param resource * relative path (from the base repo) to the resource to be accessed - * @return + * @param ivy Ivy + * @return VfsURI */ public static VfsURI vfsURIFactory(String scheme, String resource, Ivy ivy) { VfsURI vfsURI = null; @@ -84,7 +86,7 @@ public class VfsURI { * Create a wellformed VFS resource identifier * * @param scheme - * the name of the scheme used to acces the resource + * the name of the scheme used to access the resource * @param user * a user name. May be <code>null</code> * @param passwd @@ -92,7 +94,7 @@ public class VfsURI { * @param host * a host identifier. May be <code>null</code> * @param path - * a scheme spacific path to a resource + * a scheme specific path to a resource */ public VfsURI(String scheme, String user, String passwd, String host, String path) { this.scheme = scheme.trim(); @@ -124,19 +126,19 @@ public class VfsURI { * @return <code>String<code> representing a well formed VFS resource identifier */ public String getVfsURI() { - StringBuffer uri = new StringBuffer(); - uri.append(this.scheme + "://"); + StringBuilder uri = new StringBuilder(); + uri.append(this.scheme).append("://"); // not all resource identifiers include user/passwd specifiers if (user != null && user.trim().length() > 0) { - uri.append(this.user + ":"); + uri.append(this.user).append(":"); if (passwd != null && passwd.trim().length() > 0) { this.passwd = passwd.trim(); } else { this.passwd = ""; } - uri.append(this.passwd + "@"); + uri.append(this.passwd).append("@"); } // not all resource identifiers include a host specifier http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/AbstractDependencyResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/AbstractDependencyResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/AbstractDependencyResolverTest.java index 40bf4f2..e02fe67 100644 --- a/test/java/org/apache/ivy/plugins/resolver/AbstractDependencyResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/AbstractDependencyResolverTest.java @@ -19,9 +19,7 @@ package org.apache.ivy.plugins.resolver; import org.apache.ivy.core.resolve.DownloadOptions; -import junit.framework.TestCase; - -public class AbstractDependencyResolverTest extends TestCase { +public class AbstractDependencyResolverTest { protected DownloadOptions downloadOptions() { return new DownloadOptions(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/BintrayResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/BintrayResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/BintrayResolverTest.java index a3596f7..8a1c59d 100644 --- a/test/java/org/apache/ivy/plugins/resolver/BintrayResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/BintrayResolverTest.java @@ -37,6 +37,13 @@ import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.sort.SortEngine; import org.apache.ivy.plugins.matcher.ExactPatternMatcher; import org.apache.ivy.util.MockMessageLogger; +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.assertNull; public class BintrayResolverTest extends AbstractDependencyResolverTest { @@ -46,25 +53,27 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { private ResolveData _data; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { _settings = new IvySettings(); _engine = new ResolveEngine(_settings, new EventManager(), new SortEngine(_settings)); _data = new ResolveData(_engine, new ResolveOptions()); _settings.setDefaultCache(TestHelper.cache); } - @Override - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testDefaults() { BintrayResolver resolver = new BintrayResolver(); assertEquals("https://jcenter.bintray.com/", resolver.getRoot()); assertEquals("bintray/jcenter", resolver.getName()); } + @Test public void testDefaultsWithName() { BintrayResolver resolver = new BintrayResolver(); resolver.setName("TestName"); @@ -72,6 +81,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("TestName", resolver.getName()); } + @Test public void testSubjectOnly() { BintrayResolver resolver = new BintrayResolver(); resolver.setSubject("jfrog"); @@ -79,6 +89,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("bintray/jcenter", resolver.getName()); } + @Test public void testRepoOnly() { BintrayResolver resolver = new BintrayResolver(); resolver.setRepo("jfrog-jars"); @@ -86,6 +97,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("bintray/jcenter", resolver.getName()); } + @Test public void testSubjectOnlyWithName() { BintrayResolver resolver = new BintrayResolver(); resolver.setSubject("jfrog"); @@ -94,6 +106,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("TestName", resolver.getName()); } + @Test public void testRepoOnlyWithName() { BintrayResolver resolver = new BintrayResolver(); resolver.setRepo("jfrog-jars"); @@ -102,6 +115,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("TestName", resolver.getName()); } + @Test public void testSubjectAndRepo() { BintrayResolver resolver = new BintrayResolver(); resolver.setSubject("jfrog"); @@ -110,6 +124,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("bintray/jfrog/jfrog-jars", resolver.getName()); } + @Test public void testSubjectAndRepoWithName() { BintrayResolver resolver = new BintrayResolver(); resolver.setSubject("jfrog"); @@ -119,6 +134,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals("TestName", resolver.getName()); } + @Test public void testBintray() throws Exception { BintrayResolver resolver = new BintrayResolver(); @@ -156,6 +172,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } + @Test public void testErrorReport() throws Exception { BintrayResolver resolver = new BintrayResolver(); resolver.setSubject("unknown"); @@ -180,6 +197,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { .assertLogContains("tried https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar"); } + @Test public void testBintrayArtifacts() throws Exception { BintrayResolver resolver = new BintrayResolver(); resolver.setName("test"); @@ -238,6 +256,7 @@ public class BintrayResolverTest extends AbstractDependencyResolverTest { assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } + @Test public void testUnknown() throws Exception { BintrayResolver resolver = new BintrayResolver(); resolver.setName("test"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java index 9ff1a39..0f5c734 100644 --- a/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java @@ -44,6 +44,13 @@ import org.apache.ivy.core.sort.SortEngine; import org.apache.ivy.plugins.latest.LatestRevisionStrategy; import org.apache.ivy.plugins.latest.LatestTimeStrategy; import org.apache.ivy.util.MockMessageLogger; +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; /** * Tests ChainResolver @@ -56,7 +63,8 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { private ResolveData data; - protected void setUp() throws Exception { + @Before + public void setUp() { settings = new IvySettings(); engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings)); TestHelper.createCache(); @@ -64,10 +72,12 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { settings.setDefaultCache(TestHelper.cache); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testOrderFromConf() throws Exception { new XmlSettingsParser(settings).parse(ChainResolverTest.class .getResource("chainresolverconf.xml")); @@ -87,6 +97,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testName() throws Exception { ChainResolver chain = new ChainResolver(); chain.setSettings(settings); @@ -94,6 +105,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { assertEquals("chain", chain.getName()); } + @Test public void testResolveOrder() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); @@ -102,8 +114,8 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, null), MockResolver.buildMockResolver(settings, "3", true, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -117,24 +129,26 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { assertTrue(resolvers[2].askedDeps.isEmpty()); } + @Test public void testLatestTimeResolve() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); chain.setSettings(settings); settings.setDefaultLatestStrategy(new LatestTimeStrategy()); MockResolver[] resolvers = new MockResolver[] { - MockResolver.buildMockResolver(settings, "1", true, new GregorianCalendar(2005, 1, - 20).getTime()), + MockResolver.buildMockResolver(settings, "1", true, + new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", false, null), - MockResolver.buildMockResolver(settings, "3", true, new GregorianCalendar(2005, 1, - 25).getTime()), // younger -> should the one kept + MockResolver.buildMockResolver(settings, "3", true, + new GregorianCalendar(2005, 1, 25).getTime()), // younger -> should the one kept MockResolver.buildMockResolver(settings, "4", false, null), - MockResolver.buildMockResolver(settings, "5", true, new GregorianCalendar(2005, 1, - 22).getTime()), - MockResolver.buildMockResolver(settings, "6", true, new GregorianCalendar(2005, 1, - 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + MockResolver.buildMockResolver(settings, "5", true, + new GregorianCalendar(2005, 1, 22).getTime()), + MockResolver.buildMockResolver(settings, "6", true, + new GregorianCalendar(2005, 1, 18).getTime()), + MockResolver.buildMockResolver(settings, "7", false, null)}; + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -149,27 +163,32 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testLatestRevisionResolve() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); chain.setSettings(settings); chain.setLatestStrategy(new LatestRevisionStrategy()); MockResolver[] resolvers = new MockResolver[] { - MockResolver.buildMockResolver(settings, "1", true, ModuleRevisionId.newInstance( - "org", "mod", "1"), new GregorianCalendar(2005, 1, 20).getTime()), + MockResolver.buildMockResolver(settings, "1", true, + ModuleRevisionId.newInstance("org", "mod", "1"), + new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", false, null), - MockResolver.buildMockResolver(settings, "3", true, ModuleRevisionId.newInstance( - "org", "mod", "2"), new GregorianCalendar(2005, 1, 25).getTime()), + MockResolver.buildMockResolver(settings, "3", true, + ModuleRevisionId.newInstance("org", "mod", "2"), + new GregorianCalendar(2005, 1, 25).getTime()), MockResolver.buildMockResolver(settings, "4", false, null), - MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> + MockResolver.buildMockResolver(settings, "5", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime()), // latest -> // should the // one kept - MockResolver.buildMockResolver(settings, "6", true, ModuleRevisionId.newInstance( - "org", "mod", "3"), new GregorianCalendar(2005, 1, 18).getTime()), + MockResolver.buildMockResolver(settings, "6", true, + ModuleRevisionId.newInstance("org", "mod", "3"), + new GregorianCalendar(2005, 1, 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -184,6 +203,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testWithDefault() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); @@ -191,21 +211,23 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { chain.setLatestStrategy(new LatestRevisionStrategy()); MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), - MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest + MockResolver.buildMockResolver(settings, "2", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime(), true), // latest // -> // but // default MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", false, null), - MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> + MockResolver.buildMockResolver(settings, "5", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime()), // latest -> // should the // one kept MockResolver.buildMockResolver(settings, "6", false, null), MockResolver.buildMockResolver(settings, "7", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -223,31 +245,37 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testLatestWithDefault() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); chain.setSettings(settings); chain.setLatestStrategy(new LatestRevisionStrategy()); MockResolver[] resolvers = new MockResolver[] { - MockResolver.buildMockResolver(settings, "1", true, ModuleRevisionId.newInstance( - "org", "mod", "1"), new GregorianCalendar(2005, 1, 20).getTime()), - MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest + MockResolver.buildMockResolver(settings, "1", true, + ModuleRevisionId.newInstance("org", "mod", "1"), + new GregorianCalendar(2005, 1, 20).getTime()), + MockResolver.buildMockResolver(settings, "2", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime(), true), // latest // -> // but // default - MockResolver.buildMockResolver(settings, "3", true, ModuleRevisionId.newInstance( - "org", "mod", "2"), new GregorianCalendar(2005, 1, 25).getTime()), + MockResolver.buildMockResolver(settings, "3", true, + ModuleRevisionId.newInstance("org", "mod", "2"), + new GregorianCalendar(2005, 1, 25).getTime()), MockResolver.buildMockResolver(settings, "4", false, null), - MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> + MockResolver.buildMockResolver(settings, "5", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime()), // latest -> // should the // one kept - MockResolver.buildMockResolver(settings, "6", true, ModuleRevisionId.newInstance( - "org", "mod", "3"), new GregorianCalendar(2005, 1, 18).getTime()), + MockResolver.buildMockResolver(settings, "6", true, + ModuleRevisionId.newInstance("org", "mod", "3"), + new GregorianCalendar(2005, 1, 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -262,6 +290,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testFixedWithDefault() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); @@ -269,17 +298,19 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { chain.setLatestStrategy(new LatestRevisionStrategy()); MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), - MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // default + MockResolver.buildMockResolver(settings, "2", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime(), true), // default MockResolver.buildMockResolver(settings, "3", false, null), - MockResolver.buildMockResolver(settings, "4", true, ModuleRevisionId.newInstance( - "org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // not - // default + MockResolver.buildMockResolver(settings, "4", true, + ModuleRevisionId.newInstance("org", "mod", "4"), + new GregorianCalendar(2005, 1, 22).getTime()), // not + // default // -> should the // one kept MockResolver.buildMockResolver(settings, "5", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -299,6 +330,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testFixedWithDefaultAndRealResolver() throws Exception { // test case for IVY-206 ChainResolver chain = new ChainResolver(); @@ -335,6 +367,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { assertEquals("2", rmr.getResolver().getName()); } + @Test public void testUseCache() throws Exception { DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor( ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false); @@ -361,18 +394,19 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { chain.setReturnFirst(true); MockResolver[] resolvers = new MockResolver[] { - MockResolver.buildMockResolver(settings, "1", true, new GregorianCalendar(2005, 1, - 20).getTime()), + MockResolver.buildMockResolver(settings, "1", true, + new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", false, null), - MockResolver.buildMockResolver(settings, "3", true, new GregorianCalendar(2005, 1, - 25).getTime()), // younger -> should the one kept + MockResolver.buildMockResolver(settings, "3", true, + new GregorianCalendar(2005, 1, 25).getTime()), // younger -> should the one kept MockResolver.buildMockResolver(settings, "4", false, null), - MockResolver.buildMockResolver(settings, "5", true, new GregorianCalendar(2005, 1, - 22).getTime()), - MockResolver.buildMockResolver(settings, "6", true, new GregorianCalendar(2005, 1, - 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + MockResolver.buildMockResolver(settings, "5", true, + new GregorianCalendar(2005, 1, 22).getTime()), + MockResolver.buildMockResolver(settings, "6", true, + new GregorianCalendar(2005, 1, 18).getTime()), + MockResolver.buildMockResolver(settings, "7", false, null)}; + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -386,6 +420,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testReturnFirstWithDefaultAndCacheAndRealResolver() throws Exception { // test case for IVY-389 DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor( @@ -473,6 +508,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { return chain; } + @Test public void testDual() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); @@ -482,8 +518,8 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, null), MockResolver.buildMockResolver(settings, "3", true, null)}; - for (int i = 0; i < resolvers.length; i++) { - chain.add(resolvers[i]); + for (MockResolver resolver : resolvers) { + chain.add(resolver); } assertResolversSizeAndNames(chain, resolvers.length); @@ -495,6 +531,7 @@ public class ChainResolverTest extends AbstractDependencyResolverTest { assertEquals("chain", rmr.getArtifactResolver().getName()); } + @Test public void testDownloadWithDual() throws Exception { ChainResolver chain = new ChainResolver(); chain.setName("chain"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/DualResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/DualResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/DualResolverTest.java index 0be03a0..103ace0 100644 --- a/test/java/org/apache/ivy/plugins/resolver/DualResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/DualResolverTest.java @@ -18,6 +18,8 @@ package org.apache.ivy.plugins.resolver; import java.io.File; +import java.io.IOException; +import java.text.ParseException; import java.util.Arrays; import java.util.GregorianCalendar; @@ -33,6 +35,11 @@ import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.settings.XmlSettingsParser; import org.apache.ivy.core.sort.SortEngine; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Test for DualResolver */ @@ -45,7 +52,8 @@ public class DualResolverTest extends AbstractDependencyResolverTest { private File _cache; - protected void setUp() throws Exception { + @Before + public void setUp() { _settings = new IvySettings(); _engine = new ResolveEngine(_settings, new EventManager(), new SortEngine(_settings)); _cache = new File("build/cache"); @@ -54,6 +62,7 @@ public class DualResolverTest extends AbstractDependencyResolverTest { _settings.setDefaultCache(_cache); } + @Test public void testFromConf() throws Exception { new XmlSettingsParser(_settings).parse(DualResolverTest.class .getResource("dualresolverconf.xml")); @@ -75,29 +84,24 @@ public class DualResolverTest extends AbstractDependencyResolverTest { assertNull(dual.getArtifactResolver()); } - public void testFromBadConf() throws Exception { - try { - new XmlSettingsParser(_settings).parse(DualResolverTest.class - .getResource("dualresolverconf-bad.xml")); - fail("bad dual resolver configuration should raise exception"); - } catch (Exception ex) { - // ok -> bad conf has raised an exception - } + @Test(expected = ParseException.class) + public void testFromBadConf() throws IOException, ParseException { + new XmlSettingsParser(_settings).parse(DualResolverTest.class + .getResource("dualresolverconf-bad.xml")); + fail("bad dual resolver configuration should raise exception"); } - public void testBad() throws Exception { + @Test(expected = IllegalStateException.class) + public void testBad() throws ParseException { DualResolver dual = new DualResolver(); dual.setIvyResolver(new IBiblioResolver()); DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor( ModuleRevisionId.newInstance("org", "mod", "rev"), false); - try { - dual.getDependency(dd, _data); - fail("bad dual resolver configuration should raise exception"); - } catch (Exception ex) { - // ok -> should have raised an exception - } + dual.getDependency(dd, _data); + fail("bad dual resolver configuration should raise exception"); } + @Test public void testResolve() throws Exception { DualResolver dual = new DualResolver(); MockResolver ivyResolver = MockResolver.buildMockResolver(_settings, "ivy", true, @@ -116,6 +120,7 @@ public class DualResolverTest extends AbstractDependencyResolverTest { assertTrue(artifactResolver.askedDeps.isEmpty()); } + @Test public void testResolveFromArtifact() throws Exception { DualResolver dual = new DualResolver(); MockResolver ivyResolver = MockResolver.buildMockResolver(_settings, "ivy", false, @@ -134,6 +139,7 @@ public class DualResolverTest extends AbstractDependencyResolverTest { assertEquals(Arrays.asList(new DependencyDescriptor[] {dd}), artifactResolver.askedDeps); } + @Test public void testResolveFail() throws Exception { DualResolver dual = new DualResolver(); MockResolver ivyResolver = MockResolver.buildMockResolver(_settings, "ivy", false, http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java index c692a3c..5467e6a 100644 --- a/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/FileSystemResolverTest.java @@ -48,6 +48,11 @@ import org.apache.ivy.plugins.latest.LatestTimeStrategy; import org.apache.ivy.plugins.resolver.util.ResolvedResource; import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.FileUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; /** * @@ -77,7 +82,8 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { setupLastModified(); } - protected void setUp() throws Exception { + @Before + public void setUp() { settings = new IvySettings(); engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings)); cache = new File("build/cache"); @@ -100,10 +106,12 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { new File("test/repositories/1/org1/mod1.1/ivys/ivy-2.0.xml").setLastModified(time); } - protected void tearDown() throws Exception { + @After + public void tearDown() { CacheCleaner.deleteDir(cache); } + @Test public void testFixedRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -149,6 +157,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } + @Test public void testFindIvyFileRefWithMultipleIvyPatterns() throws Exception { // cfr IVY-676 FileSystemResolver resolver = new FileSystemResolver(); @@ -173,6 +182,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { return new DownloadOptions(); } + @Test public void testMaven2() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -196,6 +206,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { resolver.reportFailure(); } + @Test public void testChecksum() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -246,6 +257,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { * Tests that <code>SHA-256</code> algorithm can be used for checksums on resolvers * @throws Exception */ + @Test public void testSHA256Checksum() throws Exception { final FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("sha256-checksum-resolver"); @@ -275,6 +287,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { * Tests that <code>SHA-512</code> algorithm can be used for checksums on resolvers * @throws Exception */ + @Test public void testSHA512Checksum() throws Exception { final FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("sha256-checksum-resolver"); @@ -300,6 +313,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals("Unexpected revision of downloaded artifact", "3.0", downloadedArtifact.getModuleRevisionId().getRevision()); } + @Test public void testCheckModified() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -347,6 +361,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testNoRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -418,6 +433,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { r.close(); } + @Test public void testChanging() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -497,6 +513,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { r.close(); } + @Test public void testLatestTime() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -519,6 +536,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testLatestRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -541,6 +559,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testRelativePath() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -563,6 +582,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testFormattedLatestTime() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -585,6 +605,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testFormattedLatestRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -607,6 +628,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { assertEquals(pubdate, rmr.getPublicationDate()); } + @Test public void testPublish() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -639,6 +661,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testPublishOverwrite() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -680,6 +703,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { file.createNewFile(); } + @Test public void testPublishTransaction() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -719,6 +743,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testPublishTransactionWithBranch() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -761,6 +786,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testPublishTransactionWithSubDirectories() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -802,6 +828,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testPublishTransactionWithDottedOrganisation() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -845,6 +872,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testAbortTransaction() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -875,6 +903,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testUnsupportedTransaction() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -897,13 +926,14 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { resolver.publish(artifact, src, false); fail("publishing with transaction=true and an unsupported pattern should raise an exception"); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().indexOf("transactional") != -1); + assertTrue(ex.getMessage().contains("transactional")); } } finally { FileUtil.forceDelete(new File("test/repositories/1/myorg")); } } + @Test public void testUnsupportedTransaction2() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -928,13 +958,14 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { resolver.publish(artifact, src, false); fail("publishing with transaction=true and an unsupported combination of patterns should raise an exception"); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().indexOf("transactional") != -1); + assertTrue(ex.getMessage().contains("transactional")); } } finally { FileUtil.forceDelete(new File("test/repositories/1/myorg")); } } + @Test public void testUnsupportedTransaction3() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -956,13 +987,14 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { resolver.publish(artifact, src, true); fail("publishing with transaction=true and overwrite mode should raise an exception"); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().indexOf("transactional") != -1); + assertTrue(ex.getMessage().contains("transactional")); } } finally { FileUtil.forceDelete(new File("test/repositories/1/myorg")); } } + @Test public void testDisableTransaction() throws Exception { try { FileSystemResolver resolver = new FileSystemResolver(); @@ -1002,6 +1034,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testListing() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); @@ -1032,6 +1065,7 @@ public class FileSystemResolverTest extends AbstractDependencyResolverTest { "2.0", "2.1", "2.2"}, revs); } + @Test public void testDownloadWithUseOriginIsTrue() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java index 29291ce..6749dd8 100644 --- a/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java @@ -47,6 +47,11 @@ import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.sort.SortEngine; import org.apache.ivy.plugins.matcher.ExactPatternMatcher; import org.apache.ivy.util.MockMessageLogger; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; /** * @@ -60,7 +65,8 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { private ResolveData _data; - protected void setUp() throws Exception { + @Before + public void setUp() { _settings = new IvySettings(); _engine = new ResolveEngine(_settings, new EventManager(), new SortEngine(_settings)); _data = new ResolveData(_engine, new ResolveOptions()); @@ -68,10 +74,12 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { _settings.setDefaultCache(TestHelper.cache); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testDefaults() { IBiblioResolver resolver = new IBiblioResolver(); _settings.setVariable("ivy.ibiblio.default.artifact.root", @@ -86,6 +94,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { l.get(0)); } + @Test public void testInitFromConf() throws Exception { _settings.setVariable("ivy.ibiblio.default.artifact.root", "http://www.ibiblio.org/maven/"); _settings.setVariable("ivy.ibiblio.default.artifact.pattern", @@ -149,6 +158,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { l.get(0)); } + @Test public void testIBiblio() throws Exception { String ibiblioRoot = IBiblioHelper.getIBiblioMirror(); if (ibiblioRoot == null) { @@ -193,6 +203,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } + @Test public void testMaven2Listing() throws Exception { IBiblioResolver resolver = new IBiblioResolver(); resolver.setName("test"); @@ -227,6 +238,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { assertEquals("commons-lang", values[0]); } + @Test public void testErrorReport() throws Exception { IBiblioResolver resolver = new IBiblioResolver(); resolver.setRoot("http://unknown.host.comx/"); @@ -250,6 +262,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { .assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar"); } + @Test public void testIBiblioArtifacts() throws Exception { String ibiblioRoot = IBiblioHelper.getIBiblioMirror(); if (ibiblioRoot == null) { @@ -313,6 +326,7 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest { assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } + @Test public void testUnknown() throws Exception { String ibiblioRoot = IBiblioHelper.getIBiblioMirror(); if (ibiblioRoot == null) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java index 322c576..8900a71 100644 --- a/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java @@ -35,6 +35,11 @@ import org.apache.ivy.core.resolve.ResolveOptions; import org.apache.ivy.core.resolve.ResolvedModuleRevision; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.sort.SortEngine; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; /** * @@ -46,7 +51,8 @@ public class IvyRepResolverTest extends AbstractDependencyResolverTest { private ResolveData _data; - protected void setUp() throws Exception { + @Before + public void setUp() { _settings = new IvySettings(); _engine = new ResolveEngine(_settings, new EventManager(), new SortEngine(_settings)); _data = new ResolveData(_engine, new ResolveOptions()); @@ -54,10 +60,12 @@ public class IvyRepResolverTest extends AbstractDependencyResolverTest { _settings.setDefaultCache(TestHelper.cache); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testDefaults() { IvyRepResolver resolver = new IvyRepResolver(); _settings.setVariable("ivy.ivyrep.default.ivy.root", "http://www.jayasoft.fr/myivyrep/"); @@ -81,6 +89,7 @@ public class IvyRepResolverTest extends AbstractDependencyResolverTest { l.get(0)); } + @Test public void testMandatoryRoot() throws Exception { // IVY-625: should fail if no ivyroot specified IvyRepResolver resolver = new IvyRepResolver(); @@ -93,11 +102,12 @@ public class IvyRepResolverTest extends AbstractDependencyResolverTest { fail("using ivyrep resolver without ivyroot should raise an exception"); } catch (IllegalStateException ex) { assertTrue( - "exception thrown when using ivyrep with no ivyroot should talk about the root", ex - .getMessage().indexOf("ivyroot") != -1); + "exception thrown when using ivyrep with no ivyroot should talk about the root", + ex.getMessage().contains("ivyroot")); } } + @Test public void testIvyRepWithLocalURL() throws Exception { IvyRepResolver resolver = new IvyRepResolver(); String rootpath = new File("test/repositories/1").getAbsolutePath(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java index 86570c8..e0752fb 100644 --- a/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java @@ -30,10 +30,13 @@ import org.apache.ivy.core.resolve.ResolvedModuleRevision; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.sort.SortEngine; import org.apache.ivy.util.CacheCleaner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertNotNull; -public class JarResolverTest extends TestCase { +public class JarResolverTest { private IvySettings settings; @@ -43,9 +46,11 @@ public class JarResolverTest extends TestCase { private ResolveData data; + @SuppressWarnings("unused") private DefaultRepositoryCacheManager cacheManager; - protected void setUp() throws Exception { + @Before + public void setUp() { settings = new IvySettings(); engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings)); cache = new File("build/cache"); @@ -55,10 +60,12 @@ public class JarResolverTest extends TestCase { cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager(); } - protected void tearDown() throws Exception { + @After + public void tearDown() { CacheCleaner.deleteDir(cache); } + @Test public void testSimpleFile() throws Exception { JarResolver resolver = new JarResolver(); resolver.setName("jarresolver1"); @@ -73,6 +80,7 @@ public class JarResolverTest extends TestCase { assertNotNull(rmr); } + @Test public void testSubdirInFile() throws Exception { JarResolver resolver = new JarResolver(); resolver.setName("jarresolver1_subdir"); @@ -87,6 +95,7 @@ public class JarResolverTest extends TestCase { assertNotNull(rmr); } + @Test public void testUrl() throws Exception { JarResolver resolver = new JarResolver(); resolver.setName("jarresolver1"); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/Maven2LocalTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/Maven2LocalTest.java b/test/java/org/apache/ivy/plugins/resolver/Maven2LocalTest.java index b49ab55..f3cabfc 100644 --- a/test/java/org/apache/ivy/plugins/resolver/Maven2LocalTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/Maven2LocalTest.java @@ -30,10 +30,14 @@ import org.apache.ivy.core.resolve.ResolvedModuleRevision; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.sort.SortEngine; import org.apache.ivy.util.CacheCleaner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; -public class Maven2LocalTest extends TestCase { +public class Maven2LocalTest { private IvySettings settings; private ResolveEngine engine; @@ -42,7 +46,8 @@ public class Maven2LocalTest extends TestCase { private File cache; - protected void setUp() throws Exception { + @Before + public void setUp() { settings = new IvySettings(); engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings)); cache = new File("build/cache"); @@ -51,10 +56,12 @@ public class Maven2LocalTest extends TestCase { settings.setDefaultCache(cache); } - protected void tearDown() throws Exception { + @After + public void tearDown() { CacheCleaner.deleteDir(cache); } + @Test public void testUseMetadataForListing() throws Exception { IBiblioResolver resolver = maven2Resolver(); @@ -67,6 +74,7 @@ public class Maven2LocalTest extends TestCase { assertEquals(ModuleRevisionId.newInstance("org.apache", "test-metadata", "1.1"), m.getId()); } + @Test public void testNotUseMetadataForListing() throws Exception { IBiblioResolver resolver = maven2Resolver(); resolver.setUseMavenMetadata(false); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java index 06b0ea9..d23f947 100644 --- a/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java @@ -28,10 +28,15 @@ import org.apache.ivy.core.resolve.ResolvedModuleRevision; import org.apache.ivy.core.settings.IvySettings; import org.apache.ivy.core.settings.XmlSettingsParser; import org.apache.ivy.core.sort.SortEngine; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -public class MirroredURLResolverTest extends TestCase { +public class MirroredURLResolverTest { private IvySettings settings; @@ -39,7 +44,8 @@ public class MirroredURLResolverTest extends TestCase { private ResolveData data; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { settings = new IvySettings(); engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings)); data = new ResolveData(engine, new ResolveOptions()); @@ -55,10 +61,12 @@ public class MirroredURLResolverTest extends TestCase { .getResource("mirror-resolver-settings.xml")); } - protected void tearDown() throws Exception { + @After + public void tearDown() { TestHelper.cleanCache(); } + @Test public void testSolo() throws Exception { DependencyResolver resolver = settings.getResolver("solo"); assertNotNull(resolver); @@ -71,6 +79,7 @@ public class MirroredURLResolverTest extends TestCase { assertNotNull(rmr); } + @Test public void testFailover() throws Exception { DependencyResolver resolver = settings.getResolver("failover"); assertNotNull(resolver); @@ -83,6 +92,7 @@ public class MirroredURLResolverTest extends TestCase { assertNotNull(rmr); } + @Test public void testFail() throws Exception { DependencyResolver resolver = settings.getResolver("fail"); assertNotNull(resolver); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/MockResolver.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/MockResolver.java b/test/java/org/apache/ivy/plugins/resolver/MockResolver.java index aa0ecbd..bfedc55 100644 --- a/test/java/org/apache/ivy/plugins/resolver/MockResolver.java +++ b/test/java/org/apache/ivy/plugins/resolver/MockResolver.java @@ -94,8 +94,8 @@ public class MockResolver extends AbstractResolver { public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { DownloadReport dr = new DownloadReport(); - for (int i = 0; i < artifacts.length; i++) { - dr.addArtifactReport(new ArtifactDownloadReport(artifacts[i])); + for (Artifact artifact : artifacts) { + dr.addArtifactReport(new ArtifactDownloadReport(artifact)); } return dr; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java index fefb609..e897c51 100644 --- a/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/PackagerResolverTest.java @@ -41,6 +41,12 @@ import org.apache.ivy.util.DefaultMessageLogger; import org.apache.ivy.util.FileUtil; import org.apache.ivy.util.Message; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Tests PackagerResolver. */ @@ -58,7 +64,8 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { private File cachedir; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { Message.setDefaultLogger(new DefaultMessageLogger(99)); settings = new IvySettings(); @@ -79,7 +86,8 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { } } - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { FileUtil.forceDelete(cache); cleanupTempDirs(); } @@ -88,6 +96,7 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { FileUtil.forceDelete(workdir); } + @Test public void testFile() throws Exception { Locale oldLocale = Locale.getDefault(); @@ -132,7 +141,7 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); - System.out.println("downloaddetails: " + ar.getDownloadDetails()); + System.out.println("download details: " + ar.getDownloadDetails()); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); @@ -170,6 +179,7 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testZipResourceInclusion() throws Exception { Locale oldLocale = Locale.getDefault(); @@ -217,6 +227,7 @@ public class PackagerResolverTest extends AbstractDependencyResolverTest { } } + @Test public void testTarResourceInclusion() throws Exception { Locale oldLocale = Locale.getDefault(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/1543f528/test/java/org/apache/ivy/plugins/resolver/ResolverTestHelper.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/resolver/ResolverTestHelper.java b/test/java/org/apache/ivy/plugins/resolver/ResolverTestHelper.java index e0d941b..84da8aa 100644 --- a/test/java/org/apache/ivy/plugins/resolver/ResolverTestHelper.java +++ b/test/java/org/apache/ivy/plugins/resolver/ResolverTestHelper.java @@ -23,7 +23,7 @@ import org.apache.ivy.core.search.ModuleEntry; import org.apache.ivy.core.search.OrganisationEntry; import org.apache.ivy.core.search.RevisionEntry; -import junit.framework.Assert; +import static org.junit.Assert.*; /** * @@ -31,8 +31,8 @@ import junit.framework.Assert; public class ResolverTestHelper { static void assertOrganisationEntries(DependencyResolver resolver, String[] orgNames, OrganisationEntry[] orgs) { - Assert.assertNotNull(orgs); - Assert.assertEquals( + assertNotNull(orgs); + assertEquals( "invalid organisation entries: unmatched number: expected: " + Arrays.asList(orgNames) + " but was " + Arrays.asList(orgs), orgNames.length, orgs.length); assertOrganisationEntriesContains(resolver, orgNames, orgs); @@ -40,23 +40,23 @@ public class ResolverTestHelper { static void assertOrganisationEntriesContains(DependencyResolver resolver, String[] orgNames, OrganisationEntry[] orgs) { - Assert.assertNotNull(orgs); - for (int i = 0; i < orgNames.length; i++) { + assertNotNull(orgs); + for (String orgName : orgNames) { boolean found = false; - for (int j = 0; j < orgs.length; j++) { - if (orgNames[i].equals(orgs[j].getOrganisation())) { + for (OrganisationEntry org : orgs) { + if (orgName.equals(org.getOrganisation())) { found = true; - Assert.assertEquals(resolver, orgs[j].getResolver()); + assertEquals(resolver, org.getResolver()); } } - Assert.assertTrue("organisation not found: " + orgNames[i], found); + assertTrue("organisation not found: " + orgName, found); } } static void assertModuleEntries(DependencyResolver resolver, OrganisationEntry org, String[] names, ModuleEntry[] mods) { - Assert.assertNotNull(mods); - Assert.assertEquals( + assertNotNull(mods); + assertEquals( "invalid module entries: unmatched number: expected: " + Arrays.asList(names) + " but was " + Arrays.asList(mods), names.length, mods.length); assertModuleEntriesContains(resolver, org, names, mods); @@ -64,24 +64,24 @@ public class ResolverTestHelper { static void assertModuleEntriesContains(DependencyResolver resolver, OrganisationEntry org, String[] names, ModuleEntry[] mods) { - Assert.assertNotNull(mods); - for (int i = 0; i < names.length; i++) { + assertNotNull(mods); + for (String name : names) { boolean found = false; - for (int j = 0; j < mods.length; j++) { - if (names[i].equals(mods[j].getModule())) { + for (ModuleEntry mod : mods) { + if (name.equals(mod.getModule())) { found = true; - Assert.assertEquals(resolver, mods[j].getResolver()); - Assert.assertEquals(org, mods[j].getOrganisationEntry()); + assertEquals(resolver, mod.getResolver()); + assertEquals(org, mod.getOrganisationEntry()); } } - Assert.assertTrue("module not found: " + names[i], found); + assertTrue("module not found: " + name, found); } } static void assertRevisionEntries(DependencyResolver resolver, ModuleEntry mod, String[] names, RevisionEntry[] revs) { - Assert.assertNotNull(revs); - Assert.assertEquals( + assertNotNull(revs); + assertEquals( "invalid revision entries: unmatched number: expected: " + Arrays.asList(names) + " but was " + Arrays.asList(revs), names.length, revs.length); assertRevisionEntriesContains(resolver, mod, names, revs); @@ -89,37 +89,37 @@ public class ResolverTestHelper { static void assertRevisionEntriesContains(DependencyResolver resolver, ModuleEntry mod, String[] names, RevisionEntry[] revs) { - Assert.assertNotNull(revs); - for (int i = 0; i < names.length; i++) { + assertNotNull(revs); + for (String name : names) { boolean found = false; - for (int j = 0; j < revs.length; j++) { - if (names[i].equals(revs[j].getRevision())) { + for (RevisionEntry rev : revs) { + if (name.equals(rev.getRevision())) { found = true; - Assert.assertEquals(resolver, revs[j].getResolver()); - Assert.assertEquals(mod, revs[j].getModuleEntry()); + assertEquals(resolver, rev.getResolver()); + assertEquals(mod, rev.getModuleEntry()); } } - Assert.assertTrue("revision not found: " + names[i], found); + assertTrue("revision not found: " + name, found); } } static OrganisationEntry getEntry(OrganisationEntry[] orgs, String name) { - for (int i = 0; i < orgs.length; i++) { - if (name.equals(orgs[i].getOrganisation())) { - return orgs[i]; + for (OrganisationEntry org : orgs) { + if (name.equals(org.getOrganisation())) { + return org; } } - Assert.fail("organisation not found: " + name); + fail("organisation not found: " + name); return null; // for compilation only } static ModuleEntry getEntry(ModuleEntry[] mods, String name) { - for (int i = 0; i < mods.length; i++) { - if (name.equals(mods[i].getModule())) { - return mods[i]; + for (ModuleEntry mod : mods) { + if (name.equals(mod.getModule())) { + return mod; } } - Assert.fail("module not found: " + name); + fail("module not found: " + name); return null; // for compilation only }