Author: markt Date: Thu Sep 13 18:11:27 2012 New Revision: 1384449 URL: http://svn.apache.org/viewvc?rev=1384449&view=rev Log: Add some initial unit tests for the directory based WebResourceSet implementation.
Added: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResource.java - copied, changed from r1384119, tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/ResourceBase.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java (with props) tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/ tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java (with props) tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java (with props) tomcat/sandbox/trunk-resources/test/webresources/ tomcat/sandbox/trunk-resources/test/webresources/d1/ tomcat/sandbox/trunk-resources/test/webresources/d1/d1-f1.txt (with props) tomcat/sandbox/trunk-resources/test/webresources/d2/ tomcat/sandbox/trunk-resources/test/webresources/d2/d2-f1.txt (with props) tomcat/sandbox/trunk-resources/test/webresources/f1.txt (with props) tomcat/sandbox/trunk-resources/test/webresources/f2.txt (with props) Removed: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/ResourceBase.java Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceSet.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/ApplicationContext.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResource.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/LocalStrings.properties tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResource.java Thu Sep 13 18:11:27 2012 @@ -76,7 +76,8 @@ public interface WebResource { boolean canRead(); /** - * The path of this resource relative to the web application root. + * The path of this resource relative to the web application root. If the + * resource is a directory, the return value will end in '/'. */ String getWebappPath(); Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java Thu Sep 13 18:11:27 2012 @@ -126,13 +126,14 @@ public interface WebResourceRoot extends /** * Obtain the Set of the web applications pathnames of all of the files and - * directories located in the specified directory. + * directories located in the specified directory. Paths representing + * directories will end with a "/" character. * * @param path The path for the resource of interest relative to the root * of the web application. It must start with '/'. * * @return The Set of resources. If path does not refer to a directory - * then an empty set will be returned. + * then null will be returned. */ Set<String> listWebAppPaths(String path); Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceSet.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceSet.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceSet.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceSet.java Thu Sep 13 18:11:27 2012 @@ -49,7 +49,8 @@ public interface WebResourceSet { /** * Obtain the Set of the web applications pathnames of all of the files and - * directories located in the specified directory. + * directories located in the specified directory. Paths representing + * directories will end with a "/" character. * * @param path The path for the resource of interest relative to the root * of the web application. It must start with '/'. Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/ApplicationContext.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/ApplicationContext.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/ApplicationContext.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/ApplicationContext.java Thu Sep 13 18:11:27 2012 @@ -555,7 +555,8 @@ public class ApplicationContext /** * Return a Set containing the resource paths of resources member of the * specified collection. Each path will be a String starting with - * a "/" character. The returned set is immutable. + * a "/" character. Paths representing directories will end with a "/" + * character. The returned set is immutable. * * @param path Collection path */ Copied: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResource.java (from r1384119, tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/ResourceBase.java) URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResource.java?p2=tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResource.java&p1=tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/ResourceBase.java&r1=1384119&r2=1384449&rev=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/ResourceBase.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResource.java Thu Sep 13 18:11:27 2012 @@ -26,7 +26,7 @@ import org.apache.catalina.util.Concurre import org.apache.juli.logging.Log; import org.apache.tomcat.util.res.StringManager; -public abstract class ResourceBase implements WebResource { +public abstract class AbstractResource implements WebResource { protected static final StringManager sm = StringManager.getManager(Constants.Package); @@ -38,7 +38,7 @@ public abstract class ResourceBase imple private volatile String weakETag; - protected ResourceBase(WebResourceRoot root, String webAppPath) { + protected AbstractResource(WebResourceRoot root, String webAppPath) { this.root = root; this.webAppPath = webAppPath; } @@ -100,7 +100,7 @@ public abstract class ResourceBase imple if (len > Integer.MAX_VALUE) { // Can't create an array that big throw new ArrayIndexOutOfBoundsException(sm.getString( - "resourceBase.getContentTooLarge", getWebappPath(), + "abstractResource.getContentTooLarge", getWebappPath(), Long.valueOf(len))); } @@ -124,7 +124,7 @@ public abstract class ResourceBase imple } } catch (IOException ioe) { if (getLog().isDebugEnabled()) { - getLog().debug(sm.getString("resourceBase.getContentFail", + getLog().debug(sm.getString("abstractResource.getContentFail", getWebappPath()), ioe); } } Added: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java?rev=1384449&view=auto ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java (added) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java Thu Sep 13 18:11:27 2012 @@ -0,0 +1,33 @@ +/* + * 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.catalina.webresources; + +import org.apache.catalina.WebResourceSet; +import org.apache.tomcat.util.res.StringManager; + +public abstract class AbstractResourceSet implements WebResourceSet { + + protected static final StringManager sm = + StringManager.getManager(Constants.Package); + + + protected final void checkPath(String path) { + if (path == null || path.length() == 0 || path.charAt(0) != '/') { + throw new IllegalArgumentException(); + } + } +} Propchange: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/AbstractResourceSet.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/DirResourceSet.java Thu Sep 13 18:11:27 2012 @@ -25,14 +25,13 @@ import java.util.Set; import org.apache.catalina.WebResource; import org.apache.catalina.WebResourceRoot; import org.apache.catalina.WebResourceRoot.ResourceSetType; -import org.apache.catalina.WebResourceSet; import org.apache.catalina.util.IOTools; import org.apache.catalina.util.ResourceSet; /** * Represents a {@link WebResourceSet} based on a directory. */ -public class DirResourceSet implements WebResourceSet { +public class DirResourceSet extends AbstractResourceSet { private static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -79,8 +78,12 @@ public class DirResourceSet implements W @Override public WebResource getResource(String path) { + checkPath(path); if (path.startsWith(webAppMount)) { File f = new File(base, path.substring(webAppMount.length())); + if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { + path = path += '/'; + } return new FileResource(root, f, path); } else { return new EmptyResource(root, path); @@ -89,6 +92,7 @@ public class DirResourceSet implements W @Override public String[] list(String path) { + checkPath(path); if (path.startsWith(webAppMount)) { File f = new File(base, path.substring(webAppMount.length())); String[] result = f.list(); @@ -104,17 +108,22 @@ public class DirResourceSet implements W @Override public Set<String> listWebAppPaths(String path) { + checkPath(path); ResourceSet<String> result = new ResourceSet<>(); if (path.startsWith(webAppMount)) { File f = new File(base, path.substring(webAppMount.length())); - String[] list = f.list(); + File[] list = f.listFiles(); if (list != null) { - for (String entry : list) { - if (path.charAt(path.length() - 1) == '/') { - result.add(path + entry); - } else { - result.add(path + "/" + entry); + for (File entry : list) { + StringBuilder sb = new StringBuilder(path); + if (path.charAt(path.length() - 1) != '/') { + sb.append('/'); + } + sb.append(entry.getName()); + if (entry.isDirectory()) { + sb.append('/'); } + result.add(sb.toString()); } } } @@ -124,6 +133,7 @@ public class DirResourceSet implements W @Override public boolean mkdir(String path) { + checkPath(path); if (path.startsWith(webAppMount)) { File f = new File(base, path.substring(webAppMount.length())); return f.mkdir(); Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/FileResource.java Thu Sep 13 18:11:27 2012 @@ -30,7 +30,7 @@ import org.apache.catalina.WebResourceRo import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -public class FileResource extends ResourceBase { +public class FileResource extends AbstractResource { private static final Log log = LogFactory.getLog(FileResource.class); Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResource.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResource.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResource.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResource.java Thu Sep 13 18:11:27 2012 @@ -27,7 +27,7 @@ import org.apache.catalina.WebResourceRo import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -public class JarResource extends ResourceBase { +public class JarResource extends AbstractResource { private static final Log log = LogFactory.getLog(JarResource.class); Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java Thu Sep 13 18:11:27 2012 @@ -28,13 +28,12 @@ import java.util.jar.JarFile; import org.apache.catalina.WebResource; import org.apache.catalina.WebResourceRoot; -import org.apache.catalina.WebResourceSet; import org.apache.catalina.util.ResourceSet; /** * Represents a {@link WebResourceSet} based on a JAR file. */ -public class JarResourceSet implements WebResourceSet { +public class JarResourceSet extends AbstractResourceSet { private final WebResourceRoot root; private final JarFile base; Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/LocalStrings.properties?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/LocalStrings.properties (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/LocalStrings.properties Thu Sep 13 18:11:27 2012 @@ -20,5 +20,5 @@ fileResource.getUrlFail=Unable to determ jarResource.getInputStreamFail=Unable to obtain an InputStream for the resource [{0}] located in the JAR [{1}] jarResource.getUrlFail=Unable to determine a URL for the resource [{0}] located in the JAR [{1}] -resourceBase.getContentFail=Unable to return [{0}] as a byte array -resourceBase.getContentTooLarge=Unable to return [{0}] as a byte array since the resource is [{1}] bytes in size which is larger than the maximum size of a byte array \ No newline at end of file +abstractResource.getContentFail=Unable to return [{0}] as a byte array +abstractResource.getContentTooLarge=Unable to return [{0}] as a byte array since the resource is [{1}] bytes in size which is larger than the maximum size of a byte array \ No newline at end of file Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1384449&r1=1384448&r2=1384449&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java Thu Sep 13 18:11:27 2012 @@ -89,6 +89,9 @@ public class StandardRoot extends Lifecy result.addAll(webResourceSet.listWebAppPaths(path)); } } + if (result.size() == 0) { + return null; + } return result; } Added: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java?rev=1384449&view=auto ============================================================================== --- tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java (added) +++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java Thu Sep 13 18:11:27 2012 @@ -0,0 +1,226 @@ +/* + * 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.catalina.webresources; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import org.apache.catalina.WebResource; + +public class TestDirResourceSet { + + private DirResourceSet dirResourceSet; + + @Before + public void setup() { + File f = new File("test/webresources"); + dirResourceSet = new DirResourceSet( + new TesterWebResourceRoot(), f, "", ""); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetResourceEmpty() { + dirResourceSet.getResource(""); + } + + @Test + public void testGetResourceRoot() { + WebResource webResource = dirResourceSet.getResource("/"); + Assert.assertTrue(webResource.isDirectory()); + Assert.assertEquals("", webResource.getName()); + Assert.assertEquals("/", webResource.getWebappPath()); + } + + @Test + public void testGetResourceDirA() { + WebResource webResource = dirResourceSet.getResource("/d1"); + Assert.assertTrue(webResource.isDirectory()); + Assert.assertEquals("d1", webResource.getName()); + Assert.assertEquals("/d1/", webResource.getWebappPath()); + } + + @Test + public void testGetResourceDirB() { + WebResource webResource = dirResourceSet.getResource("/d1/"); + Assert.assertTrue(webResource.isDirectory()); + Assert.assertEquals("d1", webResource.getName()); + Assert.assertEquals("/d1/", webResource.getWebappPath()); + } + + @Test + public void testGetResourceFile() { + WebResource webResource = dirResourceSet.getResource("/d1/d1-f1.txt"); + Assert.assertTrue(webResource.isFile()); + Assert.assertEquals("d1-f1.txt", webResource.getName()); + Assert.assertEquals("/d1/d1-f1.txt", webResource.getWebappPath()); + } + + @Test(expected = IllegalArgumentException.class) + public void testListEmpty() { + dirResourceSet.list(""); + } + + @Test + public void testListRoot() { + String[] results = dirResourceSet.list("/"); + + Set<String> expected = new HashSet<>(); + expected.add("d1"); + expected.add("d2"); + expected.add("f1.txt"); + expected.add("f2.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListDirA() { + String[] results = dirResourceSet.list("/d1"); + + Set<String> expected = new HashSet<>(); + expected.add("d1-f1.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListDirB() { + String[] results = dirResourceSet.list("/d1/"); + + Set<String> expected = new HashSet<>(); + expected.add("d1-f1.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListFile() { + String[] results = dirResourceSet.list("/d1/d1-f1.txt"); + + Assert.assertNotNull(results); + Assert.assertEquals(0, results.length); + } + + @Test(expected = IllegalArgumentException.class) + public void testListWebAppPathsEmpty() { + dirResourceSet.listWebAppPaths(""); + } + + @Test + public void testListWebAppPathsRoot() { + Set<String> results = dirResourceSet.listWebAppPaths("/"); + + Set<String> expected = new HashSet<>(); + expected.add("/d1/"); + expected.add("/d2/"); + expected.add("/f1.txt"); + expected.add("/f2.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListWebAppPathsDirA() { + Set<String> results = dirResourceSet.listWebAppPaths("/d1"); + + Set<String> expected = new HashSet<>(); + expected.add("/d1/d1-f1.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListWebAppPathsDirB() { + Set<String> results = dirResourceSet.listWebAppPaths("/d1/"); + + Set<String> expected = new HashSet<>(); + expected.add("/d1/d1-f1.txt"); + + for (String result : results) { + Assert.assertTrue(result, expected.remove(result)); + } + Assert.assertEquals(0, expected.size()); + } + + @Test + public void testListWebAppPathsFile() { + Set<String> results = dirResourceSet.listWebAppPaths("/d1/d1-f1.txt"); + + Assert.assertEquals(0, results.size()); + } + + @Test(expected = IllegalArgumentException.class) + public void testMkdirEmpty() { + dirResourceSet.mkdir(""); + } + + @Test + public void testMkdirRoot() { + Assert.assertFalse(dirResourceSet.mkdir("/")); + } + + @Test + public void testMkdirDirA() { + Assert.assertFalse(dirResourceSet.mkdir("/d1")); + } + + @Test + public void testMkdirDirB() { + Assert.assertFalse(dirResourceSet.mkdir("/d1/")); + } + + @Test + public void testMkdirFile() { + Assert.assertFalse(dirResourceSet.mkdir("/d1/d1-f1.txt")); + } + + @Test + public void testMkdirNew() { + Assert.assertTrue(dirResourceSet.mkdir("/new-test")); + + File file = new File("test/webresources/new-test"); + Assert.assertTrue(file.exists()); + Assert.assertTrue(file.delete()); + } + + /* TODO Implement this test + @Test + public void testWrite() { + Assert.fail("Not yet implemented"); + } + */ +} Propchange: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TestDirResourceSet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java?rev=1384449&view=auto ============================================================================== --- tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java (added) +++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java Thu Sep 13 18:11:27 2012 @@ -0,0 +1,141 @@ +/* + * 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.catalina.webresources; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.Set; + +import org.apache.catalina.LifecycleException; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.LifecycleState; +import org.apache.catalina.WebResource; +import org.apache.catalina.WebResourceRoot; + +/** + * Minimal implementation for use in unit tests. + */ +public class TesterWebResourceRoot implements WebResourceRoot { + + @Override + public void addLifecycleListener(LifecycleListener listener) { + // NO-OP + } + + @Override + public LifecycleListener[] findLifecycleListeners() { + return null; + } + + @Override + public void removeLifecycleListener(LifecycleListener listener) { + // NO-OP + } + + @Override + public void init() throws LifecycleException { + // NO-OP + } + + @Override + public void start() throws LifecycleException { + // NO-OP + } + + @Override + public void stop() throws LifecycleException { + // NO-OP + } + + @Override + public void destroy() throws LifecycleException { + // NO-OP + } + + @Override + public LifecycleState getState() { + return null; + } + + @Override + public String getStateName() { + return null; + } + + @Override + public WebResource getResource(String path) { + return null; + } + + @Override + public WebResource[] getResources(String path) { + return null; + } + + @Override + public String[] list(String path) { + return null; + } + + @Override + public Set<String> listWebAppPaths(String path) { + return null; + } + + @Override + public WebResource[] listResources(String path) { + return null; + } + + @Override + public boolean mkdir(String path) { + return false; + } + + @Override + public boolean write(String path, InputStream is) { + return false; + } + + @Override + public String getContextName() { + return null; + } + + @Override + public void createWebResourceSet(ResourceSetType type, URL url, + String webAppPath, String internalPath) { + // NO-OP + } + + @Override + public void createWebResourceSet(ResourceSetType type, File file, + String webAppMount, String internalPath) { + // NO-OP + } + + @Override + public boolean getAddWebinfClassesResources() { + return false; + } + + @Override + public void setAllowLinking(boolean allowLinking) { + // NO-OP + } +} Propchange: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/sandbox/trunk-resources/test/webresources/d1/d1-f1.txt URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/webresources/d1/d1-f1.txt?rev=1384449&view=auto ============================================================================== (empty) Propchange: tomcat/sandbox/trunk-resources/test/webresources/d1/d1-f1.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/sandbox/trunk-resources/test/webresources/d2/d2-f1.txt URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/webresources/d2/d2-f1.txt?rev=1384449&view=auto ============================================================================== (empty) Propchange: tomcat/sandbox/trunk-resources/test/webresources/d2/d2-f1.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/sandbox/trunk-resources/test/webresources/f1.txt URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/webresources/f1.txt?rev=1384449&view=auto ============================================================================== (empty) Propchange: tomcat/sandbox/trunk-resources/test/webresources/f1.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/sandbox/trunk-resources/test/webresources/f2.txt URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/webresources/f2.txt?rev=1384449&view=auto ============================================================================== (empty) Propchange: tomcat/sandbox/trunk-resources/test/webresources/f2.txt ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org