refactor tests with hardcoded Maven Central URL

This commit is contained in:
Gintas Grigelionis 2017-12-05 12:15:20 +01:00
parent d80acb29c0
commit 2f4bf4db63
4 changed files with 16 additions and 10 deletions

View File

@ -17,8 +17,10 @@
*/
package org.apache.ivy.osgi.obr;
import static org.apache.ivy.plugins.resolver.IBiblioResolver.DEFAULT_M2_ROOT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@ -63,10 +65,11 @@ public class OBRParserTest {
String url0 = md.getAllArtifacts()[0].getUrl().toExternalForm();
String type1 = md.getAllArtifacts()[1].getType();
String url1 = md.getAllArtifacts()[1].getUrl().toExternalForm();
String jarUrl = "https://repo1.maven.org/maven2/org/apache/felix/"
+ "org.apache.felix.bundlerepository/1.0.3/org.apache.felix.bundlerepository-1.0.3.jar";
String srcUrl = "http://oscar-osgi.sf.net/obr2/org.apache.felix.bundlerepository/"
+ "org.apache.felix.bundlerepository-1.0.3-src.jar";
assertTrue("Default Maven URL must end with '/'", DEFAULT_M2_ROOT.endsWith("/"));
String jarUrl = DEFAULT_M2_ROOT + "org/apache/felix/org.apache.felix."
+ "bundlerepository/1.0.3/org.apache.felix.bundlerepository-1.0.3.jar";
String srcUrl = "http://oscar-osgi.sf.net/obr2/org.apache.felix."
+ "bundlerepository/org.apache.felix.bundlerepository-1.0.3-src.jar";
if (type0.equals("jar")) {
assertEquals(jarUrl, url0);
assertEquals("source", type1);

View File

@ -35,6 +35,7 @@ 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;
public class UpdateSiteAndIbiblioResolverTest {
@ -68,7 +69,7 @@ public class UpdateSiteAndIbiblioResolverTest {
resolver2 = new IBiblioResolver();
resolver2.setName("maven2");
settings.setVariable("ivy.ibiblio.default.artifact.root", "https://repo1.maven.org/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);

View File

@ -17,6 +17,7 @@
*/
package org.apache.ivy.plugins.resolver;
import static org.apache.ivy.plugins.resolver.IBiblioResolver.DEFAULT_M2_ROOT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -119,8 +120,9 @@ public class IBiblioResolverTest extends AbstractDependencyResolverTest {
l = resolver.getArtifactPatterns();
assertNotNull(l);
assertEquals(1, l.size());
assertEquals(
"https://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]",
assertTrue("Default Maven URL must end with '/'", DEFAULT_M2_ROOT.endsWith("/"));
assertEquals(DEFAULT_M2_ROOT
+ "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]",
l.get(0));
resolver = (IBiblioResolver) settings.getResolver("ibiblioD");

View File

@ -36,6 +36,7 @@ import java.nio.file.Path;
import java.util.Collections;
import java.util.Random;
import static org.apache.ivy.plugins.resolver.IBiblioResolver.DEFAULT_M2_ROOT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -90,9 +91,8 @@ public class HttpclientURLHandlerTest {
@Test
public void testGetURLInfo() throws Exception {
URLHandler handler = new HttpClientHandler();
URLInfo info = handler
.getURLInfo(new URL(
"https://repo1.maven.org/maven2/commons-lang/commons-lang/[1.0,3.0[/commons-lang-[1.0,3.0[.pom"), defaultTimeoutConstraint);
URLInfo info = handler.getURLInfo(new URL(DEFAULT_M2_ROOT
+ "/commons-lang/commons-lang/[1.0,3.0[/commons-lang-[1.0,3.0[.pom"), defaultTimeoutConstraint);
assertEquals(URLHandler.UNAVAILABLE, info);
}