[jboss-cvs] JBossAS SVN: r57439 - in projects/microcontainer/trunk: container/src/main/org/jboss/virtual/plugins/context/jar deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar deployers/src/tests/org/jboss/test/deployers/structure/file/test deployers/src/tests/org/jboss/test/deployers/structure/jar/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 5 07:18:26 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-10-05 07:18:18 -0400 (Thu, 05 Oct 2006)
New Revision: 57439
Added:
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/ConfiguredSuffixFileStructureUnitTestCase.java
projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarUtils.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
Log:
Make set of suffixes recognised by FileStructure and JARStructure configurable properties
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarUtils.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarUtils.java 2006-10-05 10:20:16 UTC (rev 57438)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarUtils.java 2006-10-05 11:18:18 UTC (rev 57439)
@@ -77,8 +77,27 @@
throw new IllegalArgumentException("Null suffix");
return jarSuffixes.remove(suffix);
}
+
+ /**
+ * Get the lis of jar suffixes
+ *
+ * @return the list of suffixes
+ */
+ public static Set<String> getSuffixes()
+ {
+ return jarSuffixes;
+ }
/**
+ * Clear the list of suffixes
+ *
+ */
+ public static void clearSuffixes()
+ {
+ jarSuffixes.clear();
+ }
+
+ /**
* Utilities
*/
private JarUtils()
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java 2006-10-05 10:20:16 UTC (rev 57438)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/file/FileStructure.java 2006-10-05 11:18:18 UTC (rev 57439)
@@ -48,6 +48,34 @@
}
/**
+ * Set the list of suffixes that are recognised as jars
+ *
+ * @param suffixes A list of suffixes, e.g. {".jar", ".ear"}
+ */
+ public void setSuffixes(Set<String> suffixes)
+ {
+ if (suffixes != null)
+ {
+ fileSuffixes.clear();
+ for (String suffix : suffixes)
+ {
+ addFileSuffix(suffix);
+ }
+ }
+ }
+
+ /**
+ * Gets the list of suffixes recognised as jars
+ *
+ * @return the list of suffixes
+ */
+ public Set<String> getSuffixes()
+ {
+ return fileSuffixes;
+ }
+
+
+ /**
* Add a file suffix
*
* @param suffix the suffix
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java 2006-10-05 10:20:16 UTC (rev 57438)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java 2006-10-05 11:18:18 UTC (rev 57439)
@@ -24,11 +24,13 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
/**
* JARStructure.
@@ -38,6 +40,34 @@
*/
public class JARStructure extends AbstractStructureDeployer
{
+ /**
+ * Set the list of suffixes that are recognised as jars
+ *
+ * @param suffixes A list of suffixes, e.g. {".jar", ".ear"}
+ */
+ public void setSuffixes(Set<String> suffixes)
+ {
+ if (suffixes != null)
+ {
+ JarUtils.clearSuffixes();
+ for (String suffix : suffixes)
+ {
+ JarUtils.addJarSuffix(suffix);
+ }
+ }
+ }
+
+ /**
+ * Gets the list of suffixes recognised as jars
+ *
+ * @return the list of suffixes
+ */
+ public Set<String> getSuffixes()
+ {
+ return JarUtils.getSuffixes();
+ }
+
+
@Override
public int getRelativeOrder()
{
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/ConfiguredSuffixFileStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/ConfiguredSuffixFileStructureUnitTestCase.java 2006-10-05 10:20:16 UTC (rev 57438)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/file/test/ConfiguredSuffixFileStructureUnitTestCase.java 2006-10-05 11:18:18 UTC (rev 57439)
@@ -0,0 +1,102 @@
+/*
+* 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.deployers.structure.file.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * FileStructureUnitTestCase.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfiguredSuffixFileStructureUnitTestCase extends BaseTestCase
+{
+ /** The file structure deployer */
+ Set<String> defaultSuffixes = new FileStructure().getSuffixes();
+
+ public static Test suite()
+ {
+ return new TestSuite(ConfiguredSuffixFileStructureUnitTestCase.class);
+ }
+
+ public ConfiguredSuffixFileStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ enableTrace("org.jboss.deployers");
+ }
+
+ public void testDefaults() throws Exception
+ {
+ assertNotNull("default suffixes should not be null", defaultSuffixes);
+ assertTrue("default suffixes size should be > 0", defaultSuffixes.size() > 0);
+ }
+
+ public void testOverwriteDefaults() throws Exception
+ {
+ FileStructure structure = new FileStructure();
+
+ Set<String> suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(defaultSuffixes.size(), suffixes.size());
+
+ Set<String> newSuffixes = new HashSet<String>();
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertTrue(suffixes.isEmpty());
+
+ newSuffixes = new HashSet<String>();
+ newSuffixes.add(".txt");
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(1, suffixes.size());
+ assertTrue(suffixes.contains(".txt"));
+
+ newSuffixes = new HashSet<String>();
+ newSuffixes.add("-ds.xml");
+ newSuffixes.add("-dd.xml");
+ newSuffixes.add("-service.xml");
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(3, suffixes.size());
+ assertTrue(suffixes.contains("-ds.xml"));
+ assertTrue(suffixes.contains("-dd.xml"));
+ assertTrue(suffixes.contains("-service.xml"));
+ }
+
+}
Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java 2006-10-05 10:20:16 UTC (rev 57438)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java 2006-10-05 11:18:18 UTC (rev 57439)
@@ -0,0 +1,95 @@
+/*
+* 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.deployers.structure.jar.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.test.deployers.BaseDeployersTest;
+
+/**
+ * JARStructureUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfiguredSuffixJARStructureUnitTestCase extends BaseDeployersTest
+{
+ /** The file structure deployer */
+ Set<String> defaultSuffixes = new JARStructure().getSuffixes();
+
+ public static Test suite()
+ {
+ return new TestSuite(ConfiguredSuffixJARStructureUnitTestCase.class);
+ }
+
+ public ConfiguredSuffixJARStructureUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testDefaults() throws Exception
+ {
+ assertNotNull("default suffixes should not be null", defaultSuffixes);
+ assertTrue("default suffixes size should be > 0", defaultSuffixes.size() > 0);
+ }
+
+ public void testOverwriteDefaults() throws Exception
+ {
+ JARStructure structure = new JARStructure();
+
+ Set<String> suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(defaultSuffixes.size(), suffixes.size());
+
+ Set<String> newSuffixes = new HashSet<String>();
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertTrue(suffixes.isEmpty());
+
+ newSuffixes = new HashSet<String>();
+ newSuffixes.add(".jar");
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(1, suffixes.size());
+ assertTrue(suffixes.contains(".jar"));
+
+ newSuffixes = new HashSet<String>();
+ newSuffixes.add(".bar");
+ newSuffixes.add(".tar");
+ newSuffixes.add(".far");
+ structure.setSuffixes(newSuffixes);
+ suffixes = structure.getSuffixes();
+ assertNotNull(suffixes);
+ assertEquals(3, suffixes.size());
+ assertTrue(suffixes.contains(".bar"));
+ assertTrue(suffixes.contains(".tar"));
+ assertTrue(suffixes.contains(".bar"));
+ }
+
+}
More information about the jboss-cvs-commits
mailing list