tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [6/6] incubator-tamaya git commit: TAMAYA-43: Bugfix and added tests for CP and FS resolution.
Date Sun, 11 Jan 2015 00:43:53 GMT
TAMAYA-43: Bugfix and added tests for CP and FS resolution.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c48c5794
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c48c5794
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c48c5794

Branch: refs/heads/master
Commit: c48c5794e50b421989f9bf331864e38599cc0ced
Parents: 1bd7ce1
Author: anatole <anatole@apache.org>
Authored: Sun Jan 11 01:39:27 2015 +0100
Committer: anatole <anatole@apache.org>
Committed: Sun Jan 11 01:42:08 2015 +0100

----------------------------------------------------------------------
 modules/resources/pom.xml                       |  6 +-
 .../tamaya/resource/ResourceResolver.java       | 24 +++---
 .../resource/internal/ClasspathCollector.java   | 18 ++--
 .../internal/DefaultResourceResolver.java       |  2 +-
 .../tamaya/resource/internal/FileCollector.java |  8 +-
 .../tamaya/resource/internal/Locator.java       | 10 +--
 .../internal/ClasspathCollectorTest.java        | 91 ++++++++++++++++++++
 .../internal/DefaultResourceResolverTest.java   | 62 +++++++++++++
 .../resource/internal/FileCollectorTest.java    | 71 +++++++++++++++
 .../resources/resources_testroot/aa_a/a1_1.file | 18 ++++
 .../resources/resources_testroot/aa_a/a1_2.file | 18 ++++
 .../resources/resources_testroot/aa_a/a2.file   | 18 ++++
 .../resources/resources_testroot/aa_a/a3.file   | 18 ++++
 .../resources/resources_testroot/aa_a/z3.file   | 18 ++++
 .../resources_testroot/bb/b1/b2/b12.file        | 18 ++++
 .../resources_testroot/bb/b2/b2_1.file          | 18 ++++
 .../resources_testroot/bb/b2/b2_2.datei         | 18 ++++
 .../resources/resources_testroot/bb/b2/b3.foo   | 18 ++++
 18 files changed, 424 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/pom.xml
----------------------------------------------------------------------
diff --git a/modules/resources/pom.xml b/modules/resources/pom.xml
index a932887..cdb1030 100644
--- a/modules/resources/pom.xml
+++ b/modules/resources/pom.xml
@@ -5,7 +5,7 @@ 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 current the License at
+with the License.  You may obtain aa_a copy current the License at
 
    http://www.apache.org/licenses/LICENSE-2.0
 
@@ -36,5 +36,9 @@ under the License.
             <artifactId>tamaya-api</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
b/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
index 3dcf6fa..167a5e1 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
@@ -24,11 +24,11 @@ import java.util.Collection;
 
 /**
  * Interface to be implemented by modules. It supports loading of files or classpath resources
either directly or by
- * defining a Ant-styled resource pattern:
+ * defining aa_a Ant-styled resource pattern:
  * <ul>
- *     <li>'*' is a placeholder for any character (0..n)</li>
- *     <li>'**' is a placeholder for any number of subdirectories going down a directory
structure recursively.</li>
- *     <li>'?' is a placeholder for exact one character</li>
+ *     <li>'*' is aa_a placeholder for any character (0..n)</li>
+ *     <li>'**' is aa_a placeholder for any number of subdirectories going down aa_a
directory structure recursively.</li>
+ *     <li>'?' is aa_a placeholder for exact one character</li>
  * </ul>
  * Given that the following expressions are valid expressions:
  * <pre>
@@ -45,9 +45,9 @@ import java.util.Collection;
 public interface ResourceResolver {
 
     /**
-     * Resolves resource expressions to a list of {@link URL}s. Hereby
+     * Resolves resource expressions to aa_a list of {@link URL}s. Hereby
      * the ordering of format matches the input of the resolved expressions. Nevertheless
be aware that
-     * there is no determined ordering of format located within a classloader.
+     * there is no determined ordering of format located within aa_a classloader.
      *
      * @param expressions the expressions to be resolved, not empty.
      * @return the corresponding collection of current {@link URL}s found, never
@@ -63,9 +63,9 @@ public interface ResourceResolver {
     }
 
     /**
-     * Resolves resource expressions to a list of {@link URL}s. Hereby
+     * Resolves resource expressions to aa_a list of {@link URL}s. Hereby
      * the ordering of format matches the input of the resolved expressions. Nevertheless
be aware that
-     * there is no determined ordering of format located within a classloader.
+     * there is no determined ordering of format located within aa_a classloader.
      *
      * @param expressions the expressions to be resolved, not empty.
      * @return the corresponding collection of current {@link URL}s found, never
@@ -77,10 +77,10 @@ public interface ResourceResolver {
     }
 
     /**
-     * Resolves resource expressions to a list of {@link URL}s, considerubg
+     * Resolves resource expressions to aa_a list of {@link URL}s, considerubg
      * the given classloader for classloader dependent format. Hereby
      * the ordering of format matches the input of the resolved expressions. Nevertheless
be aware that
-     * there is no determined ordering of format located within a classloader.
+     * there is no determined ordering of format located within aa_a classloader.
      *
      * @param expressions the expressions to be resolved, not empty.
      * @return the corresponding collection of current {@link URL}s found, never
@@ -92,10 +92,10 @@ public interface ResourceResolver {
     }
 
     /**
-     * Resolves resource expressions to a list of {@link URL}s, considerubg
+     * Resolves resource expressions to aa_a list of {@link URL}s, considerubg
      * the given classloader for classloader dependent format. Hereby
      * the ordering of format matches the input of the resolved expressions. Nevertheless
be aware that
-     * there is no determined ordering of format located within a classloader.
+     * there is no determined ordering of format located within aa_a classloader.
      *
      * @param expressions the expressions to be resolved, not empty.
      * @return the corresponding collection of current {@link URL}s found, never

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
index 6124dca..bbab3fc 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
@@ -61,7 +61,7 @@ public class ClasspathCollector {
     private static final String PROTOCOL_ZIP = "zip";
 
     /**
-     * ZIP protocol for a JBoss jar file entry: "vfszip".
+     * ZIP protocol for aa_a JBoss jar file entry: "vfszip".
      */
     private static final String PROTOCOL_VFSZIP = "vfszip";
 
