Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions test/java/org/apache/ivy/core/retrieve/RetrieveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
*/
package org.apache.ivy.core.retrieve;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.ivy.Ivy;
import org.apache.ivy.TestHelper;
import org.apache.ivy.core.IvyPatternHelper;
Expand All @@ -38,35 +51,24 @@
import org.apache.ivy.util.DefaultMessageLogger;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.MockMessageLogger;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.filters.TokenFilter.ReplaceString;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.taskdefs.Delete;
import org.apache.tools.ant.types.FilterChain;
import org.apache.tools.ant.filters.TokenFilter.ReplaceString;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
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.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;

public class RetrieveTest {

Expand Down Expand Up @@ -505,7 +507,7 @@ public void testUnpackExt() throws Exception {

// normal resolve, the file goes in the cache
final ResolveReport report = ivy.resolve(url, roptions);
assertFalse("Resolution report has errors", report.hasError());
assumeFalse(report.hasError());
final ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull("Module descriptor from report was null", md);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,31 @@
import org.apache.ivy.util.url.URLHandlerDispatcher;
import org.apache.ivy.util.url.URLHandlerRegistry;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

/**
* split from XmlIvyConfigurationParserTest due to dependency on network resource
* Split from XmlIvyConfigurationParserTest due to dependency on network resource.
*/
public class OnlineXmlSettingsParserTest {
// remote.test
public class OnlineXmlSettingsParserTest { // remote.test

@Before
public void setUp() throws Exception {
URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
TimeoutConstrainedURLHandler httpHandler = URLHandlerRegistry.getHttp();
dispatcher.setDownloader("http", httpHandler);
dispatcher.setDownloader("https", httpHandler);
URLHandlerRegistry.setDefault(dispatcher);

assumeTrue(httpHandler.isReachable(new URL("https://ant.apache.org/")));
}

@Test
public void testIncludeHttpUrl() throws Exception {
configureURLHandler();
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(new URL("https://ant.apache.org/ivy/test/ivysettings-include-http-url.xml"));
Expand All @@ -52,11 +63,9 @@ public void testIncludeHttpUrl() throws Exception {
@Test
public void testIncludeHttpRelativeUrl() throws Exception {
// Use a settings file via http that use an include with relative url
configureURLHandler();
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(new URL(
"https://ant.apache.org/ivy/test/ivysettings-include-http-relative-url.xml"));
parser.parse(new URL("https://ant.apache.org/ivy/test/ivysettings-include-http-relative-url.xml"));

DependencyResolver resolver = settings.getResolver("ivyrep");
assertNotNull(resolver);
Expand All @@ -66,11 +75,9 @@ public void testIncludeHttpRelativeUrl() throws Exception {
@Test
public void testIncludeHttpRelativeFile() throws Exception {
// Use a settings file via http that use an include with relative file
configureURLHandler();
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(new URL(
"https://ant.apache.org/ivy/test/ivysettings-include-http-relative-file.xml"));
parser.parse(new URL("https://ant.apache.org/ivy/test/ivysettings-include-http-relative-file.xml"));

DependencyResolver resolver = settings.getResolver("ivyrep");
assertNotNull(resolver);
Expand All @@ -82,23 +89,12 @@ public void testIncludeHttpAbsoluteFile() throws Exception {
// Use a settings file via http that use an include with absolute file
// WARNING : this test will only work if the test are launched from the project root
// directory
configureURLHandler();
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(new URL(
"https://ant.apache.org/ivy/test/ivysettings-include-http-absolute-file.xml"));
parser.parse(new URL("https://ant.apache.org/ivy/test/ivysettings-include-http-absolute-file.xml"));

DependencyResolver inc = settings.getResolver("includeworks");
assertNotNull(inc);
assertTrue(inc instanceof ChainResolver);
}

private void configureURLHandler() {
URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
TimeoutConstrainedURLHandler httpHandler = URLHandlerRegistry.getHttp();
dispatcher.setDownloader("http", httpHandler);
dispatcher.setDownloader("https", httpHandler);
URLHandlerRegistry.setDefault(dispatcher);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.ivy.osgi.updatesite;

import java.io.File;
import java.text.ParseException;
import java.net.URL;

import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.RepositoryCacheManager;
Expand All @@ -32,11 +32,12 @@
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.plugins.resolver.ChainResolver;
import org.apache.ivy.plugins.resolver.IBiblioResolver;

import org.junit.Before;
import org.junit.Test;

import static org.apache.ivy.plugins.resolver.IBiblioResolver.DEFAULT_M2_ROOT;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeNoException;

public class UpdateSiteAndIbiblioResolverTest {

Expand All @@ -56,7 +57,15 @@ public class UpdateSiteAndIbiblioResolverTest {

@Before
public void setUp() throws Exception {
try {
new URL(IBiblioResolver.DEFAULT_M2_ROOT).getContent();
} catch (Exception e) {
assumeNoException(e);
}

settings = new IvySettings();
settings.setVariable("ivy.ibiblio.default.artifact.root", IBiblioResolver.DEFAULT_M2_ROOT);
settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");

chain = new ChainResolver();
chain.setName("chain");
Expand All @@ -69,9 +78,6 @@ public void setUp() throws Exception {

resolver2 = new IBiblioResolver();
resolver2.setName("maven2");
settings.setVariable("ivy.ibiblio.default.artifact.root", DEFAULT_M2_ROOT);
settings.setVariable("ivy.ibiblio.default.artifact.pattern",
"[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
resolver2.setSettings(settings);

chain.add(resolver);
Expand All @@ -98,19 +104,15 @@ public void setUp() throws Exception {
data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
}

@Test
public void testArtifactRef() throws ParseException {

@Test
public void testArtifactRef() throws Exception {
// Simple Dependency for ibiblio
ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("log4j", "log4j", "1.2.16");
ResolvedModuleRevision rmr1 = chain.getDependency(new DefaultDependencyDescriptor(mrid1,
false), data);
ResolvedModuleRevision rmr1 = chain.getDependency(new DefaultDependencyDescriptor(mrid1, false), data);

// Simple Dependency for updatesite
ModuleRevisionId mrid2 = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
"org.apache.ivy", "2.0.0.final_20090108225011");
ResolvedModuleRevision rmr2 = chain.getDependency(new DefaultDependencyDescriptor(mrid2,
false), data);
ModuleRevisionId mrid2 = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy", "2.0.0.final_20090108225011");
ResolvedModuleRevision rmr2 = chain.getDependency(new DefaultDependencyDescriptor(mrid2, false), data);

assertNotNull(rmr1);
assertNotNull(rmr2);
Expand All @@ -121,5 +123,4 @@ public void testArtifactRef() throws ParseException {
chain.exists(artifacts2[0]);
chain.exists(artifacts1[0]);
}

}
38 changes: 20 additions & 18 deletions test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
*/
package org.apache.ivy.osgi.updatesite;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

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 org.apache.ivy.core.cache.CacheResourceOptions;
Expand All @@ -34,11 +28,15 @@
import org.apache.ivy.osgi.repo.RepoDescriptor;
import org.apache.ivy.util.CacheCleaner;
import org.apache.ivy.util.CollectionUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNoException;

public class UpdateSiteLoaderTest {

Expand All @@ -48,10 +46,12 @@ public class UpdateSiteLoaderTest {

@Before
public void setUp() {
IvySettings ivySettings = new IvySettings();
cache = new File("build/cache");
cache.mkdirs();

IvySettings ivySettings = new IvySettings();
ivySettings.setDefaultCache(cache);

CacheResourceOptions options = new CacheResourceOptions();
loader = new UpdateSiteLoader(ivySettings.getDefaultRepositoryCacheManager(), null, options, null);
}
Expand All @@ -62,9 +62,14 @@ public void tearDown() {
}

@Test
public void testIvyDE() throws IOException, ParseException, SAXException, URISyntaxException {
RepoDescriptor site = loader.load(new URI(
"https://archive.apache.org/dist/ant/ivyde/updatesite/"));
public void testIvyDE() throws Exception {
URI uri = new URI("https://archive.apache.org/dist/ant/ivyde/updatesite/");
try {
uri.toURL().getContent();
} catch (Exception e) {
assumeNoException(e);
}
RepoDescriptor site = loader.load(uri);
assertTrue(site.getModules().hasNext());
Iterator<ModuleDescriptorWrapper> it = site.getModules();
while (it.hasNext()) {
Expand All @@ -73,19 +78,16 @@ public void testIvyDE() throws IOException, ParseException, SAXException, URISyn
}
}

@Ignore // download site seems to have changed
@Ignore("download site seems to have changed")
@Test
public void testM2Eclipse() throws IOException, ParseException, SAXException,
URISyntaxException {
RepoDescriptor site = loader.load(new URI(
"https://download.eclipse.org/technology/m2e/releases/"));
public void testM2Eclipse() throws Exception {
RepoDescriptor site = loader.load(new URI("https://download.eclipse.org/technology/m2e/releases/"));
assertTrue(CollectionUtils.toList(site.getModules()).size() > 20);
}

@Ignore
@Test
public void testHeliosEclipse() throws IOException, ParseException, SAXException,
URISyntaxException {
public void testHeliosEclipse() throws Exception {
RepoDescriptor site = loader.load(new URI("https://download.eclipse.org/releases/helios/"));
assertTrue(CollectionUtils.toList(site.getModules()).size() > 900);
}
Expand Down
Loading