Repository: ant-ivy Updated Branches: refs/heads/master 497147e3e -> d4c3cbcca
Code cleanup/refactoring - checkstyle + not using deprecated methods + fix unchecked casts Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/d4c3cbcc Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/d4c3cbcc Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/d4c3cbcc Branch: refs/heads/master Commit: d4c3cbccaf05beeb11712294ef4dd0af25d9d0f4 Parents: 497147e Author: twogee <g.grigelio...@gmail.com> Authored: Sat Jul 22 22:35:00 2017 +0200 Committer: Jaikiran Pai <jaiki...@apache.org> Committed: Tue Jul 25 14:43:00 2017 +0530 ---------------------------------------------------------------------- src/java/org/apache/ivy/Ivy.java | 2 +- src/java/org/apache/ivy/Ivy14.java | 25 +++-- src/java/org/apache/ivy/Main.java | 2 +- .../org/apache/ivy/ant/IvyCacheFileset.java | 40 ++++---- .../apache/ivy/util/cli/CommandLineParser.java | 6 +- .../apache/ivy/core/deliver/DeliverTest.java | 15 +-- .../apache/ivy/core/resolve/ResolveTest.java | 101 ++++++++++--------- .../apache/ivy/core/retrieve/RetrieveTest.java | 60 ++++++----- .../conflict/LatestConflictManagerTest.java | 19 ++-- 9 files changed, 141 insertions(+), 129 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/src/java/org/apache/ivy/Ivy.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Ivy.java b/src/java/org/apache/ivy/Ivy.java index 8876739..424f010 100644 --- a/src/java/org/apache/ivy/Ivy.java +++ b/src/java/org/apache/ivy/Ivy.java @@ -543,7 +543,7 @@ public class Ivy { // RETRIEVE // /////////////////////////////////////////////////////////////////////// - @SuppressWarnings("deprecation") + @Deprecated public int retrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options) throws IOException { pushContext(); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/src/java/org/apache/ivy/Ivy14.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Ivy14.java b/src/java/org/apache/ivy/Ivy14.java index 5e1de65..42bbbd5 100644 --- a/src/java/org/apache/ivy/Ivy14.java +++ b/src/java/org/apache/ivy/Ivy14.java @@ -378,10 +378,10 @@ public class Ivy14 { boolean makeSymlinks) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, - new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern) + new RetrieveOptions().setConfs(confs).setDestArtifactPattern(destFilePattern) + .setDestIvyPattern(destIvyPattern) .setArtifactFilter(artifactFilter).setSync(sync).setUseOrigin(useOrigin) - .setMakeSymlinks(makeSymlinks)); + .setMakeSymlinks(makeSymlinks)).getNbrArtifactsCopied(); } catch (IOException e) { throw new RuntimeException(e); } @@ -392,9 +392,10 @@ public class Ivy14 { boolean useOrigin) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, - new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern) - .setArtifactFilter(artifactFilter).setSync(sync).setUseOrigin(useOrigin)); + new RetrieveOptions().setConfs(confs).setDestArtifactPattern(destFilePattern) + .setDestIvyPattern(destIvyPattern) + .setArtifactFilter(artifactFilter).setSync(sync) + .setUseOrigin(useOrigin)).getNbrArtifactsCopied(); } catch (IOException e) { throw new RuntimeException(e); } @@ -404,8 +405,9 @@ public class Ivy14 { String destIvyPattern, Filter<Artifact> artifactFilter) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, new RetrieveOptions().setConfs(confs) - .setDestIvyPattern(destIvyPattern).setArtifactFilter(artifactFilter)); + new RetrieveOptions().setConfs(confs).setDestArtifactPattern(destFilePattern) + .setDestIvyPattern(destIvyPattern) + .setArtifactFilter(artifactFilter)).getNbrArtifactsCopied(); } catch (IOException e) { throw new RuntimeException(e); } @@ -415,8 +417,8 @@ public class Ivy14 { String destIvyPattern) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, - new RetrieveOptions().setConfs(confs).setDestIvyPattern(destIvyPattern)); + new RetrieveOptions().setConfs(confs).setDestArtifactPattern(destFilePattern) + .setDestIvyPattern(destIvyPattern)).getNbrArtifactsCopied(); } catch (IOException e) { throw new RuntimeException(e); } @@ -425,7 +427,8 @@ public class Ivy14 { public int retrieve(ModuleId moduleId, String[] confs, File cache, String destFilePattern) { try { return ivy.retrieve(new ModuleRevisionId(moduleId, Ivy.getWorkingRevision()), - destFilePattern, new RetrieveOptions().setConfs(confs)); + new RetrieveOptions().setConfs(confs) + .setDestArtifactPattern(destFilePattern)).getNbrArtifactsCopied(); } catch (IOException e) { throw new RuntimeException(e); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/src/java/org/apache/ivy/Main.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/Main.java b/src/java/org/apache/ivy/Main.java index 4e93a0e..9dc058a 100644 --- a/src/java/org/apache/ivy/Main.java +++ b/src/java/org/apache/ivy/Main.java @@ -324,11 +324,11 @@ public final class Main { String ivyPattern = settings.substitute(line.getOptionValue("ivypattern")); ivy.retrieve( md.getModuleRevisionId(), - retrievePattern, new RetrieveOptions() .setConfs(confs) .setSync(line.hasOption("sync")) .setUseOrigin(line.hasOption("useOrigin")) + .setDestArtifactPattern(retrievePattern) .setDestIvyPattern(ivyPattern) .setArtifactFilter( FilterHelper.getArtifactTypeFilter(line.getOptionValues("types"))) http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/src/java/org/apache/ivy/ant/IvyCacheFileset.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/ant/IvyCacheFileset.java b/src/java/org/apache/ivy/ant/IvyCacheFileset.java index 0c92804..1707ddb 100644 --- a/src/java/org/apache/ivy/ant/IvyCacheFileset.java +++ b/src/java/org/apache/ivy/ant/IvyCacheFileset.java @@ -32,8 +32,8 @@ import org.apache.tools.ant.types.PatternSet.NameEntry; import org.apache.tools.ant.types.Resource; /** - * Creates an ant fileset consisting in all artifacts found during a resolve. Note that this task is - * not compatible with the useOrigin mode. + * Creates an ant fileset consisting in all artifacts found during a resolve. Note that this task + * is not compatible with the useOrigin mode. */ public class IvyCacheFileset extends IvyCacheTask { private String setid; @@ -50,8 +50,8 @@ public class IvyCacheFileset extends IvyCacheTask { if (useOrigin) { throw new UnsupportedOperationException( "the cachefileset task does not support the useOrigin mode, since filesets " - + "require to have only one root directory. Please use the the cachepath " - + "task instead"); + + "require to have only one root directory. Please use the the " + + "cachepath task instead"); } } @@ -89,12 +89,13 @@ public class IvyCacheFileset extends IvyCacheTask { } /** - * Returns a common base directory, determined from the {@link ArtifactDownloadReport#getLocalFile() local files} of the - * passed <code>artifactDownloadReports</code>. If no common base directory can be determined, this method throws a - * {@link BuildException} + * Returns a common base directory, determined from the + * {@link ArtifactDownloadReport#getLocalFile() local files} of the passed + * <code>artifactDownloadReports</code>. If no common base directory can be determined, this + * method throws a {@link BuildException} * - * @param artifactDownloadReports The artifact download reports for which the common base directory of the artifacts - * has to be determined + * @param artifactDownloadReports The artifact download reports for which the common base + * directory of the artifacts has to be determined * @return File */ File requireCommonBaseDir(final List<ArtifactDownloadReport> artifactDownloadReports) { @@ -112,15 +113,15 @@ public class IvyCacheFileset extends IvyCacheTask { base = getBaseDir(base, artifactDownloadReport.getLocalFile()); if (base == null) { // fail fast - we couldn't determine a common base directory, throw an error - throw new BuildException("Cannot find a common base directory, from resolved artifacts, " + - "for generating a cache fileset"); + throw new BuildException("Cannot find a common base directory, from resolved " + + "artifacts, for generating a cache fileset"); } } } if (base == null) { // finally, we couldn't determine a common base directory, throw an error - throw new BuildException("Cannot find a common base directory, from resolved artifacts, for generating " + - "a cache fileset"); + throw new BuildException("Cannot find a common base directory, from resolved " + + "artifacts, for generating a cache fileset"); } return base; } @@ -149,19 +150,20 @@ public class IvyCacheFileset extends IvyCacheTask { } /** - * Returns the common base directory between the passed <code>file1</code> and <code>file2</code>. + * Returns the common base directory between the passed <code>file1</code> and + * <code>file2</code>. * <p> - * The returned base directory will be a parent of both the <code>file1</code> and <code>file2</code> or - * it will be <code>null</code>. + * The returned base directory will be a parent of both the <code>file1</code> and + * <code>file2</code> or it will be <code>null</code>. * </p> * * @param file1 * One of the files, for which the common base directory is being sought, may be null. * @param file2 * The other file for which the common base directory should be returned, may be null. - * @return the common base directory between a <code>file1</code> and <code>file2</code>. Returns null - * if no common base directory could be determined or if either <code>file1</code> or <code>file2</code> - * is null + * @return the common base directory between a <code>file1</code> and <code>file2</code>. Returns + * null if no common base directory could be determined or if either <code>file1</code> + * or <code>file2</code> is null */ File getBaseDir(final File file1, final File file2) { if (file1 == null || file2 == null) { http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/src/java/org/apache/ivy/util/cli/CommandLineParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/util/cli/CommandLineParser.java b/src/java/org/apache/ivy/util/cli/CommandLineParser.java index e098b3b..ea9d1dd 100644 --- a/src/java/org/apache/ivy/util/cli/CommandLineParser.java +++ b/src/java/org/apache/ivy/util/cli/CommandLineParser.java @@ -21,6 +21,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -45,12 +46,11 @@ public class CommandLineParser { return this; } - @SuppressWarnings("unchecked") public CommandLineParser addOption(Option option) { options.put(option.getName(), option); if (!categories.isEmpty()) { - ((List<Option>) categories.values().toArray()[categories.values().size() - 1]) - .add(option); + // LinkedHashMap hides its tail... + new LinkedList<>(categories.values()).getLast().add(option); } return this; } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/test/java/org/apache/ivy/core/deliver/DeliverTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/deliver/DeliverTest.java b/test/java/org/apache/ivy/core/deliver/DeliverTest.java index 8ee0e57..70dcd58 100644 --- a/test/java/org/apache/ivy/core/deliver/DeliverTest.java +++ b/test/java/org/apache/ivy/core/deliver/DeliverTest.java @@ -17,12 +17,6 @@ */ package org.apache.ivy.core.deliver; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.net.URI; - import org.apache.ivy.TestHelper; import org.apache.ivy.ant.IvyDeliver; import org.apache.ivy.ant.IvyResolve; @@ -32,6 +26,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.net.URI; + +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class DeliverTest { @@ -81,7 +82,7 @@ public class DeliverTest { ivyDeliver.doExecute(); String deliverContent = readFile(deliverDir.getAbsolutePath() + "/ivys/ivy-1.0.xml"); - assertTrue(!deliverContent.contains("rev=\"latest.integration\"")); + assertFalse(deliverContent.contains("rev=\"latest.integration\"")); assertTrue(deliverContent.contains("name=\"b\" rev=\"1.5\"")); } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/test/java/org/apache/ivy/core/resolve/ResolveTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/resolve/ResolveTest.java b/test/java/org/apache/ivy/core/resolve/ResolveTest.java index 3de1346..194d308 100644 --- a/test/java/org/apache/ivy/core/resolve/ResolveTest.java +++ b/test/java/org/apache/ivy/core/resolve/ResolveTest.java @@ -17,23 +17,6 @@ */ package org.apache.ivy.core.resolve; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.apache.ivy.Ivy; import org.apache.ivy.TestHelper; import org.apache.ivy.core.cache.ArtifactOrigin; @@ -68,17 +51,35 @@ import org.apache.ivy.util.CacheCleaner; import org.apache.ivy.util.FileUtil; import org.apache.ivy.util.MockMessageLogger; import org.apache.ivy.util.StringUtils; - import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import static org.junit.Assert.*; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * @@ -1422,7 +1423,7 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); } @Test @@ -1443,9 +1444,9 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); } @Test @@ -1469,7 +1470,7 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); } @Test @@ -1490,9 +1491,9 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); } @Test @@ -1516,7 +1517,7 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar") .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); } @Test @@ -1536,8 +1537,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1558,7 +1559,7 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1578,8 +1579,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1615,8 +1616,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1637,7 +1638,7 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1657,8 +1658,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1678,8 +1679,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -1699,8 +1700,8 @@ public class ResolveTest { assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")) .exists()); assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); - assertTrue(!getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); } @Test @@ -2955,7 +2956,7 @@ public class ResolveTest { .exists()); assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org14", "mod14.1", "1.1")) .exists()); - assertTrue(!getIvyFileInCache(ModuleRevisionId.newInstance("org8", "mod8.3", "1.0")) + assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org8", "mod8.3", "1.0")) .exists()); assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org8", "mod8.1", "1.0")) .exists()); @@ -2972,7 +2973,7 @@ public class ResolveTest { .exists()); assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org14", "mod14.1", "1.1")) .exists()); - assertTrue(!getIvyFileInCache(ModuleRevisionId.newInstance("org14", "mod14.2", "1.1")) + assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org14", "mod14.2", "1.1")) .exists()); assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org14", "mod14.3", "1.1")) .exists()); @@ -3648,9 +3649,9 @@ public class ResolveTest { .exists()); assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); - assertTrue(!getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")) + assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")) .exists()); - assertTrue(!getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); + assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); } @Test @@ -3698,7 +3699,7 @@ public class ResolveTest { // dependencies assertTrue(depIvyFileInCache.exists()); - assertTrue(!getArchiveFileInCache(ivy, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar") + assertFalse(getArchiveFileInCache(ivy, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar") .exists()); } @@ -4477,8 +4478,8 @@ public class ResolveTest { Map<String, String> cmap = new HashMap<>(); cmap.put("classifier", "asl"); - assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", null /* branch */ - , "1.0", "test-classified", "jar", "jar", cmap).exists()); + assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", /* branch */ null, + "1.0", "test-classified", "jar", "jar", cmap).exists()); } @Test @@ -4505,8 +4506,8 @@ public class ResolveTest { Map<String, String> cmap = new HashMap<>(); cmap.put("classifier", "asl"); - assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", null /* branch */ - , "2.0", "test-classified", "jar", "jar", cmap).exists()); + assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-classified", /* branch */ null, + "2.0", "test-classified", "jar", "jar", cmap).exists()); } @Test http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java b/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java index f51c06e..89a11fb 100644 --- a/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java +++ b/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java @@ -87,12 +87,14 @@ public class RetrieveTest { assertNotNull(md); String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")).exists()); pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")).exists()); } @@ -110,7 +112,8 @@ public class RetrieveTest { String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]"; MockMessageLogger mockLogger = new MockMessageLogger(); Message.setDefaultLogger(mockLogger); - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar", "default")).exists()); mockLogger.assertLogDoesntContain("conflict on"); @@ -129,7 +132,8 @@ public class RetrieveTest { MockMessageLogger mockLogger = new MockMessageLogger(); Message.setDefaultLogger(mockLogger); try { - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); fail("Exception should have been thrown!"); } catch (RuntimeException e) { // expected! @@ -151,7 +155,8 @@ public class RetrieveTest { }); ModuleDescriptor md = report.getModuleDescriptor(); String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); assertEquals(4, events.size()); assertTrue(events.get(0) instanceof StartRetrieveEvent); assertTrue(events.get(1) instanceof StartRetrieveArtifactEvent); @@ -162,7 +167,8 @@ public class RetrieveTest { assertEquals(0, ev.getNbUpToDate()); events.clear(); - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); assertEquals(2, events.size()); assertTrue(events.get(0) instanceof StartRetrieveEvent); assertTrue(events.get(1) instanceof EndRetrieveEvent); @@ -188,10 +194,9 @@ public class RetrieveTest { "mod1.2", "jar", "jar", "default")).getCanonicalFile(); file.getParentFile().mkdirs(); file.createNewFile(); - ivy.retrieve(md.getModuleRevisionId(), pattern, - getRetrieveOptions().setOverwriteMode("always")); - assertEquals( - new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").lastModified(), + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setOverwriteMode("always").setDestArtifactPattern(pattern)); + assertEquals(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").lastModified(), file.lastModified()); } @@ -205,15 +210,15 @@ public class RetrieveTest { ModuleDescriptor md = report.getModuleDescriptor(); assertNotNull(md); - RetrieveOptions options = getRetrieveOptions().setMakeSymlinks(true); - String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setMakeSymlinks(true).setDestArtifactPattern(pattern)); assertLink(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")); pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setMakeSymlinks(true).setDestArtifactPattern(pattern)); assertLink(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")); } @@ -232,15 +237,15 @@ public class RetrieveTest { ModuleDescriptor md = report.getModuleDescriptor(); assertNotNull(md); - RetrieveOptions options = getRetrieveOptions().setMakeSymlinksInMass(true); - String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern)); assertLink(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")); pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern)); assertLink(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")); } @@ -276,13 +281,15 @@ public class RetrieveTest { assertNotNull(md); String pattern = "build/test/${retrieve.dir}/[module]/[conf]/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve"); assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")).exists()); pattern = "build/test/${retrieve.dir}/[module]/[conf]/[type]s/[artifact]-[revision].[ext]"; - ivy.retrieve(md.getModuleRevisionId(), pattern, getRetrieveOptions()); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve"); assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", "default")).exists()); @@ -332,8 +339,8 @@ public class RetrieveTest { String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])"; - RetrieveOptions options = getRetrieveOptions(); - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0"); assertTrue(dest.exists()); @@ -360,9 +367,8 @@ public class RetrieveTest { String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])"; - RetrieveOptions options = getRetrieveOptions(); - options.setSync(true); - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setSync(true).setDestArtifactPattern(pattern)); File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0"); assertTrue(dest.exists()); @@ -395,8 +401,8 @@ public class RetrieveTest { final String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])"; - final RetrieveOptions options = getRetrieveOptions(); - ivy.retrieve(md.getModuleRevisionId(), pattern, options); + ivy.retrieve(md.getModuleRevisionId(), + getRetrieveOptions().setDestArtifactPattern(pattern)); final File dest = new File("build/test/retrieve/packaging/module9/default/jars/module9-1.0.jar"); assertTrue("Retrieved artifact is missing at " + dest.getAbsolutePath(), dest.exists()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d4c3cbcc/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java b/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java index 9324461..03a9942 100644 --- a/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java +++ b/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java @@ -17,13 +17,6 @@ */ package org.apache.ivy.plugins.conflict; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.io.File; -import java.util.Iterator; -import java.util.List; - import org.apache.ivy.Ivy; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.ConfigurationResolveReport; @@ -35,6 +28,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.File; +import java.util.Iterator; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + public class LatestConflictManagerTest { private Ivy ivy; @@ -178,9 +178,8 @@ public class LatestConflictManagerTest { assertEquals("A revision should be 1.0.0", "1.0.0", mrid.getRevision()); } else if (mrid.getName().equals("D")) { assertEquals("D revision should be 1.0.0", "1.0.0", mrid.getRevision()); - } - // by transitivity - else if (mrid.getName().equals("B")) { + } else if (mrid.getName().equals("B")) { + // by transitivity assertEquals("B revision should be 1.0.0", "1.0.0", mrid.getRevision()); } else if (mrid.getName().equals("C")) { assertEquals("C revision should be 1.0.2", "1.0.2", mrid.getRevision());