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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 26 18:01:15 EDT 2008


Author: alesj
Date: 2008-03-26 18:01:14 -0400 (Wed, 26 Mar 2008)
New Revision: 71327

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-other.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/OtherMetaData.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/package-info.java
   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/SchemaResolverXBPackageTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/JBossXBDeployersTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.java
Log:
Test JBossXmlSchema on a package.

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-other.xml (from rev 71307, projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-foobar.xml)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-other.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-other.xml	2008-03-26 22:01:14 UTC (rev 71327)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss-other xmlns="urn:jboss:myother:1.0" name="mymetadata"/>

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.xml (from rev 71307, projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.xml)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.xml	2008-03-26 22:01:14 UTC (rev 71327)
@@ -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.other.OtherMetaData"
+         suffix="-other.xml"
+         register-with-jbossxb="true"
+    />
+
+</deployment>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/JBossXBDeployersTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/JBossXBDeployersTestSuite.java	2008-03-26 21:33:34 UTC (rev 71326)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/JBossXBDeployersTestSuite.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -25,6 +25,7 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 import org.jboss.test.deployers.vfs.xb.test.SchemaResolverXBTestCase;
+import org.jboss.test.deployers.vfs.xb.test.SchemaResolverXBPackageTestCase;
 
 /**
  * JBossXB deployers extensions.
@@ -43,6 +44,7 @@
       TestSuite suite = new TestSuite("JBossXB Deployers Tests");
 
       suite.addTest(SchemaResolverXBTestCase.suite());
+      suite.addTest(SchemaResolverXBPackageTestCase.suite());
 
       return suite;
    }

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/OtherMetaData.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/OtherMetaData.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/OtherMetaData.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -0,0 +1,46 @@
+/*
+* 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.support.other;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at XmlRootElement(name="jboss-other")
+public class OtherMetaData implements Serializable
+{
+   private String name;
+
+   public String getName()
+   {
+      return name;
+   }
+
+   @XmlAttribute(required = true)
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/package-info.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/package-info.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/other/package-info.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -0,0 +1,28 @@
+/*
+* 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.
+*/
+ at JBossXmlSchema(namespace="urn:jboss:myother:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+package org.jboss.test.deployers.vfs.xb.support.other;
+
+import javax.xml.bind.annotation.XmlNsForm;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+

Added: 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	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -0,0 +1,89 @@
+/*
+* 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 java.net.URL;
+import java.util.Collections;
+
+import junit.framework.Test;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.test.deployers.vfs.xb.XBDeployersTest;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Schema resolver JBossXB package test case.
+ *
+ * @param <T> exact output type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractSchemaResolverXBTest<T> extends XBDeployersTest
+{
+   public AbstractSchemaResolverXBTest(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(SchemaResolverXBPackageTestCase.class);
+   }
+
+   protected abstract Class<T> getOutput();
+
+   protected abstract String getSuffix();
+
+   protected abstract String getName(T metadata);
+
+   public void testJBossXBParser() throws Throwable
+   {
+      SchemaResolverDeployer<?> deployer = assertBean("deployer", SchemaResolverDeployer.class);
+      assertEquals(getOutput(), deployer.getOutput());
+      assertEquals(getSuffix(), deployer.getSuffix());
+      assertTrue(deployer.isRegisterWithJBossXB());
+
+      String common = "/org/jboss/test/deployers/vfs/xb/test";
+      URL url = getClass().getResource(common);
+      assertNotNull(url);
+      VirtualFile file = VFS.getRoot(url);
+      assertNotNull(file);
+
+      VFSDeploymentContext context = new AbstractVFSDeploymentContext(file, "");
+      context.setMetaDataLocations(Collections.singletonList(file));
+      AbstractVFSDeploymentUnit unit = new AbstractVFSDeploymentUnit(context);
+
+      deployer.deploy(unit);
+      try
+      {
+         T metaData = unit.getAttachment(getOutput());
+         assertNotNull(metaData);
+         assertEquals("mymetadata", getName(metaData));
+      }
+      finally
+      {
+         deployer.undeploy(unit);
+      }
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.java (from rev 71307, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBPackageTestCase.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -0,0 +1,58 @@
+/*
+* 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.test.deployers.vfs.xb.support.other.OtherMetaData;
+
+/**
+ * Schema resolver JBossXB package test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SchemaResolverXBPackageTestCase extends AbstractSchemaResolverXBTest<OtherMetaData>
+{
+   public SchemaResolverXBPackageTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(SchemaResolverXBPackageTestCase.class);
+   }
+
+   protected Class<OtherMetaData> getOutput()
+   {
+      return OtherMetaData.class;
+   }
+
+   protected String getSuffix()
+   {
+      return "-other.xml";
+   }
+
+   protected String getName(OtherMetaData metadata)
+   {
+      return metadata.getName();
+   }
+}
\ No newline at end of file

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.java	2008-03-26 21:33:34 UTC (rev 71326)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/SchemaResolverXBTestCase.java	2008-03-26 22:01:14 UTC (rev 71327)
@@ -21,25 +21,15 @@
 */
 package org.jboss.test.deployers.vfs.xb.test;
 
-import java.net.URL;
-import java.util.Collections;
-
 import junit.framework.Test;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.test.deployers.vfs.xb.XBDeployersTest;
 import org.jboss.test.deployers.vfs.xb.support.TestMetaData;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
 
 /**
  * Schema resolver JBossXB test case.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class SchemaResolverXBTestCase extends XBDeployersTest
+public class SchemaResolverXBTestCase extends AbstractSchemaResolverXBTest<TestMetaData>
 {
    public SchemaResolverXBTestCase(String name)
    {
@@ -51,26 +41,18 @@
       return suite(SchemaResolverXBTestCase.class);
    }
 
-   public void testJBossXBParser() throws Throwable
+   protected Class<TestMetaData> getOutput()
    {
-      SchemaResolverDeployer<?> deployer = assertBean("deployer", SchemaResolverDeployer.class);
-      assertEquals(TestMetaData.class, deployer.getOutput());
-      assertEquals("-foobar.xml", deployer.getSuffix());
-      assertTrue(deployer.isRegisterWithJBossXB());
+      return TestMetaData.class;
+   }
 
-      String common = "/org/jboss/test/deployers/vfs/xb/test";
-      URL url = getClass().getResource(common);
-      assertNotNull(url);
-      VirtualFile file = VFS.getRoot(url);
-      assertNotNull(file);
+   protected String getSuffix()
+   {
+      return "-foobar.xml";
+   }
 
-      VFSDeploymentContext context = new AbstractVFSDeploymentContext(file, "");
-      context.setMetaDataLocations(Collections.singletonList(file));
-      AbstractVFSDeploymentUnit unit = new AbstractVFSDeploymentUnit(context);
-      deployer.deploy(unit);
-
-      TestMetaData metaData = unit.getAttachment(TestMetaData.class);
-      assertNotNull(metaData);
-      assertEquals("mymetadata", metaData.getName());
+   protected String getName(TestMetaData metadata)
+   {
+      return metadata.getName();
    }
 }




More information about the jboss-cvs-commits mailing list