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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 14 10:41:44 EDT 2008


Author: alex.loubyansky at jboss.com
Date: 2008-04-14 10:41:44 -0400 (Mon, 14 Apr 2008)
New Revision: 72181

Added:
   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/SchemaResolverDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java
Log:
JBDEPLOY-27

Added: 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	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.xml	2008-04-14 14:41:44 UTC (rev 72181)
@@ -0,0 +1,12 @@
+<?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>

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-14 14:30:52 UTC (rev 72180)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java	2008-04-14 14:41:44 UTC (rev 72181)
@@ -21,6 +21,7 @@
 */
 package org.jboss.test.deployers.vfs.xb.test;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.Collections;
 
@@ -57,6 +58,25 @@
 
    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);
@@ -73,6 +93,7 @@
       VFSDeploymentContext context = new AbstractVFSDeploymentContext(file, "");
       context.setMetaDataLocations(Collections.singletonList(file));
       AbstractVFSDeploymentUnit unit = new AbstractVFSDeploymentUnit(context);
+      prepareDeploymentUnit(unit);
 
       deployer.deploy(unit);
       try

Added: 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	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverAltDDXBTestCase.java	2008-04-14 14:41:44 UTC (rev 72181)
@@ -0,0 +1,69 @@
+/*
+* 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/SchemaResolverDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java	2008-04-14 14:30:52 UTC (rev 72180)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java	2008-04-14 14:41:44 UTC (rev 72181)
@@ -196,6 +196,10 @@
       if (file == null)
          throw new IllegalArgumentException("Null file");
 
+      VirtualFile altDD = (VirtualFile) unit.getAttachment(getOutput().getName() + ".altDD");
+      if(altDD != null)
+         file = altDD;
+
       log.debug("Parsing file: "+file+" for deploymentType: " + getOutput());
       Unmarshaller unmarshaller = factory.newUnmarshaller();
       unmarshaller.setSchemaValidation(isUseSchemaValidation());




More information about the jboss-cvs-commits mailing list