You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by ga...@apache.org on 2013/03/07 17:06:21 UTC
svn commit: r1453936 - in /geronimo/xbean/trunk/xbean-finder/src:
main/java/org/apache/xbean/finder/archive/JarArchive.java
test/java/org/apache/xbean/finder/FileDecodeFinderTest.java
test/java/org/apache/xbean/finder/archive/Archives.java
Author: gawor
Date: Thu Mar 7 16:06:21 2013
New Revision: 1453936
URL: http://svn.apache.org/r1453936
Log:
XBEAN-241: finder doesn't handle #. Patch from Romain Manni-Bucau.
Added:
geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java (with props)
Modified:
geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java
Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java?rev=1453936&r1=1453935&r2=1453936&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java Thu Mar 7 16:06:21 2013
@@ -50,7 +50,7 @@ public class JarArchive implements Archi
jarPath = jarPath.substring(0, jarPath.indexOf("!"));
u = new URL(jarPath);
}
- jar = new JarFile(u.getFile().replace("%20", " ")); // no more an url
+ jar = new JarFile(FileArchive.decode(u.getFile())); // no more an url
} catch (IOException e) {
throw new IllegalStateException(e);
}
Added: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java?rev=1453936&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java Thu Mar 7 16:06:21 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.xbean.finder;
+
+import org.apache.xbean.finder.archive.Archives;
+import org.apache.xbean.finder.archive.JarArchive;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+public class FileDecodeFinderTest {
+
+ @Test
+ public void testSharp() throws Exception {
+ doTest(createLib("folder##"));
+ }
+
+ @Test
+ public void testSpace() throws Exception {
+ doTest(createLib("folder with a space"));
+ }
+
+ private void doTest(final File lib) throws MalformedURLException {
+ final AnnotationFinder all = new AnnotationFinder(new JarArchive(Thread.currentThread().getContextClassLoader(), lib.toURI().toURL()));
+ assertEquals(1, all.findAnnotatedClasses(Marker.class).size());
+ }
+
+ private File createLib(final String name) throws IOException {
+ final File jar = new File("target/" + name + "/lib/dep.jar"); // target is useless with xbean surefire config but better in ide ;)
+ jar.getParentFile().mkdirs();
+ Archives.jarArchive(jar, Collections.<String, String>emptyMap(), Marker.class, SuperSimpleBean.class);
+ return jar;
+ }
+
+ @java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE})
+ @java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
+ public @interface Marker {}
+
+ @Marker public static class SuperSimpleBean {}
+}
Propchange: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FileDecodeFinderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java?rev=1453936&r1=1453935&r2=1453936&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java Thu Mar 7 16:06:21 2013
@@ -98,10 +98,19 @@ public class Archives {
}
public static File jarArchive(Map<String, String> entries, Class... classes) throws IOException {
+ return jarArchive(null, entries, classes);
+ }
+
+ public static File jarArchive(File path, Map<String, String> entries, Class... classes) throws IOException {
ClassLoader loader = Archives.class.getClassLoader();
- File classpath = File.createTempFile("path with spaces", ".jar");
+ File classpath;
+ if (path == null) {
+ classpath = File.createTempFile("path with spaces", ".jar");
+ } else {
+ classpath = path;
+ }
// Create the ZIP file
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(classpath)));