[jboss-cvs] JBossAS SVN: r74382 - in projects/jboss-deployers/trunk: deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 11 07:32:28 EDT 2008
Author: alesj
Date: 2008-06-11 07:32:28 -0400 (Wed, 11 Jun 2008)
New Revision: 74382
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.xml
projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml
projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/IncludeMetaData.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java
Modified:
projects/jboss-deployers/trunk/build/pom.xml
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java
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/AbstractSchemaResolverXBTest.java
Log:
[JBDEPLOY-47]; passing systemId to xml parser deployers.
Modified: projects/jboss-deployers/trunk/build/pom.xml
===================================================================
--- projects/jboss-deployers/trunk/build/pom.xml 2008-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/build/pom.xml 2008-06-11 11:32:28 UTC (rev 74382)
@@ -28,7 +28,7 @@
<version.jboss.common.core>2.2.4.GA</version.jboss.common.core>
<version.jboss.common.logging.spi>2.0.4.GA</version.jboss.common.logging.spi>
<version.jboss.common.logging.log4j>2.0.4.GA</version.jboss.common.logging.log4j>
- <version.jbossxb>2.0.0.CR9</version.jbossxb>
+ <version.jbossxb>2.0.0-SNAPSHOT</version.jbossxb>
<version.jboss.aop>2.0.0.CR11</version.jboss.aop>
<version.jboss.vfs>2.0.0.Beta14</version.jboss.vfs>
<version.org.jboss.test>1.0.5.GA</version.org.jboss.test>
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.xml (from rev 74372, 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/IncludeTestCase.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.xml 2008-06-11 11:32:28 UTC (rev 74382)
@@ -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.IncludeMetaData"
+ suffix="-include.xml"
+ register-with-jbossxb="true"
+ />
+
+</deployment>
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml (from rev 74372, 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-include.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml 2008-06-11 11:32:28 UTC (rev 74382)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss-include xmlns="urn:jboss:include:1.0" name="mymetadata" xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <jboss-test>test1</jboss-test>
+ <xi:include fixup-base-uris="false" fixup-language="false" href="included.xml"/>
+
+</jboss-include>
Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml 2008-06-11 11:32:28 UTC (rev 74382)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-test xmlns="urn:jboss:include:1.0">test2</jboss-test>
+
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java 2008-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -56,12 +56,16 @@
public void testNullStream() throws Exception
{
+ // this one needs to be created first
+ TestXmlDeployer xmlDeployer = new TestXmlDeployer();
+ xmlDeployer.create();
+
AbstractVFSParsingDeployer<?>[] deployers = new AbstractVFSParsingDeployer<?>[]
{
new Properties2BeansDeployer(),
new MockBshDeployer(),
// new TestJaxbDeployer(),
- new TestXmlDeployer(),
+ xmlDeployer,
new SchemaResolverDeployer<Object>(Object.class),
};
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-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/JBossXBDeployersTestSuite.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -24,8 +24,9 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.jboss.test.deployers.vfs.xb.test.IncludeTestCase;
+import org.jboss.test.deployers.vfs.xb.test.SchemaResolverXBPackageTestCase;
import org.jboss.test.deployers.vfs.xb.test.SchemaResolverXBTestCase;
-import org.jboss.test.deployers.vfs.xb.test.SchemaResolverXBPackageTestCase;
/**
* JBossXB deployers extensions.
@@ -45,6 +46,7 @@
suite.addTest(SchemaResolverXBTestCase.suite());
suite.addTest(SchemaResolverXBPackageTestCase.suite());
+ suite.addTest(IncludeTestCase.suite());
return suite;
}
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/IncludeMetaData.java (from rev 74372, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/TestMetaData.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/IncludeMetaData.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/support/IncludeMetaData.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -0,0 +1,73 @@
+/*
+* 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;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at JBossXmlSchema(namespace="urn:jboss:include:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="jboss-include", namespace = "urn:jboss:include:1.0")
+ at XmlType(
+ name="includeType",
+ namespace="urn:jboss:include:1.0",
+ propOrder={"others"}
+)
+public class IncludeMetaData implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private List<TestMetaData> others;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @XmlAttribute(required = true)
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public List<TestMetaData> getOthers()
+ {
+ return others;
+ }
+
+ @XmlElement(name = "jboss-test")
+ public void setOthers(List<TestMetaData> others)
+ {
+ this.others = others;
+ }
+}
\ No newline at end of file
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-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -24,8 +24,6 @@
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;
@@ -47,11 +45,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(SchemaResolverXBPackageTestCase.class);
- }
-
protected abstract Class<T> getOutput();
protected abstract String getSuffix();
@@ -79,12 +72,17 @@
try
{
T metaData = unit.getAttachment(getOutput());
- assertNotNull(metaData);
- assertEquals("mymetadata", getName(metaData));
+ assertMetaData(metaData);
}
finally
{
deployer.undeploy(unit);
}
}
+
+ protected void assertMetaData(T metaData) throws Exception
+ {
+ assertNotNull(metaData);
+ assertEquals("mymetadata", getName(metaData));
+ }
}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -0,0 +1,72 @@
+/*
+* 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.util.List;
+
+import junit.framework.Test;
+import org.jboss.test.deployers.vfs.xb.support.IncludeMetaData;
+import org.jboss.test.deployers.vfs.xb.support.TestMetaData;
+
+/**
+ * Test include.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class IncludeTestCase extends AbstractSchemaResolverXBTest<IncludeMetaData>
+{
+ public IncludeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(IncludeTestCase.class);
+ }
+
+ protected Class<IncludeMetaData> getOutput()
+ {
+ return IncludeMetaData.class;
+ }
+
+ protected String getSuffix()
+ {
+ return "-include.xml";
+ }
+
+ protected String getName(IncludeMetaData metadata)
+ {
+ return metadata.getName();
+ }
+
+ protected void assertMetaData(IncludeMetaData metaData) throws Exception
+ {
+ super.assertMetaData(metaData);
+ List<TestMetaData> others = metaData.getOthers();
+ assertNotNull(others);
+ int size = 2;
+ assertEquals(size, others.size());
+ for(int i=0; i < size; i++)
+ assertEquals("test" + i, others.get(i).getName());
+ }
+}
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java 2008-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -166,17 +166,17 @@
{
if (file == null)
throw new IllegalArgumentException("Null file");
+
+ log.debug("Parsing: " + file.getName());
- log.trace("Parsing: " + file.getName());
-
+ DocumentBuilder parser = getDocumentBuilderFactory().newDocumentBuilder();
InputStream is = openStreamAndValidate(file);
try
{
- DocumentBuilder parser = getDocumentBuilderFactory().newDocumentBuilder();
InputSource source = new InputSource(is);
source.setSystemId(file.toURI().toString());
parser.setEntityResolver(new JBossEntityResolver());
- return parser.parse(is);
+ return parser.parse(source);
}
finally
{
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java 2008-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.logging.Logger;
@@ -34,6 +33,7 @@
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+import org.xml.sax.InputSource;
/**
* JBossXB deployer helper.
@@ -185,11 +185,12 @@
unmarshaller.setSchemaValidation(isUseSchemaValidation());
unmarshaller.setValidation(isUseValidation());
InputStream is = openStreamAndValidate(file);
- Object parsed = null;
+ Object parsed;
try
{
- parsed = unmarshaller.unmarshal(is, resolver);
- log.debug("Parsed file: "+file+" to: "+parsed);
+ InputSource source = new InputSource(is);
+ source.setSystemId(file.toURI().toString());
+ parsed = unmarshaller.unmarshal(source, resolver);
}
finally
{
@@ -204,6 +205,7 @@
if (parsed == null)
throw new DeploymentException("The xml " + file.getPathName() + " is not well formed!");
+ log.debug("Parsed file: "+file+" to: "+parsed);
return expectedType.cast(parsed);
}
@@ -241,19 +243,28 @@
Unmarshaller unmarshaller = factory.newUnmarshaller();
unmarshaller.setSchemaValidation(isUseSchemaValidation());
unmarshaller.setValidation(isUseValidation());
- Object parsed = null;
+ InputStream is = openStreamAndValidate(file);
+ Object parsed;
try
{
- URL url = file.toURL();
- parsed = unmarshaller.unmarshal(url.toString(), omf, root);
+ InputSource source = new InputSource(is);
+ source.setSystemId(file.toURI().toString());
+ parsed = unmarshaller.unmarshal(source, omf, root);
}
- catch (Throwable t)
+ finally
{
- DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + file.getPathName(), t);
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
}
if (parsed == null)
throw new DeploymentException("The xml " + file.getPathName() + " is not well formed!");
+ log.debug("Parsed file: "+file+" to: "+parsed);
return expectedType.cast(parsed);
}
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java 2008-06-11 11:12:47 UTC (rev 74381)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java 2008-06-11 11:32:28 UTC (rev 74382)
@@ -147,6 +147,7 @@
Transformer trans = getTemplates().newTransformer();
trans.setErrorListener(new JBossErrorHandler(file.getPathName(), null));
Source s = new DOMSource(document);
+ s.setSystemId(file.toURI().toString());
DOMResult r = new DOMResult();
setParameters(trans);
@@ -169,15 +170,4 @@
{
// nothing by default
}
-
- /**
- * Parse a deployment
- *
- * @param unit the deployment unit
- * @param file the metadata file
- * @param document the document
- * @return the metadata
- * @throws Exception for any error
- */
- protected abstract T parse(VFSDeploymentUnit unit, VirtualFile file, Document document) throws Exception;
}
More information about the jboss-cvs-commits
mailing list