Merge pull request #13 from apache/issues/SLING-8421-2
SLING-8421: Allow artifact providers that work with URLs instead of F…
diff --git a/src/main/java/org/apache/sling/feature/io/IOUtils.java b/src/main/java/org/apache/sling/feature/io/IOUtils.java
index 205052d..fa64815 100644
--- a/src/main/java/org/apache/sling/feature/io/IOUtils.java
+++ b/src/main/java/org/apache/sling/feature/io/IOUtils.java
@@ -17,12 +17,20 @@
package org.apache.sling.feature.io;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.jar.JarFile;
public class IOUtils {
@@ -155,6 +163,94 @@
return paths;
}
+ /**
+ * Get a File from a local URL (if possible)
+ *
+ * @param url a local url (like a file: url or a jar:file: url
+ * @param cache if an attempt should be made to download the content of the url locally
+ * if it can not be presented as a file directly
+ * @param tmpDir the tmpDir to use (null for default)
+ * @return the file the url points to (or null if none) - or a tmp file if cache is true and the url could be cached
+ * @throws IOException
+ */
+ public static File getFileFromURL(URL url, boolean cache, File tmpDir) throws IOException {
+ File result;
+ if (url.getProtocol().equals("file")) {
+ try {
+ result = new File(url.toURI());
+ } catch (URISyntaxException e) {
+ result = new File(url.getPath());
+ }
+ } else if (url.getProtocol().equals("jar")) {
+ String innerURL = url.getPath();
+ if (innerURL.endsWith("!/") && innerURL.indexOf("!/") == innerURL.lastIndexOf("!/")) {
+ innerURL = innerURL.substring(0, innerURL.indexOf("!/"));
+ try {
+ result = getFileFromURL(new URL(innerURL), cache, tmpDir);
+ } catch (IOException ex) {
+ result = null;
+ }
+ }
+ else {
+ result = null;
+ }
+ }
+ else {
+ result = null;
+ }
+
+ if ((result == null || !result.exists()) && cache) {
+ File tmp = File.createTempFile("jar", ".jar", tmpDir);
+ try (InputStream input = url.openStream(); OutputStream output = new FileOutputStream(tmp)) {
+ byte[] buffer =new byte[64 * 1024];
+ for (int i = input.read(buffer); i != -1;i = input.read(buffer)) {
+ output.write(buffer, 0, i);
+ }
+ }
+ result = tmp;
+ }
+ return result;
+ }
+
+ /**
+ * Get a JarFile from a local URL (if possible)
+ *
+ * @param url a local url (like a file: url or a jar:file: url
+ * @param cache if an attempt should be made to download the content of the url locally
+ * if it can not be presented as a jarfile directly
+ * @param tmpDir the tmpDir to use (null for default)
+ *
+ * @return the jarfile the url points to
+ * @throws IOException if the url can't be represented as a jarfile
+ */
+ public static JarFile getJarFileFromURL(URL url, boolean cache, File tmpDir) throws IOException {
+ try {
+ URL targetURL = url;
+ if (!url.getProtocol().equals("jar")) {
+ targetURL = new URL("jar:" + toURLString(url) + "!/");
+ }
+ else if (!url.getPath().endsWith("!/")) {
+ targetURL = new URL(toURLString(url) + "!/");
+ }
+ return ((JarURLConnection) targetURL.openConnection()).getJarFile();
+ } catch (IOException ex) {
+ File file = getFileFromURL(url, cache, tmpDir);
+ if (file != null) {
+ return new JarFile(file);
+ }
+ else {
+ throw ex;
+ }
+ }
+ }
+
+ private static String toURLString(URL url) {
+ try {
+ return url.toURI().toURL().toString();
+ } catch (URISyntaxException | MalformedURLException e) {
+ return url.toString();
+ }
+ }
static final Comparator<String> FEATURE_PATH_COMP = new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
diff --git a/src/main/java/org/apache/sling/feature/io/file/ArtifactHandler.java b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactHandler.java
similarity index 77%
rename from src/main/java/org/apache/sling/feature/io/file/ArtifactHandler.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/ArtifactHandler.java
index e1d4ab0..044a8ef 100644
--- a/src/main/java/org/apache/sling/feature/io/file/ArtifactHandler.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactHandler.java
@@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts;
-import java.io.File;
+import java.net.URL;
/**
* A handler provides a file object for an artifact.
@@ -25,17 +25,17 @@
private final String url;
- private final File file;
+ private final URL localURL;
/**
* Create a new handler.
*
* @param url The url of the artifact
- * @param file The file for the artifact
+ * @param localURL The local URL for the artifact
*/
- public ArtifactHandler(final String url, final File file) {
+ public ArtifactHandler(final String url, final URL localURL) {
this.url = url;
- this.file = file;
+ this.localURL = localURL;
}
/**
@@ -48,11 +48,11 @@
}
/**
- * Get a file for the artifact
+ * Get a local url for the artifact
*
* @return The file
*/
- public File getFile() {
- return file;
+ public URL getLocalURL() {
+ return localURL;
}
}
diff --git a/src/main/java/org/apache/sling/feature/io/file/ArtifactManager.java b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
similarity index 91%
rename from src/main/java/org/apache/sling/feature/io/file/ArtifactManager.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
index 0db5c51..5767c3b 100644
--- a/src/main/java/org/apache/sling/feature/io/file/ArtifactManager.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManager.java
@@ -14,26 +14,27 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.file.Files;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.io.file.spi.ArtifactProvider;
-import org.apache.sling.feature.io.file.spi.ArtifactProviderContext;
+import org.apache.sling.feature.io.artifacts.spi.ArtifactProvider;
+import org.apache.sling.feature.io.artifacts.spi.ArtifactProviderContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -109,7 +110,7 @@
shutdown();
}
- private final File getArtifactFromProviders(final String url, final String relativeCachePath) throws IOException {
+ private final URL getArtifactFromProviders(final String url, final String relativeCachePath) throws IOException {
final int pos = url.indexOf(":");
final String scheme = url.substring(0, pos);
@@ -149,8 +150,8 @@
while ( url.charAt(pos) == '/') {
pos++;
}
- final File file = this.getArtifactFromProviders(url, url.substring(pos));
- if ( file == null || !file.exists()) {
+ final URL file = this.getArtifactFromProviders(url, url.substring(pos));
+ if ( file == null ) {
throw new IOException("Artifact " + url + " not found.");
}
return new ArtifactHandler(url, file);
@@ -161,7 +162,7 @@
if ( !f.exists()) {
throw new IOException("Artifact " + url + " not found.");
}
- return new ArtifactHandler(f.toURI().toString(), f);
+ return new ArtifactHandler(f.toURI().toString(), f.toURI().toURL());
}
logger.debug("Querying repositories for {}", path);
@@ -185,7 +186,7 @@
logger.debug("Checking {} to get artifact from {}", handler, artifactUrl);
- final File file = handler.getArtifact(artifactUrl, path);
+ final URL file = handler.getArtifact(artifactUrl, path);
if ( file != null ) {
logger.debug("Found artifact {}", artifactUrl);
return new ArtifactHandler(artifactUrl, file);
@@ -211,8 +212,8 @@
while ( fullURL.charAt(pos2) == '/') {
pos2++;
}
- final File file2 = this.getArtifactFromProviders(fullURL, path);
- if ( file2 == null || !file2.exists()) {
+ final URL file2 = this.getArtifactFromProviders(fullURL, path);
+ if ( file2 == null ) {
throw new IOException("Artifact " + fullURL + " not found.");
}
return new ArtifactHandler(artifactUrl, file2);
@@ -228,8 +229,10 @@
protected String getFileContents(final ArtifactHandler handler) throws IOException {
final StringBuilder sb = new StringBuilder();
- for(final String line : Files.readAllLines(handler.getFile().toPath())) {
- sb.append(line).append('\n');
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(handler.getLocalURL().openStream(), "UTF-8"))) {
+ for(String line = reader.readLine(); line != null; line = reader.readLine()) {
+ sb.append(line).append('\n');
+ }
}
return sb.toString();
@@ -296,14 +299,14 @@
}
@Override
- public File getArtifact(final String url, final String relativeCachePath) {
+ public URL getArtifact(final String url, final String relativeCachePath) {
logger.debug("Checking url to be local file {}", url);
// check if this is already a local file
try {
final File f = new File(new URL(url).toURI());
if ( f.exists() ) {
this.config.incLocalArtifacts();
- return f;
+ return f.toURI().toURL();
}
return null;
} catch ( final URISyntaxException ise) {
@@ -361,7 +364,7 @@
} else {
this.config.incCachedArtifacts();
}
- return cacheFile;
+ return cacheFile.toURI().toURL();
} catch ( final Exception e) {
logger.info("Artifact not found in one repository", e);
// ignore for now
diff --git a/src/main/java/org/apache/sling/feature/io/file/ArtifactManagerConfig.java b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManagerConfig.java
similarity index 96%
rename from src/main/java/org/apache/sling/feature/io/file/ArtifactManagerConfig.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManagerConfig.java
index d3c8bea..d03c7e3 100644
--- a/src/main/java/org/apache/sling/feature/io/file/ArtifactManagerConfig.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/ArtifactManagerConfig.java
@@ -14,13 +14,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import org.apache.sling.feature.io.file.spi.ArtifactProviderContext;
+import org.apache.sling.feature.io.artifacts.spi.ArtifactProviderContext;
/**
* This class holds the configuration of artifact manager.
diff --git a/src/main/java/org/apache/sling/feature/io/file/package-info.java b/src/main/java/org/apache/sling/feature/io/artifacts/package-info.java
similarity index 94%
rename from src/main/java/org/apache/sling/feature/io/file/package-info.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/package-info.java
index 83cd885..08e8d2c 100644
--- a/src/main/java/org/apache/sling/feature/io/file/package-info.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/package-info.java
@@ -18,6 +18,6 @@
*/
@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts;
diff --git a/src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProvider.java b/src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProvider.java
similarity index 89%
rename from src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProvider.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProvider.java
index c238946..8b27ba5 100644
--- a/src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProvider.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProvider.java
@@ -14,10 +14,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file.spi;
+package org.apache.sling.feature.io.artifacts.spi;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import org.osgi.annotation.versioning.ConsumerType;
@@ -52,7 +53,7 @@
* @param url Artifact url
* @param relativeCachePath A relative path that can be used as a cache path
* by the provider. The path does not start with a slash.
- * @return A file if the artifact exists or {@code null}
+ * @return A local url if the artifact exists or {@code null}
*/
- File getArtifact(String url, String relativeCachePath);
+ URL getArtifact(String url, String relativeCachePath);
}
diff --git a/src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProviderContext.java b/src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProviderContext.java
similarity index 96%
rename from src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProviderContext.java
rename to src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProviderContext.java
index 02a9722..dccfbfc 100644
--- a/src/main/java/org/apache/sling/feature/io/file/spi/ArtifactProviderContext.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/spi/ArtifactProviderContext.java
@@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file.spi;
+package org.apache.sling.feature.io.artifacts.spi;
import java.io.File;
diff --git a/src/main/java/org/apache/sling/feature/io/file/package-info.java b/src/main/java/org/apache/sling/feature/io/artifacts/spi/package-info.java
similarity index 94%
copy from src/main/java/org/apache/sling/feature/io/file/package-info.java
copy to src/main/java/org/apache/sling/feature/io/artifacts/spi/package-info.java
index 83cd885..bb0c1f0 100644
--- a/src/main/java/org/apache/sling/feature/io/file/package-info.java
+++ b/src/main/java/org/apache/sling/feature/io/artifacts/spi/package-info.java
@@ -18,6 +18,6 @@
*/
@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts.spi;
diff --git a/src/main/java/org/apache/sling/feature/io/file/spi/package-info.java b/src/main/java/org/apache/sling/feature/io/file/spi/package-info.java
deleted file mode 100644
index eef08c6..0000000
--- a/src/main/java/org/apache/sling/feature/io/file/spi/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-
-@org.osgi.annotation.versioning.Version("1.0.0")
-package org.apache.sling.feature.io.file.spi;
-
-
diff --git a/src/test/java/org/apache/sling/feature/io/IOUtilsTest.java b/src/test/java/org/apache/sling/feature/io/IOUtilsTest.java
index 08ce172..4c72e0f 100644
--- a/src/test/java/org/apache/sling/feature/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/sling/feature/io/IOUtilsTest.java
@@ -17,13 +17,31 @@
package org.apache.sling.feature.io;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
-import org.apache.sling.feature.io.IOUtils;
import org.junit.Test;
public class IOUtilsTest {
@@ -47,4 +65,98 @@
}
}
+ @Test public void testGetFileFromURL() throws IOException {
+ File file = File.createTempFile("IOUtilsTest \\\\+%23öäü^^^°$::", ".test");
+
+ try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"))) {
+ writer.println("Hello");
+ }
+
+ assertEquals(file, IOUtils.getFileFromURL(new URL("file:" + file.getPath()), false, null));
+
+ assertEquals(file, IOUtils.getFileFromURL(file.toURI().toURL(), false, null));
+
+ URL url = new URL(null,"bla:" + file.toURI().toURL(), new URLStreamHandler() {
+ @Override
+ protected URLConnection openConnection(URL u){
+ return new URLConnection(u) {
+ @Override
+ public void connect()
+ {
+
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ return new FileInputStream(file);
+ }
+ };
+ }
+ });
+
+ assertNull(IOUtils.getFileFromURL(url, false, null));
+ File tmp = IOUtils.getFileFromURL(url, true, null);
+
+ assertNotEquals(file, tmp);
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tmp), "UTF-8"))) {
+ assertEquals("Hello", reader.readLine());
+ }
+
+ File jarFile = File.createTempFile("\"IOUtilsTest \\\\\\\\+%23öäü^^^°$::\"", ".jar");
+
+ try (JarOutputStream output = new JarOutputStream(new FileOutputStream(jarFile))) {
+ output.putNextEntry(new JarEntry("test"));
+ output.write("Hello".getBytes());
+ output.closeEntry();
+ }
+
+ assertEquals(jarFile, IOUtils.getFileFromURL(new URL("jar:file:" + jarFile.getPath() + "!/"), false, null));
+ assertEquals(jarFile, IOUtils.getFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/"), false, null));
+ assertNull(IOUtils.getFileFromURL(new URL("jar:file:" + jarFile.getPath() + "!/test"), false, null));
+ File tmpJar = IOUtils.getFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/test"), true, null);
+ assertNotNull(tmpJar);
+ assertNotEquals(jarFile, tmpJar);
+ }
+
+ @Test public void testGetJarFileFromURL() throws IOException {
+ File jarFile = File.createTempFile("\"IOUtilsTest \\\\\\\\+%23öäü^^^°$::\"", ".jar");
+
+ try (JarOutputStream output = new JarOutputStream(new FileOutputStream(jarFile))) {
+ output.putNextEntry(new JarEntry("test"));
+ output.write("Hello".getBytes());
+ output.closeEntry();
+ output.putNextEntry(new JarEntry("test.jar"));
+ try (JarOutputStream inner = new JarOutputStream(output)) {
+ inner.putNextEntry(new JarEntry("inner"));
+ inner.write("Hello".getBytes());
+ inner.closeEntry();
+ }
+ }
+
+ JarFile jar = IOUtils.getJarFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/"), true, null);
+ assertNotNull(jar);
+ jar = IOUtils.getJarFileFromURL(jarFile.toURI().toURL(), true, null);
+ assertNotNull(jar);
+
+ assertNull(IOUtils.getFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/test"), false, null));
+
+ JarFile tmpJar = IOUtils.getJarFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/test.jar"), true, null);
+ assertNotNull(tmpJar);
+ assertNotNull(tmpJar.getEntry("inner"));
+
+ try {
+ IOUtils.getJarFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/test"), true, null);
+ fail();
+ } catch (IOException ex) {
+ // Expected
+ }
+
+ try {
+ IOUtils.getJarFileFromURL(new URL("jar:" + jarFile.toURI().toURL() + "!/test.jar"), false, null);
+ fail();
+ } catch (IOException ex) {
+ // Expected
+ }
+ }
}
diff --git a/src/test/java/org/apache/sling/feature/io/file/ArtifactManagerTest.java b/src/test/java/org/apache/sling/feature/io/artifacts/ArtifactManagerTest.java
similarity index 85%
rename from src/test/java/org/apache/sling/feature/io/file/ArtifactManagerTest.java
rename to src/test/java/org/apache/sling/feature/io/artifacts/ArtifactManagerTest.java
index 69d9d32..5894734 100644
--- a/src/test/java/org/apache/sling/feature/io/file/ArtifactManagerTest.java
+++ b/src/test/java/org/apache/sling/feature/io/artifacts/ArtifactManagerTest.java
@@ -14,22 +14,22 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.io.file;
+package org.apache.sling.feature.io.artifacts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import org.apache.sling.feature.io.file.ArtifactHandler;
-import org.apache.sling.feature.io.file.ArtifactManager;
-import org.apache.sling.feature.io.file.ArtifactManagerConfig;
-import org.apache.sling.feature.io.file.spi.ArtifactProvider;
+import org.apache.sling.feature.io.artifacts.ArtifactHandler;
+import org.apache.sling.feature.io.artifacts.ArtifactManager;
+import org.apache.sling.feature.io.artifacts.ArtifactManagerConfig;
+import org.apache.sling.feature.io.artifacts.spi.ArtifactProvider;
import org.junit.Test;
public class ArtifactManagerTest {
@@ -68,12 +68,9 @@
final ArtifactManagerConfig config = mock(ArtifactManagerConfig.class);
when(config.getRepositoryUrls()).thenReturn(new String[] {REPO});
- final File metadataFile = mock(File.class);
- when(metadataFile.exists()).thenReturn(true);
- when(metadataFile.getPath()).thenReturn("/maven-metadata.xml");
+ final URL metadataFile = new URL("file:/maven-metadata.xml");
- final File artifactFile = mock(File.class);
- when(artifactFile.exists()).thenReturn(true);
+ final URL artifactFile = new URL("file:/artifact");
final ArtifactProvider provider = mock(ArtifactProvider.class);
when(provider.getArtifact(REPO + "/group/artifact/1.0.0-SNAPSHOT/artifact-1.0.0-SNAPSHOT.txt", "group/artifact/1.0.0-SNAPSHOT/artifact-1.0.0-SNAPSHOT.txt")).thenReturn(null);
@@ -87,7 +84,7 @@
@Override
protected String getFileContents(final ArtifactHandler handler) throws IOException {
- final String path = handler.getFile().getPath();
+ final String path = handler.getLocalURL().getPath();
if ( "/maven-metadata.xml".equals(path) ) {
return METADATA;
}
@@ -97,6 +94,6 @@
final ArtifactHandler handler = mgr.getArtifactHandler("mvn:group/artifact/1.0.0-SNAPSHOT/txt");
assertNotNull(handler);
- assertEquals(artifactFile, handler.getFile());
+ assertEquals(artifactFile, handler.getLocalURL());
}
}