[jboss-cvs] JBossAS SVN: r72330 - in projects/jboss-deployers/trunk: deployers-vfs/src/tests/org/jboss/test/deployers and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 17 05:28:53 EDT 2008


Author: alex.loubyansky at jboss.com
Date: 2008-04-17 05:28:53 -0400 (Thu, 17 Apr 2008)
New Revision: 72330

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/test/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/test/DeployersAltDDTestCase.java
Removed:
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java
Log:
JBDEPLOY-27 moved the fix to the AbstractVFSParsingDeployer and re-worked the testcase

Deleted: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.xml	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.xml	2008-04-17 09:28:53 UTC (rev 72330)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <jbossxb-parser xmlns="urn:jboss:deployers:2.0"
-         name="deployer"
-         metadata="org.jboss.test.deployers.vfs.xb.support.TestMetaData"
-         suffix="-other.xml"
-         register-with-jbossxb="true"
-    />
-
-</deployment>

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/test/DeployersAltDDTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/test/DeployersAltDDTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/altdd/test/DeployersAltDDTestCase.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -0,0 +1,189 @@
+/*
+* 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.altdd.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
+/**
+ * alt-dd tests.
+ *
+ * @author <a href="mailto:alex at jboss.com">Alexey Loubyansky</a>
+ */
+public class DeployersAltDDTestCase extends BaseTestCase
+{
+   public static Test suite()
+   {
+      return suite(DeployersAltDDTestCase.class);
+   }
+
+   public DeployersAltDDTestCase(String test)
+   {
+      super(test);
+   }
+
+   public void testAltDD() throws Exception
+   {
+      final VirtualFile altDD = getMockVF();
+      AbstractVFSDeploymentContext context = new AbstractVFSDeploymentContext();
+      DeploymentUnit unit = context.getDeploymentUnit();
+      unit.addAttachment(Object.class.getName() + ".altDD", altDD);
+
+      final boolean pickedUpAltDD[] = new boolean[1];
+      AbstractVFSParsingDeployer deployer = new AbstractVFSParsingDeployer<Object>(Object.class)
+      {
+         @Override
+         protected Object parse(VFSDeploymentUnit unit, VirtualFile file, Object root) throws Exception
+         {
+            if(file == altDD)
+               pickedUpAltDD[0] = true;
+            return null;
+         }
+
+         public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException
+         {
+         }
+      };
+      
+      deployer.setName("dd");
+      deployer.deploy(unit);
+      
+      assertTrue("Picked up alt-dd", pickedUpAltDD[0]);
+   }
+
+   private static VirtualFile getMockVF()
+   {
+      VirtualFile altDD = new VirtualFile(new VirtualFileHandler()
+      {
+         private static final long serialVersionUID = 1L;
+
+         public void close()
+         {
+         }
+
+         public boolean exists() throws IOException
+         {
+            return false;
+         }
+
+         public VirtualFileHandler getChild(String arg0) throws IOException
+         {
+            return null;
+         }
+
+         public List<VirtualFileHandler> getChildren(boolean arg0) throws IOException
+         {
+            return null;
+         }
+
+         public long getLastModified() throws IOException
+         {
+            return 0;
+         }
+
+         public String getName()
+         {
+            return null;
+         }
+
+         public VirtualFileHandler getParent() throws IOException
+         {
+            return null;
+         }
+
+         public String getPathName()
+         {
+            return null;
+         }
+
+         public long getSize() throws IOException
+         {
+            return 0;
+         }
+
+         public VFSContext getVFSContext()
+         {
+            return null;
+         }
+
+         public VirtualFile getVirtualFile()
+         {
+            return null;
+         }
+
+         public boolean hasBeenModified() throws IOException
+         {
+            return false;
+         }
+
+         public boolean isHidden() throws IOException
+         {
+            return false;
+         }
+
+         public boolean isLeaf() throws IOException
+         {
+            return false;
+         }
+
+         public InputStream openStream() throws IOException
+         {
+            return null;
+         }
+
+         public URI toURI() throws URISyntaxException
+         {
+            return null;
+         }
+
+         public URL toURL() throws MalformedURLException, URISyntaxException
+         {
+            return null;
+         }
+
+         public URL toVfsUrl() throws MalformedURLException, URISyntaxException
+         {
+            return null;
+         }
+      });
+      return altDD;
+   }
+}

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -58,25 +58,6 @@
 
    protected abstract String getName(T metadata);
 
