[jboss-cvs] JBossAS SVN: r57459 - in projects/microcontainer/trunk/container/src: resources/tests/vfs/test resources/tests/vfs/test/unpacked-with-metadata.jar resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF resources/tests/vfs/test/unpacked-with-metadata.jar/org resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/support tests/org/jboss/test/virtual/support tests/org/jboss/test/virtual/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 5 19:20:49 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-10-05 19:20:43 -0400 (Thu, 05 Oct 2006)
New Revision: 57459
Added:
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF/some-data.xml
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/support/
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/support/CommonClass.class
projects/microcontainer/trunk/container/src/resources/tests/vfs/test/with-metadata.jar
projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/support/MetaDataMatchFilter.java
Modified:
projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
Log:
Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF/some-data.xml
===================================================================
--- projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF/some-data.xml 2006-10-05 22:59:15 UTC (rev 57458)
+++ projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/META-INF/some-data.xml 2006-10-05 23:20:43 UTC (rev 57459)
@@ -0,0 +1,3 @@
+<meta>
+ <entry/>
+</meta>
\ No newline at end of file
Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/support/CommonClass.class
===================================================================
(Binary files differ)
Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-with-metadata.jar/org/jboss/test/vfs/support/CommonClass.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/with-metadata.jar
===================================================================
(Binary files differ)
Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/with-metadata.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/support/MetaDataMatchFilter.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/support/MetaDataMatchFilter.java 2006-10-05 22:59:15 UTC (rev 57458)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/support/MetaDataMatchFilter.java 2006-10-05 23:20:43 UTC (rev 57459)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.support;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * Copy of org.jboss.deployers.plugins.structure.MetaDataMatchFilter for FileVFSUnitTestCase.testGetMetaDataPackedJar()
+ *
+ * @author adrian at jboss.org
+ * @version $Revision: 44223 $
+ */
+public class MetaDataMatchFilter implements VirtualFileFilterWithAttributes
+{
+ /** The name */
+ private String name;
+
+ /** The suffix */
+ private String suffix;
+
+ /** The attributes */
+ private VisitorAttributes attributes;
+
+ /**
+ * Create a new MetaDataMatchFilter.
+ * using {@link VisitorAttributes#LEAVES_ONLY}
+ *
+ * @param name the name to exactly match
+ * @param suffix the suffix to partially match
+ * @throws IllegalArgumentException if both the name and suffix are null
+ */
+ public MetaDataMatchFilter(String name, String suffix)
+ {
+ this(name, suffix, null);
+ }
+
+ /**
+ * Create a new MetaDataMatchFilter.
+ *
+ * @param name the name to exactly match
+ * @param suffix the suffix to partially match
+ * @param attributes the attributes, pass null to use {@link VisitorAttributes#LEAVES_ONLY}
+ * @throws IllegalArgumentException if both the name and suffix are null
+ */
+ public MetaDataMatchFilter(String name, String suffix, VisitorAttributes attributes)
+ {
+ if (name == null && suffix == null)
+ throw new IllegalArgumentException("Null name and suffix");
+ this.name = name;
+ this.suffix = suffix;
+ if (attributes == null)
+ attributes = VisitorAttributes.LEAVES_ONLY;
+ this.attributes = attributes;
+ }
+
+ public VisitorAttributes getAttributes()
+ {
+ return attributes;
+ }
+
+ public boolean accepts(VirtualFile file)
+ {
+ String fileName = file.getName();
+ if (name != null && fileName.equals(name))
+ return true;
+ if (suffix != null)
+ return fileName.endsWith(suffix);
+ return false;
+ }
+}
Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java 2006-10-05 22:59:15 UTC (rev 57458)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java 2006-10-05 23:20:43 UTC (rev 57459)
@@ -28,6 +28,7 @@
import junit.framework.TestSuite;
import org.jboss.test.BaseTestCase;
+import org.jboss.test.virtual.support.MetaDataMatchFilter;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
@@ -629,4 +630,40 @@
VirtualFile jar1 = outerJar.findChild("jar1.jar");
assertEquals(jar1URL, jar1.toURL());
}
+
+ /**
+ * Tests that we can find the META-INF/some-data.xml in an unpacked deployment
+ */
+ public void testGetMetaDataUnpackedJar() throws Exception
+ {
+ testGetMetaDataFromJar("unpacked-with-metadata.jar");
+ }
+
+ /**
+ * Tests that we can find the META-INF/some-data.xml in a packed deployment
+ */
+ public void testGetMetaDataPackedJar() throws Exception
+ {
+ testGetMetaDataFromJar("with-metadata.jar");
+ }
+
+ private void testGetMetaDataFromJar(String name) throws Exception
+ {
+ URL rootURL = getResource("/vfs/test");
+ VFS vfs = VFS.getVFS(rootURL);
+
+ VirtualFile jar = vfs.findChild(name);
+ assertNotNull(jar);
+ VirtualFile metadataLocation = jar.findChild("META-INF");
+ assertNotNull(metadataLocation);
+
+ VirtualFile metadataByName = metadataLocation.findChild("some-data.xml");
+ assertNotNull(metadataByName);
+
+ //This is the same code as is called by AbstractDeploymentContext.getMetaDataFiles(String name, String suffix).
+ //The MetaDataMatchFilter is a copy of the one used there
+ List<VirtualFile> metaDataList = metadataLocation.getChildren(new MetaDataMatchFilter(null, "-data.xml"));
+ assertNotNull(metaDataList);
+ assertEquals("Wrong size", 1, metaDataList.size());
+ }
}
More information about the jboss-cvs-commits
mailing list