This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-1.4.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit ed82c567adfb74db48177df2700904e45f4c84c9 Author: Robert Munteanu <[email protected]> AuthorDate: Mon Jun 15 09:27:16 2015 +0000 SLING-4781 - Implement MockBundle.getEntryPaths Cleanup MockBundle.getEntry to always use an absolute path git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1685521 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/sling/testing/mock/osgi/MockBundle.java | 17 +++-------------- .../apache/sling/testing/mock/osgi/MockBundleTest.java | 1 + 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java index ffeecf2..32a3528 100644 --- a/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java +++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java @@ -70,20 +70,9 @@ public final class MockBundle implements Bundle { @Override public URL getEntry(final String name) { - // the original implementation of this method performed getClass().getResource() - // however, this means that the it does not work out-of-the-box with paths - // returned from getEntryPaths(), which are by definition relative - - // as a fallback we make sure the resource is absolute if the relative one does - // not get a result, but perhaps we should enforce a relative lookup at all times - - // try to load resource from classpath - URL resource = getClass().getResource(name); - - if ( resource == null || ! name.startsWith("/")) { - resource = getClass().getResource("/" + name); - } - return resource; + String nameToQuery = name.startsWith("/") ? name : "/" + name; + + return getClass().getResource(nameToQuery); } @Override diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java index fefcd93..38d4dc3 100644 --- a/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java +++ b/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java @@ -57,6 +57,7 @@ public class MockBundleTest { @Test public void testGetEntry() { assertNotNull(bundle.getEntry("/META-INF/test.txt")); + assertNotNull(bundle.getEntry("META-INF/test.txt")); assertNull(bundle.getEntry("/invalid")); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