-   protected void prepareDeploymentUnit(AbstractVFSDeploymentUnit unit)
-   {
-   }
-   
-   protected void setAltDD(AbstractVFSDeploymentUnit unit, String altDDName)
-   {
-      VirtualFile altDDFile = null;
-      try
-      {
-         altDDFile = unit.getRoot().getChild(altDDName);
-      }
-      catch (IOException e)
-      {
-         fail("Failed to locate altDD '" + altDDName + "' under " + unit.getRoot().getPathName());
-      }
-      assertNotNull("altDD exists under " + unit.getRoot().getPathName() + ": " + altDDName, altDDFile);
-      unit.addAttachment(getOutput().getName() + ".altDD", altDDFile);
-   }
-   
    public void testJBossXBParser() throws Throwable
    {
       SchemaResolverDeployer<?> deployer = assertBean("deployer", SchemaResolverDeployer.class);
@@ -93,7 +74,6 @@
       VFSDeploymentContext context = new AbstractVFSDeploymentContext(file, "");
       context.setMetaDataLocations(Collections.singletonList(file));
       AbstractVFSDeploymentUnit unit = new AbstractVFSDeploymentUnit(context);
-      prepareDeploymentUnit(unit);
 
       deployer.deploy(unit);
       try

Deleted: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.java	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -1,69 +0,0 @@
-/*
-* 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.xb.test;
-
-import junit.framework.Test;
-
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.test.deployers.vfs.xb.support.TestMetaData;
-
-/**
- * Schema resolver deployer altDD testcase
- *
- * @author <a href="mailto:alex at jboss.com">Alexey Loubyansky</a>
- */
-public class SchemaResolverAltDDXBTestCase extends AbstractSchemaResolverXBTest<TestMetaData>
-{
-   public static Test suite()
-   {
-      return suite(SchemaResolverAltDDXBTestCase.class);
-   }
-
-   public SchemaResolverAltDDXBTestCase(String name)
-   {
-      super(name);
-   }
-
-   @Override
-   protected String getName(TestMetaData metadata)
-   {
-      return metadata.getName();
-   }
-
-   @Override
-   protected Class<TestMetaData> getOutput()
-   {
-      return TestMetaData.class;
-   }
-
-   @Override
-   protected String getSuffix()
-   {
-      return "-other.xml";
-   }
-   
-   @Override
-   protected void prepareDeploymentUnit(AbstractVFSDeploymentUnit unit)
-   {
-      setAltDD(unit, "MyMetaData-foobar.xml");
-   }
-}

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -116,9 +116,13 @@
       // Try to find the metadata
       VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
 
-      VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name);
-      if (file == null)
-         return null;
+      VirtualFile file = (VirtualFile) unit.getAttachment(getOutput().getName() + ".altDD");
+      if(file == null)
+      {
+         file = vfsDeploymentUnit.getMetaDataFile(name);
+         if (file == null)
+            return null;
+      }
       
       T result = parse(vfsDeploymentUnit, file, root);
       if (result != null)
@@ -173,7 +177,9 @@
       }
       else
       {
-         VirtualFile file = files.get(0);
+         VirtualFile file = (VirtualFile) unit.getAttachment(getOutput().getName() + ".altDD");
+         if(file == null)
+            file = files.get(0);
 
          T result = parse(vfsDeploymentUnit, file, root);
          if (result != null)

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -109,6 +109,8 @@
       if (file == null)
          throw new IllegalArgumentException("Null file");
 
+      log.debug("Parsing file: "+file+" for deploymentType: " + getOutput());
+
       Unmarshaller unmarshaller = factory.newUnmarshaller();
       unmarshaller.setSchemaValidation(isUseSchemaValidation());
       unmarshaller.setValidation(isUseValidation());

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java	2008-04-17 08:09:37 UTC (rev 72329)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java	2008-04-17 09:28:53 UTC (rev 72330)
@@ -195,11 +195,6 @@
    {
       if (file == null)
          throw new IllegalArgumentException("Null file");
-
-      VirtualFile altDD = (VirtualFile) unit.getAttachment(getOutput().getName() + ".altDD");
-      if(altDD != null)
-         file = altDD;
-
       return parse(file);
    }
 




More information about the jboss-cvs-commits mailing list