[jboss-cvs] JBossAS SVN: r74599 - in projects/vfs/trunk/src: test/java/org/jboss/test/virtual/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 16 05:52:37 EDT 2008
Author: alesj
Date: 2008-06-16 05:52:37 -0400 (Mon, 16 Jun 2008)
New Revision: 74599
Added:
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java
projects/vfs/trunk/src/test/resources/vfs/test/badmf.jar
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
Log:
[JBVFS-3]; Suppress exceptions in VFSUtils.addManifestLocations.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java 2008-06-16 09:46:50 UTC (rev 74598)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java 2008-06-16 09:52:37 UTC (rev 74599)
@@ -158,7 +158,10 @@
VirtualFile parent = file.getParent();
if (parent == null)
- throw new IllegalStateException(file + " has no parent.");
+ {
+ log.debug(file + " has no parent.");
+ return;
+ }
URL parentURL;
URL vfsRootURL;
@@ -171,25 +174,27 @@
}
catch(URISyntaxException e)
{
- IOException ioe = new IOException("Failed to get parent URL for " + file);
- ioe.initCause(e);
- throw ioe;
+ log.debug("Failed to get parent URL for " + file + ", reason=" + e);
+ return;
}
+ String parentPath = parentURL.toString();
+ if(parentPath.endsWith("/") == false)
+ parentPath += "/";
+
StringTokenizer tokenizer = new StringTokenizer(classPath);
while (tokenizer.hasMoreTokens())
{
String path = tokenizer.nextToken();
try
{
- String parentPath = parentURL.toString();
- if(parentPath.endsWith("/") == false)
- parentPath += "/";
URL libURL = new URL(parentPath + path);
String libPath = libURL.getPath();
- // TODO, this occurs for inner jars. Doubtful that such a mf cp is valid
- if( rootPathLength > libPath.length() )
- throw new IOException("Invalid rootPath: "+vfsRootURL+", libPath: "+libPath);
+ if(rootPathLength > libPath.length())
+ {
+ log.debug("Invalid rootPath: " + vfsRootURL + ", libPath: " + libPath);
+ continue;
+ }
String vfsLibPath = libPath.substring(rootPathLength);
VirtualFile vf = file.getVFS().getChild(vfsLibPath);
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java 2008-06-16 09:46:50 UTC (rev 74598)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java 2008-06-16 09:52:37 UTC (rev 74599)
@@ -81,6 +81,8 @@
suite.addTest(TempTestCase.suite());
// visitor
suite.addTest(VisitorUnitTestCase.suite());
+ // utils
+ suite.addTest(VFSUtilTestCase.suite());
return suite;
}
Copied: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java (from rev 74595, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java)
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java 2008-06-16 09:52:37 UTC (rev 74599)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.virtual.test;
+
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * VFSUtilTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSUtilTestCase extends AbstractMockVFSTest
+{
+ public VFSUtilTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(VFSUtilTestCase.class);
+ }
+
+ public void testAddManifestLocations() throws Throwable
+ {
+ URL url = getResource("/vfs/test");
+ VirtualFile root = VFS.getRoot(url);
+ VirtualFile file = root.getChild("badmf.jar");
+ assertNotNull(file);
+ List<VirtualFile> paths = new ArrayList<VirtualFile>();
+ VFSUtils.addManifestLocations(file, paths);
+ assertEquals(3, paths.size());
+ }
+}
\ No newline at end of file
Added: projects/vfs/trunk/src/test/resources/vfs/test/badmf.jar
===================================================================
(Binary files differ)
Property changes on: projects/vfs/trunk/src/test/resources/vfs/test/badmf.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the jboss-cvs-commits
mailing list