[jboss-cvs] JBossAS SVN: r106120 - in projects/profileservice/trunk/domain: src/test/java/org/jboss/test/profileservice/domain/parsing/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 17 11:17:17 EDT 2010


Author: alex.loubyansky at jboss.com
Date: 2010-06-17 11:17:16 -0400 (Thu, 17 Jun 2010)
New Revision: 106120

Added:
   projects/profileservice/trunk/domain/src/test/java/org/jboss/test/profileservice/domain/parsing/test/XSDValidationUnitTestCase.java
Modified:
   projects/profileservice/trunk/domain/pom.xml
   projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-logging.xsd
   projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-resources.xsd
   projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-servers.xsd
Log:
basic domain xsd validation tests

Modified: projects/profileservice/trunk/domain/pom.xml
===================================================================
--- projects/profileservice/trunk/domain/pom.xml	2010-06-17 13:55:46 UTC (rev 106119)
+++ projects/profileservice/trunk/domain/pom.xml	2010-06-17 15:17:16 UTC (rev 106120)
@@ -33,6 +33,20 @@
 			<artifactId>jboss-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+
+    <dependency>
+      <groupId>xml-apis</groupId>
+      <artifactId>xml-apis</artifactId>
+      <version>1.3.04</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+      <version>2.9.1</version>
+      <scope>test</scope>
+    </dependency>
 		
   </dependencies>
   

Added: projects/profileservice/trunk/domain/src/test/java/org/jboss/test/profileservice/domain/parsing/test/XSDValidationUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/domain/src/test/java/org/jboss/test/profileservice/domain/parsing/test/XSDValidationUnitTestCase.java	                        (rev 0)
+++ projects/profileservice/trunk/domain/src/test/java/org/jboss/test/profileservice/domain/parsing/test/XSDValidationUnitTestCase.java	2010-06-17 15:17:16 UTC (rev 106120)
@@ -0,0 +1,71 @@
+package org.jboss.test.profileservice.domain.parsing.test;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.Util;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * A XSDValidationUnitTestCase.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class XSDValidationUnitTestCase extends BaseTestCase
+{
+   public XSDValidationUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testCommon() throws Exception
+   {
+      validateSchema("jboss-domain-common.xsd");
+   }
+
+   public void testServers() throws Exception
+   {
+      validateSchema("jboss-domain-servers.xsd");
+   }
+
+   private void validateSchema(String name) throws IOException
+   {
+      URL xsd = getSchemaUrl(name);
+      JBossEntityResolver entityResolver = new JBossEntityResolver()
+      {
+         @Override
+         public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+         {
+            URL schemaUrl = getSchemaUrl(systemId);
+            if(schemaUrl == null)
+               throw new IllegalStateException("Schema " + systemId + " not found in 'schemas/'");
+            InputSource is = new InputSource();
+            is.setByteStream(schemaUrl.openStream());
+            return is;
+         }         
+      };
+      MultiClassSchemaResolver resolver = new MultiClassSchemaResolver(entityResolver);
+      try
+      {
+         assertNotNull(Util.loadSchema(xsd.openStream(), null, resolver));
+      }
+      catch(Throwable t)
+      {
+         fail(t.getMessage());
+      }
+   }
+
+   private URL getSchemaUrl(String name)
+   {
+      ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+      URL xsd = ccl.getResource("schemas/" + name);
+      return xsd;
+   }
+}

Modified: projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-logging.xsd
===================================================================
--- projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-logging.xsd	2010-06-17 13:55:46 UTC (rev 106119)
+++ projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-logging.xsd	2010-06-17 15:17:16 UTC (rev 106120)
@@ -29,8 +29,8 @@
             attributeFormDefault="unqualified"
             version="1.0">
 
-    <!-- Allow access to common domain schema elements -->
-    <xs:include schemaLocation="jboss-domain-common.xsd"/>
+    <!-- Allow access to common domain schema elements
+    <xs:include schemaLocation="jboss-domain-common.xsd"/> -->
 
     <xs:element name="logging" type="loggingType"/>
 
@@ -209,7 +209,7 @@
             <xs:element name="formatter" type="formatterType" minOccurs="0"/>
             <xs:element name="loggers" type="loggersType" minOccurs="0"/>
             <xs:element name="sub-handlers" type="handlersType" minOccurs="0"/>
-            <xs:element name="properties" type="com:propertiesType" minOccurs="0"/>
+            <xs:element name="properties" type="propertiesType" minOccurs="0"/>
         </xs:all>
         <xs:attribute name="name" type="xs:string" use="optional"/>
         <xs:attribute name="encoding" type="xs:string" use="optional"/>

Modified: projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-resources.xsd
===================================================================
--- projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-resources.xsd	2010-06-17 13:55:46 UTC (rev 106119)
+++ projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-resources.xsd	2010-06-17 15:17:16 UTC (rev 106120)
@@ -38,7 +38,7 @@
                 <xs:attribute name="jndi-lookup-name" use="required"/>
                 <xs:attribute name="res-type" use="required"/>
                 <xs:attribute name="factory-class" use="required"/>
-                <xs:attribute name="enabled" default="true" type="dc:boolean"/>
+                <xs:attribute name="enabled" default="true" type="boolean"/>
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>

Modified: projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-servers.xsd
===================================================================
--- projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-servers.xsd	2010-06-17 13:55:46 UTC (rev 106119)
+++ projects/profileservice/trunk/domain/src/test/resources/schemas/jboss-domain-servers.xsd	2010-06-17 15:17:16 UTC (rev 106120)
@@ -4,10 +4,8 @@
     targetNamespace="urn:jboss:domain:1.0"
     >
 
-    <!-- Include the common definitions -->
-    <xs:include schemaLocation="jboss-domain-common.xsd" />
-    <!-- Include the profiles -->
-    <xs:include schemaLocation="jboss-domain-profiles.xsd" />
+    <!-- Include the common definitions
+    <xs:include schemaLocation="jboss-domain-common.xsd" /> -->
     <!-- Include the resources definitions -->
     <xs:include schemaLocation="jboss-domain-resources.xsd" />
     <!-- Include the logging schema definitions for reuse -->



More information about the jboss-cvs-commits mailing list