Updated Branches:
  refs/heads/master 0f74eec4f -> ec7a022bd
  refs/heads/sandbox/resourcefinder 55303c08b -> bba8177b4


WICKET-4617 complete tests


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

Branch: refs/heads/sandbox/resourcefinder
Commit: bba8177b4525e77233a97f6c09bb4ef426d6dd96
Parents: d11c407
Author: Carl-Eric Menzel <cmen...@wicketbuch.de>
Authored: Wed Jun 27 19:21:06 2012 +0200
Committer: Carl-Eric Menzel <cmen...@wicketbuch.de>
Committed: Wed Jun 27 19:21:06 2012 +0200

----------------------------------------------------------------------
 .../util/resource/ClassPathResourceFinderTest.java |   54 +++++++++++++++
 .../org/apache/wicket/util/resource/PathTest.java  |    6 +-
 .../util/resource/ResourceStreamLocatorTest.java   |   11 ++--
 3 files changed, 62 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/bba8177b/wicket-core/src/test/java/org/apache/wicket/core/util/resource/ClassPathResourceFinderTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/core/util/resource/ClassPathResourceFinderTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/core/util/resource/ClassPathResourceFinderTest.java
new file mode 100644
index 0000000..c3ac327
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/core/util/resource/ClassPathResourceFinderTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.wicket.core.util.resource;
+
+import static org.apache.wicket.util.resource.ResourceStreamLocatorTest.*;
+
+import java.io.File;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.junit.Test;
+
+public class ClassPathResourceFinderTest extends WicketTestCase
+{
+       @Test
+       public void loadStartingFromClasspathRoot() throws Exception
+       {
+               ClassPathResourceFinder finder = new 
ClassPathResourceFinder("");
+               String filename = 
ClassPathResourceFinderTest.class.getName().replace('.',
+                       File.separatorChar) +
+                       ".class";
+               IResourceStream rs = finder.find(WebApplication.class, 
filename);
+               assertNotNull(rs);
+               assertEquals(ClassPathResourceFinderTest.class.getSimpleName() 
+ ".class", getFilename(rs));
+       }
+
+       @Test
+       public void loadStartingFromPrefix() throws Exception
+       {
+               ClassPathResourceFinder finder = new ClassPathResourceFinder(
+                       ClassPathResourceFinderTest.class.getPackage()
+                               .getName()
+                               .replace('.', File.separatorChar));
+               String filename = 
ClassPathResourceFinderTest.class.getSimpleName() + ".class";
+               IResourceStream rs = finder.find(WebApplication.class, 
filename);
+               assertNotNull(rs);
+               assertEquals(ClassPathResourceFinderTest.class.getSimpleName() 
+ ".class", getFilename(rs));
+       }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/bba8177b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java 
b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
index e3ba41e..e2f418e 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/resource/PathTest.java
@@ -36,8 +36,7 @@ public class PathTest extends WicketTestCase
        @Test
        public void loadFromRootUsingSubpathInFilename() throws Exception
        {
-               Path path = new Path();
-               path.add(CLASSPATH_ROOT);
+               Path path = new Path(CLASSPATH_ROOT);
                IResourceStream rs = path.find(PathTest.class, PACKAGE_PATH + 
File.separatorChar + FILENAME);
                assertNotNull(rs);
                assertEquals(FILENAME, getFilename(rs));
@@ -46,8 +45,7 @@ public class PathTest extends WicketTestCase
        @Test
        public void loadFilenameFromPath() throws Exception
        {
-               Path path = new Path();
-               path.add(CLASSPATH_ROOT + File.separatorChar + PACKAGE_PATH);
+               Path path = new Path(CLASSPATH_ROOT + File.separatorChar + 
PACKAGE_PATH);
                IResourceStream rs = path.find(PathTest.class, FILENAME);
                assertNotNull(rs);
                assertEquals(FILENAME, getFilename(rs));

http://git-wip-us.apache.org/repos/asf/wicket/blob/bba8177b/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java
index 3e9d2f3..08b1ca9 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/util/resource/ResourceStreamLocatorTest.java
@@ -24,16 +24,17 @@ import java.net.URL;
 import java.util.Locale;
 
 import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.core.util.resource.ClassPathResourceFinder;
 import org.apache.wicket.core.util.resource.UrlResourceStream;
 import org.apache.wicket.core.util.resource.locator.IResourceStreamLocator;
 import org.apache.wicket.core.util.resource.locator.ResourceStreamLocator;
-import org.apache.wicket.util.file.Path;
+import org.apache.wicket.util.file.IResourceFinder;
 import org.apache.wicket.util.string.Strings;
 import org.junit.Test;
 
 
 /**
- * ResourceStreamLocator test. Tests construction of resource names with 
+ * ResourceStreamLocator test. Tests construction of resource names with
  * 
  * @author Juergen Donnerstag
  */
@@ -63,7 +64,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase
         * @param locale
         * @param extension
         */
-       public void createAndTestResource(Path sourcePath, String style, String 
variation,
+       public void createAndTestResource(IResourceFinder sourcePath, String 
style, String variation,
                Locale locale, String extension)
        {
                IResourceStreamLocator locator = new 
ResourceStreamLocator(sourcePath);
@@ -77,7 +78,7 @@ public class ResourceStreamLocatorTest extends WicketTestCase
         * 
         * @param sourcePath
         */
-       public void executeMultiple(Path sourcePath)
+       public void executeMultiple(IResourceFinder sourcePath)
        {
                createAndTestResource(sourcePath, null, null, null, "");
                createAndTestResource(sourcePath, "style", null, null, 
"_style");
@@ -114,7 +115,7 @@ public class ResourceStreamLocatorTest extends 
WicketTestCase
        public void locateInClasspath()
        {
                // Execute without source path
-               executeMultiple(new Path());
+               executeMultiple(new ClassPathResourceFinder(""));
 
                // Determine source path
                IResourceStreamLocator locator = new ResourceStreamLocator();

Reply via email to