[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-1301) Bugs with MockServletContext.getResourcePaths()

Michael Youngstrom (JIRA) jira-events at lists.jboss.org
Mon May 7 11:26:52 EDT 2007

Bugs with MockServletContext.getResourcePaths()

                 Key: JBSEAM-1301
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1301
             Project: JBoss Seam
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.2.1.GA
            Reporter: Michael Youngstrom
         Assigned To: Michael Youngstrom
             Fix For: 1.3.0.BETA1

I've been doing some work with Seam integration testing lately and noticed getResourcePaths() wasn't working correctly.  It appeared to never return anything beyond the webroot.  So, I fixed that problem and enhanced getResourcePaths so that it could handle situations where a users directory structure may have multiple webroots  (e.g. one for test and main).  I changed from searching for webroot by looking for WEB-INF/web.xml files to only WEB-INF.

If nobody has any objections to my implementation I'll go ahead and commit this.

This is how I've rewritten getResourcePaths():

   public Set getResourcePaths(String name)
      Enumeration<URL> enumeration = null;
         enumeration = getClass().getClassLoader().getResources("WEB-INF");
      catch (IOException e)
         throw new RuntimeException("Error finding webroot.",e);
      Set<String> result = new HashSet<String>();
      while(enumeration.hasMoreElements()) {
         URL url = enumeration.nextElement();
         File rootFile = new File(url.getPath()).getParentFile();
         File newFile = new File(rootFile.getPath()+name);
         File[] files = newFile.listFiles();
         if(files != null) {
            addPaths( result, files, rootFile.getPath() );
      return result;

   private static void addPaths(Set<String> result, File[] files, String rootPath)
      for (File file: files)
          String filePath = file.getPath().substring( rootPath.length() ).replace('\\', '/');
         if(file.isDirectory()) {
         } else {

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list