[jboss-cvs] JBossAS SVN: r108775 - in projects/jboss-deployers/trunk/deployers-vfs/src/test: java/org/jboss/test/deployers/vfs/classloader/support and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 21 18:53:39 EDT 2010


Author: alesj
Date: 2010-10-21 18:53:38 -0400 (Thu, 21 Oct 2010)
New Revision: 108775

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/CheckResource.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/ExtCLPathDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/conf/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/conf/jboss.properties
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/META-INF/jboss-beans.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/META-INF/jboss-beans.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.xml
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
Log:
Test resource lookup.


Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java	2010-10-21 22:33:23 UTC (rev 108774)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java	2010-10-21 22:53:38 UTC (rev 108775)
@@ -59,6 +59,7 @@
       suite.addTest(ManifestClassLoaderUnitTestCase.suite());
       suite.addTest(IntegrationDeployerUnitTestCase.suite());
       suite.addTest(RequirementsIntegrationUnitTestCase.suite());
+      suite.addTest(ResourcesUnitTestCase.suite());
 
       return suite;
    }

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/CheckResource.java (from rev 104761, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TryTouch.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/CheckResource.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/CheckResource.java	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1,43 @@
+/*
+* 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.vfs.classloader.support;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CheckResource
+{
+   public void start() throws Throwable
+   {
+      ClassLoader cl = getClass().getClassLoader();
+      URL url1 = cl.getResource("conf/jboss.properties");
+      if (url1 == null)
+         throw new IllegalArgumentException("Null -- conf/jboss.properties");
+      System.out.println("url1 = " + url1);
+      URL url2 = cl.getResource("jboss.properties");
+      if (url2 == null)
+         throw new IllegalArgumentException("Null -- jboss.properties");
+      System.out.println("url2 = " + url2);
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/ExtCLPathDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/ExtCLPathDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/ExtCLPathDeployer.java	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.vfs.classloader.support;
+
+import java.net.URL;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.MatchAllVirtualFileFilter;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+ at SuppressWarnings({"deprecation"})
+public class ExtCLPathDeployer extends AbstractVFSRealDeployer
+{
+   public ExtCLPathDeployer()
+   {
+      setStage(DeploymentStages.POST_PARSE);
+   }
+
+   public void deploy(VFSDeploymentUnit unit) throws DeploymentException
+   {
+      try
+      {
+         URL resource = getClass().getResource("/classloader/resources");
+         VirtualFile root = VFS.getChild(resource);
+         unit.appendClassPath(root.getChildren(MatchAllVirtualFileFilter.INSTANCE));
+         VirtualFile app = root.getChild("app");
+         unit.appendClassPath(app.getChildren(MatchAllVirtualFileFilter.INSTANCE));
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error", e);
+      }
+   }
+}

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.java (from rev 104761, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.java	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1,70 @@
+/*
+* 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.vfs.classloader.test;
+
+import java.io.IOException;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.deployers.vfs.classloader.support.CheckResource;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import junit.framework.Test;
+
+/**
+ * ResourcesUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ResourcesUnitTestCase extends BootstrapDeployersTest
+{
+   public ResourcesUnitTestCase(String name) throws IOException
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ResourcesUnitTestCase.class);
+   }
+
+   public void testDelegation() throws Exception
+   {
+      VirtualFile root = createDeploymentRoot("/classloader/resources", "test.jar");
+      DeploymentUnit unit = assertDeploy(root);
+      try
+      {
+         VirtualFile jarFile = VFS.getChild(getName()).getChild("check.jar");
+         createAssembledDirectory(jarFile)
+            .addPackage(CheckResource.class)
+            .addPath("META-INF", "/classloader/resources/check/META-INF");
+
+         DeploymentUnit check = assertDeploy(jarFile);
+         undeploy(check);
+      }
+      finally
+      {
+         undeploy(unit);
+      }
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/conf/jboss.properties
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/conf/jboss.properties	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/app/conf/jboss.properties	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1 @@
+org=jboss

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/META-INF/jboss-beans.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/check/META-INF/jboss-beans.xml	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1,3 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="CR" class="org.jboss.test.deployers.vfs.classloader.support.CheckResource"/>
+</deployment>

Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/META-INF/jboss-beans.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/classloader/resources/test.jar/META-INF/jboss-beans.xml	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0"/>

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.xml (from rev 104761, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classloader/test/IntegrationDeployerUnitTestCase.xml)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classloader/test/ResourcesUnitTestCase.xml	2010-10-21 22:53:38 UTC (rev 108775)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="ExtCLPathDeployer" class="org.jboss.test.deployers.vfs.classloader.support.ExtCLPathDeployer"/>
+
+</deployment>



More information about the jboss-cvs-commits mailing list