Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add RI unit test showing that multiple schemas can be validated
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2454 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Victor Yarmolovich
committed
Apr 17, 2009
1 parent
ede4d41
commit d6dd2ef
Showing
10 changed files
with
138 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/schema/SchemaValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jboss.webbeans.test.unit.xml.parser.schema; | ||
|
||
import javax.inject.DefinitionException; | ||
|
||
import org.jboss.testharness.impl.packaging.Artifact; | ||
import org.jboss.testharness.impl.packaging.Classes; | ||
import org.jboss.testharness.impl.packaging.Resource; | ||
import org.jboss.testharness.impl.packaging.Resources; | ||
import org.jboss.webbeans.ejb.EjbDescriptorCache; | ||
import org.jboss.webbeans.mock.MockXmlEnvironment; | ||
import org.jboss.webbeans.test.AbstractWebBeansTest; | ||
import org.jboss.webbeans.test.unit.xml.beans.Order; | ||
import org.jboss.webbeans.xml.XmlEnvironment; | ||
import org.jboss.webbeans.xml.XmlParser; | ||
import org.testng.annotations.Test; | ||
|
||
@Artifact | ||
@Resources({ | ||
@Resource(source="/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml", destination="WEB-INF/classes/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml" ), | ||
@Resource(source="/org/jboss/webbeans/test/unit/xml/parser/schema/not-valid-beans.xml", destination="WEB-INF/classes/org/jboss/webbeans/test/unit/xml/parser/schema/not-valid-beans.xml" ) | ||
}) | ||
@Classes({Order.class}) | ||
public class SchemaValidationTest extends AbstractWebBeansTest | ||
{ | ||
@Test | ||
public void testTwoValidSchemas() | ||
{ | ||
XmlEnvironment parserEnv = new MockXmlEnvironment(getResources("beans.xml"), new EjbDescriptorCache()); | ||
XmlParser parser = new XmlParser(parserEnv); | ||
parser.parse(); | ||
|
||
assert parserEnv.getManager().resolveByType(Order.class).size() == 1; | ||
} | ||
|
||
@Test(expectedExceptions = DefinitionException.class) | ||
public void testOneSchemaNotValid() | ||
{ | ||
XmlEnvironment parserEnv = new MockXmlEnvironment(getResources("not-valid-beans.xml"), new EjbDescriptorCache()); | ||
XmlParser parser = new XmlParser(parserEnv); | ||
parser.parse(); | ||
|
||
assert false; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Beans xmlns="urn:java:ee" | ||
xmlns:myapp="urn:java:org.jboss.webbeans.test.unit.xml.parser.schema" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="urn:java:org.jboss.webbeans.test.unit.xml.parser.schema.valid http://mydomain.com/myapp/schema-1.2.xsd"> | ||
|
||
<Deploy> | ||
<Standard /> | ||
<Production /> | ||
<myapp:TestDeploymentType /> | ||
</Deploy> | ||
|
||
<myapp:Order> | ||
<Array> | ||
<String /> | ||
</Array> | ||
<myapp:getVal /> | ||
<myapp:val /> | ||
<Integer /> | ||
</myapp:Order> | ||
</Beans> |
2 changes: 2 additions & 0 deletions
2
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.jboss.webbeans.test.unit.xml.beans | ||
org.jboss.webbeans.test.unit.xml.beans.annotationtype |
20 changes: 20 additions & 0 deletions
20
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/not-valid-beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Beans xmlns="urn:java:ee" | ||
xmlns:myapp="urn:java:org.jboss.webbeans.test.unit.xml.parser.schema" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="urn:java:org.jboss.webbeans.test.unit.xml.parser.schema.notvalid http://mydomain.com/myapp/schema-1.2.xsd"> | ||
|
||
<Deploy> | ||
<Standard /> | ||
<Production /> | ||
<myapp:TestDeploymentType /> | ||
</Deploy> | ||
|
||
<myapp:Order> | ||
<Array> | ||
<String /> | ||
</Array> | ||
<myapp:getVal /> | ||
<myapp:val /> | ||
<Integer /> | ||
</myapp:Order> | ||
</Beans> |
10 changes: 10 additions & 0 deletions
10
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/notvalid/schema.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java:ee"> | ||
<xs:element name="Beanses"> | ||
<xs:complexType> | ||
<xs:sequence minOccurs="0" maxOccurs="unbounded"> | ||
<xs:any namespace="##any" processContents="skip" /> | ||
</xs:sequence> | ||
<xs:anyAttribute namespace="##any" processContents="skip" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
10 changes: 10 additions & 0 deletions
10
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/schema.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java:ee"> | ||
<xs:element name="Beans"> | ||
<xs:complexType> | ||
<xs:sequence minOccurs="0" maxOccurs="unbounded"> | ||
<xs:any namespace="##any" processContents="skip" /> | ||
</xs:sequence> | ||
<xs:anyAttribute namespace="##any" processContents="skip" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
10 changes: 10 additions & 0 deletions
10
tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/valid/schema.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java:ee"> | ||
<xs:element name="Beans"> | ||
<xs:complexType> | ||
<xs:sequence minOccurs="0" maxOccurs="unbounded"> | ||
<xs:any namespace="##any" processContents="skip" /> | ||
</xs:sequence> | ||
<xs:anyAttribute namespace="##any" processContents="skip" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters