[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1301) Bugs with MockServletContext.getResourcePaths()
Pete Muir (JIRA)
jira-events at lists.jboss.org
Sun Jun 10 19:01:11 EDT 2007
[ http://jira.jboss.com/jira/browse/JBSEAM-1301?page=comments#action_12364816 ]
Pete Muir commented on JBSEAM-1301:
-----------------------------------
Mike, you can flesh out Mock* as you like - many of the methods don't do anything ;)
> 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.ALPHA
>
>
> 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;
> try
> {
> 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()) {
> result.add(filePath+"/");
> } else {
> result.add(filePath);
> }
> }
> }
--
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