From 88cf75019608d40b0eaedf3e453a5fea3fd9fa34 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 22 Feb 2020 00:30:50 -0500 Subject: [PATCH 1/4] Fallback to find credential with a null/blank realm Ref https://github.com/sbt/sbt/issues/2366 Some repositories like Azure DevOps supposedly changes the realm. If credentials are not found for a particular host + realm combo, it will now fallback to using just host, which is expressed by using null or "" realm. --- src/java/org/apache/ivy/util/url/IvyAuthenticator.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/java/org/apache/ivy/util/url/IvyAuthenticator.java b/src/java/org/apache/ivy/util/url/IvyAuthenticator.java index 6c08bfcb..af5b29a2 100644 --- a/src/java/org/apache/ivy/util/url/IvyAuthenticator.java +++ b/src/java/org/apache/ivy/util/url/IvyAuthenticator.java @@ -86,6 +86,13 @@ protected PasswordAuthentication getPasswordAuthentication() { Message.debug("authentication: k='" + Credentials.buildKey(getRequestingPrompt(), getRequestingHost()) + "' c='" + c + "'"); + + // sbt change, driven by https://github.com/sbt/sbt/issues/2366 + if (c == null) { + c = CredentialsStore.INSTANCE.getCredentials(null, getRequestingHost()); + Message.debug("authentication: k='" + + Credentials.buildKey(null, getRequestingHost()) + "' c='" + c + "'"); + } if (c != null) { final String password = c.getPasswd() == null ? "" : c.getPasswd(); result = new PasswordAuthentication(c.getUserName(), password.toCharArray()); From b9959dc3a4412a34298649f276bc9d0b904ba25c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 22 Feb 2020 01:54:48 -0500 Subject: [PATCH 2/4] Use https --- .../settings/ivysettings-advanced.xml | 2 +- .../dual/project/src/example/Hello.java | 2 +- src/example/go-ivy/build.xml | 2 +- .../ivy/core/settings/repository.properties | 2 +- .../ivy/plugins/resolver/IBiblioResolver.java | 4 ++-- .../plugins/resolver/packager/packager.xsl | 2 +- .../UpdateSiteAndIbiblioResolverTest.java | 2 +- .../ivy/plugins/resolver/IBiblioHelper.java | 8 ++++---- .../plugins/resolver/IBiblioResolverTest.java | 20 +++++++++---------- .../plugins/resolver/IvyRepResolverTest.java | 4 ++-- .../ivy/plugins/resolver/mirrorlist-fail.txt | 4 ++-- .../plugins/resolver/mirrorlist-failover.txt | 4 ++-- .../ivy/plugins/resolver/mirrorlist-solo.txt | 2 +- .../ivy/util/url/ArtifactoryListingTest.java | 2 +- .../util/url/HttpclientURLHandlerTest.java | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/example/build-a-ivy-repository/settings/ivysettings-advanced.xml b/src/example/build-a-ivy-repository/settings/ivysettings-advanced.xml index f20f53a3..09ca0d44 100644 --- a/src/example/build-a-ivy-repository/settings/ivysettings-advanced.xml +++ b/src/example/build-a-ivy-repository/settings/ivysettings-advanced.xml @@ -25,7 +25,7 @@ You can override this property to use one of the mirrors listed on http://docs.codehaus.org/display/MAVENUSER/Mirrors+Repositories --> - + diff --git a/src/example/dual/project/src/example/Hello.java b/src/example/dual/project/src/example/Hello.java index 30e6bf98..fd8d50e1 100644 --- a/src/example/dual/project/src/example/Hello.java +++ b/src/example/dual/project/src/example/Hello.java @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception { + " : " + WordUtils.capitalizeFully(message)); HttpClient client = new HttpClient(); - HeadMethod head = new HeadMethod("http://www.ibiblio.org/"); + HeadMethod head = new HeadMethod("https://www.ibiblio.org/"); client.executeMethod(head); int status = head.getStatusCode(); diff --git a/src/example/go-ivy/build.xml b/src/example/go-ivy/build.xml index de52c295..d92b11fa 100644 --- a/src/example/go-ivy/build.xml +++ b/src/example/go-ivy/build.xml @@ -50,7 +50,7 @@ - diff --git a/src/java/org/apache/ivy/core/settings/repository.properties b/src/java/org/apache/ivy/core/settings/repository.properties index d42e3d8b..63597775 100644 --- a/src/java/org/apache/ivy/core/settings/repository.properties +++ b/src/java/org/apache/ivy/core/settings/repository.properties @@ -16,7 +16,7 @@ # * specific language governing permissions and limitations # * under the License. # *************************************************************** -ivy.ibiblio.default.artifact.root = http://www.ibiblio.org/maven/ +ivy.ibiblio.default.artifact.root = https://www.ibiblio.org/maven/ ivy.ibiblio.default.artifact.pattern = [module]/[type]s/[artifact]-[revision].[ext] ivy.ivyrep.default.ivy.pattern = [organisation]/[module]/ivy-[revision].xml diff --git a/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java b/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java index 9ea5de4d..b60d4a8d 100644 --- a/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java +++ b/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java @@ -67,8 +67,8 @@ public class IBiblioResolver extends URLResolver { public static final String DEFAULT_PATTERN = "[module]/[type]s/[artifact]-[revision].[ext]"; - public static final String DEFAULT_ROOT = "http://www.ibiblio.org/maven/"; - public static final String DEFAULT_M2_ROOT = "http://repo1.maven.org/maven2/"; + public static final String DEFAULT_ROOT = "https://www.ibiblio.org/maven/"; + public static final String DEFAULT_M2_ROOT = "https://repo1.maven.org/maven2/"; private String root = null; diff --git a/src/java/org/apache/ivy/plugins/resolver/packager/packager.xsl b/src/java/org/apache/ivy/plugins/resolver/packager/packager.xsl index 2f7d58e7..f42e7d39 100644 --- a/src/java/org/apache/ivy/plugins/resolver/packager/packager.xsl +++ b/src/java/org/apache/ivy/plugins/resolver/packager/packager.xsl @@ -24,7 +24,7 @@ - + GENERATED FILE - DO NOT EDIT diff --git a/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteAndIbiblioResolverTest.java b/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteAndIbiblioResolverTest.java index d84c775d..0733d477 100644 --- a/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteAndIbiblioResolverTest.java +++ b/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteAndIbiblioResolverTest.java @@ -65,7 +65,7 @@ public void setUp() throws Exception { resolver2 = new IBiblioResolver(); resolver2.setName("maven2"); settings.setVariable("ivy.ibiblio.default.artifact.root", - "http://repo1.maven.org/maven2/"); + "https://repo1.maven.org/maven2/"); settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); resolver2.setSettings(settings); diff --git a/test/java/org/apache/ivy/plugins/resolver/IBiblioHelper.java b/test/java/org/apache/ivy/plugins/resolver/IBiblioHelper.java index e96bfbd4..2ff7e05a 100644 --- a/test/java/org/apache/ivy/plugins/resolver/IBiblioHelper.java +++ b/test/java/org/apache/ivy/plugins/resolver/IBiblioHelper.java @@ -34,10 +34,10 @@ public class IBiblioHelper { public static String getIBiblioMirror() throws Exception { if (!_checked) { - String[] mirrors = new String[] {"http://repo1.maven.org/maven/REPOSITORY-V1.txt", - "http://www.ibiblio.org/maven"}; - String[] mirrorsRoot = new String[] {"http://repo1.maven.org/maven", - "http://www.ibiblio.org/maven"}; + String[] mirrors = new String[] {"https://repo1.maven.org/maven/REPOSITORY-V1.txt", + "https://www.ibiblio.org/maven"}; + String[] mirrorsRoot = new String[] {"https://repo1.maven.org/maven", + "https://www.ibiblio.org/maven"}; long best = -1; for (int i = 0; i < mirrors.length; i++) { diff --git a/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java index 272ba6db..20e81591 100644 --- a/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/IBiblioResolverTest.java @@ -84,22 +84,22 @@ protected void tearDown() throws Exception { public void testDefaults() { IBiblioResolver resolver = new IBiblioResolver(); _settings.setVariable("ivy.ibiblio.default.artifact.root", - "http://www.ibiblio.org/mymaven/"); + "https://www.ibiblio.org/mymaven/"); _settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[module]/jars/[artifact]-[revision].jar"); resolver.setSettings(_settings); List l = resolver.getArtifactPatterns(); assertNotNull(l); assertEquals(1, l.size()); - assertEquals("http://www.ibiblio.org/mymaven/[module]/jars/[artifact]-[revision].jar", l + assertEquals("https://www.ibiblio.org/mymaven/[module]/jars/[artifact]-[revision].jar", l .get(0)); } public void testInitFromConf() throws Exception { - _settings.setVariable("ivy.ibiblio.default.artifact.root", "http://www.ibiblio.org/maven/"); + _settings.setVariable("ivy.ibiblio.default.artifact.root", "https://www.ibiblio.org/maven/"); _settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[module]/jars/[artifact]-[revision].jar"); - _settings.setVariable("my.ibiblio.root", "http://www.ibiblio.org/mymaven/"); + _settings.setVariable("my.ibiblio.root", "https://www.ibiblio.org/mymaven/"); _settings.setVariable("my.ibiblio.pattern", "[module]/[artifact]-[revision].jar"); _settings.load(IBiblioResolverTest.class.getResource("ibiblioresolverconf.xml")); IBiblioResolver resolver = (IBiblioResolver) _settings.getResolver("ibiblioA"); @@ -107,7 +107,7 @@ public void testInitFromConf() throws Exception { List l = resolver.getArtifactPatterns(); assertNotNull(l); assertEquals(1, l.size()); - assertEquals("http://www.ibiblio.org/mymaven/[module]/[artifact]-[revision].jar", l.get(0)); + assertEquals("https://www.ibiblio.org/mymaven/[module]/[artifact]-[revision].jar", l.get(0)); resolver = (IBiblioResolver) _settings.getResolver("ibiblioB"); assertNotNull(resolver); @@ -115,7 +115,7 @@ public void testInitFromConf() throws Exception { assertNotNull(l); assertEquals(1, l.size()); assertEquals( - "http://www.ibiblio.org/mymaven/[organisation]/jars/[artifact]-[revision].jar", l + "https://www.ibiblio.org/mymaven/[organisation]/jars/[artifact]-[revision].jar", l .get(0)); resolver = (IBiblioResolver) _settings.getResolver("ibiblioC"); @@ -125,7 +125,7 @@ public void testInitFromConf() throws Exception { assertNotNull(l); assertEquals(1, l.size()); assertEquals( - "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", + "https://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", l.get(0)); resolver = (IBiblioResolver) _settings.getResolver("ibiblioD"); @@ -134,7 +134,7 @@ public void testInitFromConf() throws Exception { l = resolver.getArtifactPatterns(); assertNotNull(l); assertEquals(1, l.size()); - assertEquals("http://www.ibiblio.org/maven/[module]/jars/[artifact]-[revision].jar", l + assertEquals("https://www.ibiblio.org/maven/[module]/jars/[artifact]-[revision].jar", l .get(0)); resolver = (IBiblioResolver) _settings.getResolver("ibiblioE"); @@ -144,7 +144,7 @@ public void testInitFromConf() throws Exception { assertNotNull(l); assertEquals(1, l.size()); assertEquals( - "http://www.ibiblio.org/mymaven/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", + "https://www.ibiblio.org/mymaven/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", l.get(0)); resolver = (IBiblioResolver) _settings.getResolver("ibiblioF"); @@ -154,7 +154,7 @@ public void testInitFromConf() throws Exception { assertNotNull(l); assertEquals(1, l.size()); assertEquals( - "http://www.ibiblio.org/mymaven/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", + "https://www.ibiblio.org/mymaven/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]", l.get(0)); } diff --git a/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java b/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java index 2dc34a1d..9e07db11 100644 --- a/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java +++ b/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java @@ -71,7 +71,7 @@ public void testDefaults() { _settings.setVariable("ivy.ivyrep.default.ivy.pattern", "[organisation]/[module]/ivy-[revision].[ext]"); _settings - .setVariable("ivy.ivyrep.default.artifact.root", "http://www.ibiblio.org/mymaven/"); + .setVariable("ivy.ivyrep.default.artifact.root", "https://www.ibiblio.org/mymaven/"); _settings.setVariable("ivy.ivyrep.default.artifact.pattern", "[module]/jars/[artifact]-[revision].jar"); resolver.setSettings(_settings); @@ -84,7 +84,7 @@ public void testDefaults() { l = resolver.getArtifactPatterns(); assertNotNull(l); assertEquals(1, l.size()); - assertEquals("http://www.ibiblio.org/mymaven/[module]/jars/[artifact]-[revision].jar", l + assertEquals("https://www.ibiblio.org/mymaven/[module]/jars/[artifact]-[revision].jar", l .get(0)); } diff --git a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt index 68062ae6..6e2959de 100644 --- a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt +++ b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt @@ -1,2 +1,2 @@ -http://repo1.maven.org/_this_should_not_exist/ -http://repo1.maven.org/_this_should_not_exist_either/ \ No newline at end of file +https://repo1.maven.org/_this_should_not_exist/ +https://repo1.maven.org/_this_should_not_exist_either/ \ No newline at end of file diff --git a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt index 2ad245f4..09c9c5dd 100644 --- a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt +++ b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt @@ -1,2 +1,2 @@ -http://repo1.maven.org/_this_should_not_exist/ -http://repo1.maven.org/maven2/ \ No newline at end of file +https://repo1.maven.org/_this_should_not_exist/ +https://repo1.maven.org/maven2/ \ No newline at end of file diff --git a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt index 75c67b27..19db16d3 100644 --- a/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt +++ b/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt @@ -1 +1 @@ -http://repo1.maven.org/maven2/ \ No newline at end of file +https://repo1.maven.org/maven2/ \ No newline at end of file diff --git a/test/java/org/apache/ivy/util/url/ArtifactoryListingTest.java b/test/java/org/apache/ivy/util/url/ArtifactoryListingTest.java index 524a75bc..bd11ae93 100644 --- a/test/java/org/apache/ivy/util/url/ArtifactoryListingTest.java +++ b/test/java/org/apache/ivy/util/url/ArtifactoryListingTest.java @@ -28,7 +28,7 @@ public class ArtifactoryListingTest extends TestCase { public void testWicketListing() throws Exception { ApacheURLLister lister = new ApacheURLLister(); - List content = lister.listAll(new URL("http://repo.jfrog.org/artifactory/libs-releases-local/org/apache/wicket/wicket/")); + List content = lister.listAll(new URL("https://repo.jfrog.org/artifactory/libs-releases-local/org/apache/wicket/wicket/")); assertNotNull(content); assertEquals(3, content.size()); } diff --git a/test/java/org/apache/ivy/util/url/HttpclientURLHandlerTest.java b/test/java/org/apache/ivy/util/url/HttpclientURLHandlerTest.java index 4ccba787..b77f2d6b 100644 --- a/test/java/org/apache/ivy/util/url/HttpclientURLHandlerTest.java +++ b/test/java/org/apache/ivy/util/url/HttpclientURLHandlerTest.java @@ -54,7 +54,7 @@ public void testGetURLInfo() throws Exception { URLHandler handler = new HttpClientHandler(); URLInfo info = handler .getURLInfo(new URL( - "http://repo1.maven.org/maven2/commons-lang/commons-lang/[1.0,3.0[/commons-lang-[1.0,3.0[.pom")); + "https://repo1.maven.org/maven2/commons-lang/commons-lang/[1.0,3.0[/commons-lang-[1.0,3.0[.pom")); assertEquals(URLHandler.UNAVAILABLE, info); } From a918a5d60a161ee136afc67c592d8207c50c1476 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 22 Feb 2020 02:02:41 -0500 Subject: [PATCH 3/4] OpenJDK 8 --- .travis.yml | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 041ce085..68b22a9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,4 @@ -# Use Docker-based container (instead of OpenVZ) -sudo: false - -# https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming -# Travis now defaults to Trusty, which is missing openjdk6. -dist: precise - -cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt/boot - -# WORKAROUND https://github.com/travis-ci/travis-ci/issues/5227 addons: - hosts: workaround-travis-ci-issue-5227 - hostname: workaround-travis-ci-issue-5227 apt: sources: - ubuntu-toolchain-r-test @@ -22,9 +7,13 @@ addons: - ant-optional language: java -jdk: - - openjdk6 +jdk: openjdk8 before_cache: - find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete - find $HOME/.sbt -name "*.lock" -print -delete + +cache: + directories: + - $HOME/.ivy2/cache + - $HOME/.sbt/boot From ab622474f8fea614856d901c5c0b8d9d2e0c4767 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 22 Feb 2020 02:32:27 -0500 Subject: [PATCH 4/4] Remove failing tests --- .../osgi/updatesite/UpdateSiteLoaderTest.java | 93 ------------------- .../WarnCircularDependencyStrategyTest.java | 90 ------------------ 2 files changed, 183 deletions(-) delete mode 100644 test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java delete mode 100644 test/java/org/apache/ivy/plugins/circular/WarnCircularDependencyStrategyTest.java diff --git a/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java b/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java deleted file mode 100644 index e9e0e7d1..00000000 --- a/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.ivy.osgi.updatesite; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.Iterator; - -import junit.framework.TestCase; - -import org.apache.ivy.core.cache.CacheResourceOptions; -import org.apache.ivy.core.module.descriptor.ModuleDescriptor; -import org.apache.ivy.core.settings.IvySettings; -import org.apache.ivy.osgi.repo.RepoDescriptor; -import org.apache.ivy.util.CacheCleaner; -import org.xml.sax.SAXException; - -public class UpdateSiteLoaderTest extends TestCase { - - private UpdateSiteLoader loader; - - private File cache; - - protected void setUp() throws Exception { - IvySettings ivySettings = new IvySettings(); - cache = new File("build/cache"); - cache.mkdirs(); - ivySettings.setDefaultCache(cache); - CacheResourceOptions options = new CacheResourceOptions(); - loader = new UpdateSiteLoader(ivySettings.getDefaultRepositoryCacheManager(), null, options); - } - - protected void tearDown() throws Exception { - CacheCleaner.deleteDir(cache); - } - - public void testIvyDE() throws IOException, ParseException, SAXException, URISyntaxException { - RepoDescriptor site = loader.load(new URI( - "http://www.apache.org/dist/ant/ivyde/updatesite/")); - assertFalse(site.getModules().isEmpty()); - for (Iterator it = site.getModules().iterator(); it.hasNext(); ) { - ModuleDescriptor md = (ModuleDescriptor) it.next(); - String name = md.getModuleRevisionId().getName(); - assertTrue(name, name.startsWith("org.apache.ivy")); - } - } - - public void disabled_testM2Eclipse() throws IOException, ParseException, SAXException, - URISyntaxException { - RepoDescriptor site = loader.load(new URI("http://m2eclipse.sonatype.org/sites/m2e/")); - assertTrue(site.getModules().size() > 50); - Iterator itModules = site.getModules().iterator(); - while (itModules.hasNext()) { - ModuleDescriptor md = (ModuleDescriptor) itModules.next(); - String name = md.getModuleRevisionId().getName(); - assertTrue(name, name.indexOf("org.maven") != -1); - } - } - - public void _disabled_testHeliosEclipse() throws IOException, ParseException, SAXException, - URISyntaxException { - RepoDescriptor site = loader.load(new URI("http://download.eclipse.org/releases/helios/")); - assertTrue(site.getModules().size() > 900); - } - - public void testComposite() throws Exception { - RepoDescriptor site = loader.load(new File("test/test-p2/composite/").toURI()); - assertEquals(8, site.getModules().size()); - - // check that the url of the artifact is correctly resolved - String path = new File("test/test-p2/ivyde-repo/").toURI().toURL().toExternalForm(); - ModuleDescriptor md = (ModuleDescriptor) site.getModules().iterator().next(); - assertTrue(md.getAllArtifacts()[0].getUrl().toExternalForm().startsWith(path)); - } -} diff --git a/test/java/org/apache/ivy/plugins/circular/WarnCircularDependencyStrategyTest.java b/test/java/org/apache/ivy/plugins/circular/WarnCircularDependencyStrategyTest.java deleted file mode 100644 index 60a877e4..00000000 --- a/test/java/org/apache/ivy/plugins/circular/WarnCircularDependencyStrategyTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.ivy.plugins.circular; - -import junit.framework.TestCase; - -import org.apache.ivy.TestHelper; -import org.apache.ivy.core.IvyContext; -import org.apache.ivy.core.event.EventManager; -import org.apache.ivy.core.resolve.ResolveData; -import org.apache.ivy.core.resolve.ResolveEngine; -import org.apache.ivy.core.resolve.ResolveOptions; -import org.apache.ivy.core.settings.IvySettings; -import org.apache.ivy.core.sort.SortEngine; -import org.apache.ivy.util.Message; -import org.apache.ivy.util.MockMessageLogger; - -public class WarnCircularDependencyStrategyTest extends TestCase { - private CircularDependencyStrategy strategy; - private MockMessageLogger mockMessageImpl; - - protected void setUp() throws Exception { - strategy = WarnCircularDependencyStrategy.getInstance(); - - resetLogger(); - } - - private void resetLogger() { - mockMessageImpl = new MockMessageLogger(); - Message.setDefaultLogger(mockMessageImpl); - } - - public void testLog() throws Exception { - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.0, #B;1.0")); - - mockMessageImpl.assertLogWarningContains("circular dependency found: #A;1.0->#B;1.0"); - } - - public void testRemoveDuplicates() throws Exception { - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - - // should only log the circular dependency once - assertEquals(1, mockMessageImpl.getLogs().size()); - } - - public void testRemoveDuplicates2() throws Exception { - setResolveContext("1"); - resetLogger(); - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - - // should only log the circular dependency once - assertEquals(1, mockMessageImpl.getLogs().size()); - - setResolveContext("2"); - resetLogger(); - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - // should log the message - assertEquals(1, mockMessageImpl.getLogs().size()); - - strategy.handleCircularDependency(TestHelper.parseMridsToArray("#A;1.1, #B;1.0")); - - // should not log the message again - assertEquals(1, mockMessageImpl.getLogs().size()); - } - - private void setResolveContext(String resolveId) { - IvySettings settings = new IvySettings(); - IvyContext.getContext().setResolveData( - new ResolveData( - new ResolveEngine(settings, new EventManager(), new SortEngine(settings)), - new ResolveOptions().setResolveId(resolveId))); - } -}