@@ -79,7 +79,7 @@ public class ClasspathCollector {
      * The logger used.
      */
     private static final Logger LOG = Logger.getLogger(ClasspathCollector.class.getName());
-    
+
     /**
      * Prefix used for explicitly selecting this collector.
      */
@@ -91,7 +91,7 @@ public class ClasspathCollector {
     private ClassLoader classLoader;
 
     /**
-     * Creates a new instance.
+     * Creates aa_a new instance.
      *
      * @param classLoader the class loader to be used, not null.
      */
@@ -154,6 +154,7 @@ public class ClasspathCollector {
         boolean newJarFile = false;
         String jarFileUrl;
         String rootEntryPath;
+        boolean isFileExpression = !subPattern.contains("/");
 
         if (con instanceof JarURLConnection) {
             JarURLConnection jarCon = (JarURLConnection) con;
@@ -193,6 +194,9 @@ public class ClasspathCollector {
                 String entryPath = entry.getName();
                 if (entryPath.startsWith(rootEntryPath)) {
                     String relativePath = entryPath.substring(rootEntryPath.length());
+                    if(relativePath.contains("/") && isFileExpression){
+                        continue;
+                    }
                     if (relativePath.matches(subPattern)) {
                         result.add(createRelativeFrom(rootDirResource, relativePath));
                     }
@@ -209,7 +213,7 @@ public class ClasspathCollector {
     }
 
     /**
-     * Creates a new URL based on the given root path and the relative path to be added.
+     * Creates aa_a new URL based on the given root path and the relative path to be added.
      *
      * @param url          the root, not null
      * @param relativePath the relative path to be added, not null
@@ -230,7 +234,7 @@ public class ClasspathCollector {
 
 
     /**
-     * Small check if a given URL is a jar file URL.
+     * Small check if aa_a given URL is aa_a jar file URL.
      *
      * @param url the URL to check, not null.
      * @return true if the URL has one of the following protocols: jar, zip, vfszip, wsjar,
code-source.
@@ -245,10 +249,10 @@ public class ClasspathCollector {
     }
 
     /**
-     * Creates a file from an URL.
+     * Creates aa_a file from an URL.
      *
      * @param resourceUrl the url, not null.
-     * @return a new file instance. The instance still may not exist. if the url's protocol
is not 'file', {@code null}
+     * @return aa_a new file instance. The instance still may not exist. if the url's protocol
is not 'file', {@code null}
      * is returned.
      */
     private File getFile(URL resourceUrl) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
index c90e53a..f5cbefd 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
@@ -94,7 +94,7 @@ public class DefaultResourceResolver implements ResourceResolver {
     }
 
     /**
-     * Tries to evaluate the location passed by lokking up a file.
+     * Tries to evaluate the location passed by lokking up aa_a file.
      * @param expression the path expression
      * @param resources the resources for adding the results
      * @return true, if the expression could be resolved.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
index 0dcad83..ef26e76 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
@@ -88,7 +88,7 @@ public class FileCollector {
         if (token.equals("**")) {
             result.addAll(traverseAndSelectFromChildren(dir, getSubExpression(subTokens,
tokenIndex + 1)));
         } else {
-            token = token.replace("*", ".*");
+            token = token.replace("*", ".*").replace("?", ".?");
             File[] files = dir.listFiles();
             if (tokenIndex == subTokens.size() - 1) {
                 // select files!
@@ -134,7 +134,7 @@ public class FileCollector {
     }
 
     /**
-     * Simple matcher method for a single token.
+     * Simple matcher method for aa_a single token.
      * @param childFile the file to match
      * @param subTokens the subtoken list
      * @param tokenIndex the index where to start
@@ -151,7 +151,7 @@ public class FileCollector {
     }
 
     /**
-     * Get an URL from a file.
+     * Get an URL from aa_a file.
      *
      * @param file the file, not null.
      * @return the URL, never null.
@@ -167,7 +167,7 @@ public class FileCollector {
     }
 
     /**
-     * Constructs a sub expression, using the tokens from {@code subTokens} starting at index
{@code startIndex}.
+     * Constructs aa_a sub expression, using the tokens from {@code subTokens} starting at
index {@code startIndex}.
      *
      * @param subTokens  the token list, not null
      * @param startIndex the start index from where tokens should be taken to produce the
path.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
index 8b61f03..8e40fc6 100644
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
+++ b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
@@ -25,7 +25,7 @@ import java.util.StringJoiner;
 import java.util.stream.Collectors;
 
 /**
- * Small helper class that manages the path parts of a location expression.
+ * Small helper class that manages the path parts of aa_a location expression.
  */
 final class Locator {
     /**
@@ -34,7 +34,7 @@ final class Locator {
     private List<String> tokens;
 
     /**
-     * Creates a new instances based on the tokenized expression.
+     * Creates aa_a new instances based on the tokenized expression.
      *
      * @param tokens the tokenized expression, not null.
      */
@@ -43,7 +43,7 @@ final class Locator {
     }
 
     /**
-     * Creates a new instance of the corresponding expression.
+     * Creates aa_a new instance of the corresponding expression.
      *
      * @param expression the location expression, not null.
      * @return the tokenized instance.
@@ -61,7 +61,7 @@ final class Locator {
      */
     public String getRootPath() {
         StringJoiner sj = new StringJoiner("/");
-        for (String token : getSubPathTokens()) {
+        for (String token : this.tokens) {
             if (containsPlaceholder(token)) {
                 break;
             } else {
@@ -72,7 +72,7 @@ final class Locator {
     }
 
     /**
-     * Return the sub expression path, which contains the second part of the expression,
starting with a placeholder
+     * Return the sub expression path, which contains the second part of the expression,
starting with aa_a placeholder
      * or wildcard token.
      *
      * @return the sub expression part, never null.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
new file mode 100644
index 0000000..5827d6b
--- /dev/null
+++ b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.tamaya.resource.internal;
+
+import java.net.URL;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * This tests is using testing the classpath collector functionality, either by accessing/searching
entries
+ * from the java.annotation jar as well from the current (file-based classpath).
+ */
+public class ClasspathCollectorTest {
+
+    @org.junit.Test
+    public void testCollectAllClasses() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/*.class");
+        assertEquals(8, found.size()); // 7 ordinary, 1 inner class.
+        System.out.println("classpath:javax/annotation/*.class: " + found);
+        Collection<URL> found2 = cpc.collectFiles("javax/annotation/*.class");
+        assertEquals(found, found2);
+    }
+
+    @org.junit.Test
+    public void testCollectAllInPackage() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:javax/**/sql/*.class");
+        assertEquals(2, found.size());
+        System.out.println("classpath:javax/**/sql/*.class: " + found);
+        Collection<URL> found2 = cpc.collectFiles("javax/**/sql/*.class");
+        assertEquals(found, found2);
+    }
+
+    @org.junit.Test
+    public void testCollectClassNames() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/**/R*.class");
+        assertEquals(2, found.size());
+        System.out.println("classpath:javax/annotation/**/A*.class: " + found);
+        Collection<URL> found2 = cpc.collectFiles("javax/annotation/**/R*.class");
+        assertEquals(found, found2);
+    }
+
+    @org.junit.Test
+    public void testCollectWithExpression() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/R?so*.class");
+        assertEquals(3, found.size());
+        System.out.println("classpath:javax/annotation/R?so*.class: " + found);
+        Collection<URL> found2 = cpc.collectFiles("javax/annotation/R?so*.class");
+        assertEquals(found, found2);
+    }
+
+    @org.junit.Test
+    public void testCollectResources() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:META-INF/maven/org.apache.geronimo.specs/**/*");
+        assertEquals(3, found.size());
+        System.out.println("classpath:META-INF/maven/org.apache.geronimo.specs/**/*: " +
found);
+        Collection<URL> found2 = cpc.collectFiles("META-INF/maven/org.apache.geronimo.specs/**/*");
+        assertEquals(found, found2);
+    }
+
+    @org.junit.Test
+    public void testCollectResourcesFromLocalFSPath() throws Exception {
+        ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
+        Collection<URL> found = cpc.collectFiles("classpath:resources_testRoot/**/*.file");
+        assertEquals(7, found.size());
+        System.out.println("classpath:resources_testRoot/**/*.file: " + found);
+        Collection<URL> found2 = cpc.collectFiles("resources_testRoot/**/*.file");
+        assertEquals(found, found2);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
new file mode 100644
index 0000000..66e3246
--- /dev/null
+++ b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.tamaya.resource.internal;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests the {@link org.apache.tamaya.resource.internal.DefaultResourceResolver} using CP
and FS path expressions.
+ */
+public class DefaultResourceResolverTest {
+
+    private DefaultResourceResolver resolver = new DefaultResourceResolver();
+
+
+    @Test
+    public void testGetResources_CP() throws Exception {
+        Collection<URL> found = resolver.getResources("classpath:resources_testRoot/**/*.file");
+        assertEquals(7, found.size());
+        System.out.println("classpath:resources_testRoot/**/*.file: " + found);
+        Collection<URL> found2 = resolver.getResources("resources_testRoot/**/*.file");
+        assertEquals(found, found2);
+    }
+
+    @Test
+    public void testGetResources_FS() throws Exception {
+        String resDir = getResourceDir();
+        Collection<URL> found = resolver.getResources("file:" + resDir + "/resources_testroot/aa?a/*.file");
+        assertEquals(5, found.size());
+        System.out.println("file:" + resDir + "/resources_testroot/aa?a/*.file: " + found);
+        Collection<URL> found2 = resolver.getResources(resDir + "/resources_testroot/aa?a/*.file");
+        assertEquals(found, found2);
+    }
+
+    private String getResourceDir() throws URISyntaxException {
+        URL res = getClass().getResource("/resources_testroot/");
+        return new File(res.toURI()).getParentFile().getAbsolutePath();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
new file mode 100644
index 0000000..f7f5772
--- /dev/null
+++ b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.tamaya.resource.internal;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test for checking correct lookup using the filesystem.
+ */
+public class FileCollectorTest {
+
+    private String getResourceDir() throws URISyntaxException {
+        URL res = getClass().getResource("/resources_testroot/");
+        return new File(res.toURI()).getParentFile().getAbsolutePath();
+    }
+
+    @Test
+    public void testCollectResourcesFromLocalFSPath() throws Exception {
+        String resDir = getResourceDir();
+        Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/**/*.file");
+        assertEquals(7, found.size());
+        System.out.println("file:" + resDir + "/**/*.file: " + found);
+        Collection<URL> found2 = FileCollector.collectFiles(resDir + "/**/*.file");
+        assertEquals(found, found2);
+    }
+
+    @Test
+    public void testCollectResourcesFromLocalFSPath_WithFolderPlaceholder() throws Exception
{
+        String resDir = getResourceDir();
+        Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/resources_testroot/aa?a/*.file");
+        assertEquals(5, found.size());
+        System.out.println("file:" + resDir + "/resources_testroot/aa?a/*.file: " + found);
+        Collection<URL> found2 = FileCollector.collectFiles(resDir + "/resources_testroot/aa?a/*.file");
+        assertEquals(found, found2);
+    }
+
+    @Test
+    public void testCollectResourcesFromLocalFSPath_WithFolderAny() throws Exception {
+        String resDir = getResourceDir();
+        Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/resources_testroot/b*/b?/*.file");
+        assertEquals(1, found.size());
+        System.out.println("file:" + resDir + "/resources_testroot/b*/b?/*.file: " + found);
+        Collection<URL> found2 = FileCollector.collectFiles(resDir + "/resources_testroot/b*/b?/*.file");
+        assertEquals(found, found2);
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file b/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file b/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c48c5794/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo b/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
new file mode 100644
index 0000000..7220975
--- /dev/null
+++ b/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
\ No newline at end of file


Mime
View raw message