[jboss-svn-commits] JBL Code SVN: r6297 - in labs/jbossesb/workspace/rearchitecture/product/etc/validation: . src/org/jboss/soa/esb/services/xml tests tests/resources tests/src tests/src/org tests/src/org/jboss tests/src/org/jboss/soa tests/src/org/jboss/soa/esb tests/src/org/jboss/soa/esb/services tests/src/org/jboss/soa/esb/services/xml
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 19 10:19:10 EDT 2006
Author: arvinder
Date: 2006-09-19 10:19:00 -0400 (Tue, 19 Sep 2006)
New Revision: 6297
Added:
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/bascic-jms-epr-example.xml
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-email-epr-example.xml
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-ftp-epr-example.xml
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-jdbc-epr.example.xml
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/xml/
labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/xml/XmlValidationTest.java
Modified:
labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml
labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java
Log:
Added basic code and place holders
Modified: labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml 2006-09-19 14:17:23 UTC (rev 6296)
+++ labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml 2006-09-19 14:19:00 UTC (rev 6297)
@@ -0,0 +1,99 @@
+<project name="JBESB" default="usage" basedir=".">
+
+
+ <!-- ================================================================== -->
+ <!-- P R O P E R T I E S -->
+ <!-- ================================================================== -->
+ <property name="org.jboss.esb.etc.schema.xsd.home" value="."/>
+ <property name="org.jboss.esb.etc.schema.xsd.examples" value="."/>
+
+ <!-- ================================================================== -->
+ <!-- U S A G E -->
+ <!-- ================================================================== -->
+ <target name="org.jboss.esb.etc.schema.usage" >
+ <echo message="+----------------------------------------------------------------+"/>
+ <echo message="| "/>
+ <echo message="| U S A G E: "/>
+ <echo message="| "/>
+ <echo message="| ant [target] [options] "/>
+ <echo message="| "/>
+ <echo message="| Where: "/>
+ <echo message="| "/>
+ <echo message="| targets = "/>
+ <echo message="| clean [ clean temporary dirs and classes ] "/>
+ <echo message="| compile [ compile classes ] "/>
+ <echo message="| validate [ validate all xsd examples ] "/>
+ <echo message="| validate.email [ validate email examples ] "/>
+ <echo message="| validate.jdbc [ validate jdbc examples ] "/>
+ <echo message="| validate.jms [ validate jms examples ] "/>
+ <echo message="| validate.ftp [ validate ftp examples ] "/>
+ <echo message="| "/>
+ <echo message="+----------------------------------------------------------------+"/>
+
+ </target>
+
+
+ <!-- ================================================================== -->
+ <!-- C L E A N -->
+ <!-- ================================================================== -->
+ <target name="org.jboss.esb.etc.schema.clean" >
+ <echo message="+--------------------------------------------------------+"/>
+ <echo message="| |"/>
+ <echo message="| C L E A N |"/>
+ <echo message="| |"/>
+ <echo message="+--------------------------------------------------------+"/>
+
+ </target>
+
+
+ <!-- ================================================================== -->
+ <!-- P R E P A R E -->
+ <!-- ================================================================== -->
+ <target name="org.jboss.esb.etc.schema.prepare" depends="clean" >
+ <echo message="+--------------------------------------------------------+"/>
+ <echo message="| |"/>
+ <echo message="| P R E P A R E |"/>
+ <echo message="| |"/>
+ <echo message="+--------------------------------------------------------+"/>
+
+ </target>
+
+
+ <!-- ================================================================== -->
+ <!-- B U I L D -->
+ <!-- ================================================================== -->
+ <target name="org.jboss.esb.etc.schema.build" depends="org.jboss.esb.etc.schema.prepare" >
+ <echo message="+--------------------------------------------------------+"/>
+ <echo message="| |"/>
+ <echo message="| C O M P I L E |"/>
+ <echo message="| |"/>
+ <echo message="+--------------------------------------------------------+"/>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- V A L I D A T E -->
+ <!-- ================================================================== -->
+ <target name="org.jboss.esb.etc.schema.validate" depends="build" >
+ <echo message="+--------------------------------------------------------+"/>
+ <echo message="| |"/>
+ <echo message="| V A L I D A T E |"/>
+ <echo message="| |"/>
+ <echo message="+--------------------------------------------------------+"/>
+ <ant dir="tests" target="test"/>
+ </target>
+
+
+
+
+ <!-- ================================================================== -->
+ <!-- S H O R T N A M E S -->
+ <!-- ================================================================== -->
+ <target name="usage" depends="org.jboss.esb.etc.schema.usage" />
+ <target name="clean" depends="org.jboss.esb.etc.schema.clean" />
+ <target name="build" depends="org.jboss.esb.etc.schema.build" />
+ <target name="validate" depends="org.jboss.esb.etc.schema.validate" />
+
+
+
+</project>
Modified: labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java 2006-09-19 14:17:23 UTC (rev 6296)
+++ labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java 2006-09-19 14:19:00 UTC (rev 6297)
@@ -23,6 +23,7 @@
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
+import org.jboss.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -36,37 +37,54 @@
import java.io.File;
/**
- * Class Description
+ * A Helper classes used to validate xml files against supplied schemas.
*
* @author $Revision$
* $Id$
*/
public class XmlValidation {
+ /**
+ * Our Logger
+ */
+ private Logger log = Logger.getLogger(XmlValidation.class);
+ /**
+ * The xml file to validate.
+ */
private String xmlFileToValidate = null;
+ /**
+ * The xsd to validate it against.
+ */
private String xsdToValidateAgainst = null;
- public static void main(String[] args) {
-
- }
-
+ /**
+ * Validation method used to validate an xml file against an xsd.
+ * @param xml The xml file to be validated.
+ * @param xsd The schema to validate against.
+ * @return Boolean true/false indicating successful validation.
+ * @throws Exception Failure during validation.
+ */
public boolean validate(String xml, String xsd) throws Exception {
-
+ if(log.isInfoEnabled()) {
+ log.info("Validating " + xml + " Against " + xsd);
+ }
boolean isValid = false;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File(xml));
-
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Source schemaFile = new StreamSource(new File(xsd));
Schema schema = factory.newSchema(schemaFile);
Validator validator = schema.newValidator();
-
try {
validator.validate(new DOMSource(document));
isValid = true;
} catch (SAXException e) {
-
+ log.error("Failed to validate xml",e);
+ throw e;
}
+ if(log.isInfoEnabled()) {
+ log.info("IsValid = " + isValid);
+ }
return isValid;
}
Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/bascic-jms-epr-example.xml
===================================================================
Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-email-epr-example.xml
===================================================================
Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-ftp-epr-example.xml
===================================================================
Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/resources/basic-jdbc-epr.example.xml
===================================================================
Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/xml/XmlValidationTest.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/xml/XmlValidationTest.java 2006-09-19 14:17:23 UTC (rev 6296)
+++ labs/jbossesb/workspace/rearchitecture/product/etc/validation/tests/src/org/jboss/soa/esb/services/xml/XmlValidationTest.java 2006-09-19 14:19:00 UTC (rev 6297)
@@ -0,0 +1,43 @@
+package org.jboss.soa.esb.services.xml;
+
+import org.jboss.soa.esb.common.tests.BaseTest;
+
+
+public class XmlValidationTest extends BaseTest {
+
+
+
+ /**
+ * Validate the Email EPR
+ * @throws Exception
+ */
+ public void testBasicEmailEPR() throws Exception {
+
+ }
+
+ /**
+ * Validate the JMS EPR
+ * @throws Exception
+ */
+ public void testBasicJMSEPR() throws Exception {
+
+ }
+
+ /**
+ * Validate the JDBC EPR
+ * @throws Exception
+ */
+ public void testBasicJDBCEPR() throws Exception {
+
+ }
+
+ /**
+ * Validate the FTP EPR
+ * @throws Exception
+ */
+ public void testBasicFTPEPR() throws Exception {
+
+ }
+
+
+}
More information about the jboss-svn-commits
mailing list