directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r751996 - in /directory/apacheds/trunk: ./ xbean-spring/ xbean-spring/src/test/ xbean-spring/src/test/java/ xbean-spring/src/test/java/org/ xbean-spring/src/test/java/org/apache/ xbean-spring/src/test/java/org/apache/directory/ xbean-spring...
Date Tue, 10 Mar 2009 06:31:55 GMT
Author: felixk
Date: Tue Mar 10 06:31:55 2009
New Revision: 751996

URL: http://svn.apache.org/viewvc?rev=751996&view=rev
Log:
Add test to validate sample configurations from module server-xml against the generated schema.

Added:
    directory/apacheds/trunk/xbean-spring/src/test/
    directory/apacheds/trunk/xbean-spring/src/test/java/
    directory/apacheds/trunk/xbean-spring/src/test/java/org/
    directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/
    directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/
    directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/
    directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
  (with props)
Modified:
    directory/apacheds/trunk/pom.xml
    directory/apacheds/trunk/xbean-spring/pom.xml

Modified: directory/apacheds/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?rev=751996&r1=751995&r2=751996&view=diff
==============================================================================
--- directory/apacheds/trunk/pom.xml (original)
+++ directory/apacheds/trunk/pom.xml Tue Mar 10 06:31:55 2009
@@ -269,6 +269,13 @@
         <artifactId>bcprov-jdk15</artifactId>
         <version>140</version>
       </dependency>
+
+      <dependency>
+        <groupId>xerces</groupId>
+        <artifactId>xercesImpl</artifactId>
+        <version>2.9.1</version>
+      </dependency>
+
     </dependencies>
   </dependencyManagement>
 

Modified: directory/apacheds/trunk/xbean-spring/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xbean-spring/pom.xml?rev=751996&r1=751995&r2=751996&view=diff
==============================================================================
--- directory/apacheds/trunk/xbean-spring/pom.xml (original)
+++ directory/apacheds/trunk/xbean-spring/pom.xml Tue Mar 10 06:31:55 2009
@@ -131,6 +131,11 @@
       <scope>provided</scope>
     </dependency>
 
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+    </dependency>
+
     <!-- replication interceptor xbean config metadata -->
     <dependency>
       <groupId>org.apache.directory.server</groupId>
@@ -186,6 +191,46 @@
           </execution>
         </executions>
       </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>unpack-sample-configurations</id>
+            <phase>process-test-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.directory.server</groupId>
+                  <artifactId>apacheds-server-xml</artifactId>
+                  <type>jar</type>
+                  <version>${pom.version}</version>
+                  <outputDirectory>target/test-classes</outputDirectory>
+                  <includes>**/server.xml, **/serverAuthenticatorInAuthenticationInterceptor.xml,
**/serverJdbmPartition.xml, **/serverReplicationInterceptor.xml</includes>
+                </artifactItem>
+                <artifactItem>
+                  <groupId>org.apache.xbean</groupId>
+                  <artifactId>xbean-spring</artifactId>
+                  <type>jar</type>
+                  <outputDirectory>target/test-classes</outputDirectory>
+                  <includes>**/*.xsd</includes>
+                </artifactItem>
+                <artifactItem>
+                  <groupId>org.springframework</groupId>
+                  <artifactId>spring-beans</artifactId>
+                  <type>jar</type>
+                  <outputDirectory>target/test-classes</outputDirectory>
+                  <includes>**/*.xsd</includes>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>

Added: directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java?rev=751996&view=auto
==============================================================================
--- directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
(added)
+++ directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
Tue Mar 10 06:31:55 2009
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server;
+
+
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+/**
+ * Tests to validate sample configurations against generated schema
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$ $Date$
+ * 
+ */
+public class ConfigurationValidationTest
+{
+
+    static final String apachedsXbeanSchema = "target/xbean/apacheds-xbean-spring.xsd";
+    static final String springBeans = "target/test-classes/org/springframework/beans/factory/xml/spring-beans-2.5.xsd";
+    static final String springTool = "target/test-classes/org/springframework/beans/factory/xml/spring-tool-2.5.xsd";
+    static final String springUtil = "target/test-classes/org/springframework/beans/factory/xml/spring-util-2.5.xsd";
+    static final String xbeanSpring = "target/test-classes/org/apache/xbean/spring/spring-beans.xsd";
+
+    static final String[] schemas =
+        { springBeans, apachedsXbeanSchema, springTool, springUtil, xbeanSpring };
+
+    private static DocumentBuilder builder;
+    private Validator handler = null;
+
+
+    /**
+     * Global setup for the whole test class
+     */
+    @BeforeClass
+    public static void GlobalSetup()
+    {
+        try
+        {
+            System.setProperty( "javax.xml.parsers.DocumentBuilderFactory",
+                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl" );
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setNamespaceAware( true );
+            factory.setValidating( true );
+            factory.setAttribute( "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+                "http://www.w3.org/2001/XMLSchema" );
+            factory.setAttribute( "http://java.sun.com/xml/jaxp/properties/schemaSource",
schemas );
+            builder = factory.newDocumentBuilder();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * SetUp for each test
+     */
+    @Before
+    public void SetUp()
+    {
+        handler = new Validator();
+        builder.setErrorHandler( handler );
+    }
+
+
+    /**
+     * Test validation of server.xml file
+     * 
+     * @throws Exception
+     */
+    @Ignore("Failing because 'Cannot find the declaration of element 'spring:beans'.'")
+    @Test
+    public void testValidationServerXml() throws Exception
+    {
+        builder.parse( "file:./target/test-classes/server.xml" );
+
+        assertTrue( handler.saxParseException.toString(), !handler.validationError );
+    }
+
+
+    /**
+     * Test validation of serverAuthenticatorInAuthenticationInterceptor.xml
+     * file
+     * 
+     * @throws Exception
+     */
+    @Ignore("Failing because 'Cannot find the declaration of element 'spring:beans'.'")
+    @Test
+    public void testValidationServerAuthenticatorInAuthenticationInterceptorXml() throws
Exception
+    {
+        builder.parse( "file:./target/test-classes/serverAuthenticatorInAuthenticationInterceptor.xml"
);
+
+        assertTrue( handler.saxParseException.toString(), !handler.validationError );
+    }
+
+
+    /**
+     * Test validation of serverJdbmPartition.xml file
+     * 
+     * @throws Exception
+     */
+    @Ignore("Failing because 'Cannot find the declaration of element 'spring:beans'.'")
+    @Test
+    public void testValidationServerJdbmPartitionXml() throws Exception
+    {
+        builder.parse( "file:./target/test-classes/serverJdbmPartition.xml" );
+
+        assertTrue( handler.saxParseException.toString(), !handler.validationError );
+    }
+
+
+    /**
+     * Test validation of serverReplicationInterceptor.xml file
+     * 
+     * @throws Exception
+     */
+    @Ignore("Failing because 'Cannot find the declaration of element 'spring:beans'.'")
+    @Test
+    public void testValidationServerReplicationInterceptorXml() throws Exception
+    {
+        builder.parse( "file:./target/test-classes/serverReplicationInterceptor.xml" );
+
+        assertTrue( handler.saxParseException.toString(), !handler.validationError );
+    }
+
+    /**
+     * A validator handler
+     * 
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$ $Date$
+     *
+     */
+    private class Validator extends DefaultHandler
+    {
+        public boolean validationError = false;
+        public SAXParseException saxParseException = null;
+
+
+        public void error( SAXParseException exception ) throws SAXException
+        {
+            validationError = true;
+            saxParseException = exception;
+        }
+
+
+        public void fatalError( SAXParseException exception ) throws SAXException
+        {
+            validationError = true;
+            saxParseException = exception;
+        }
+
+
+        public void warning( SAXParseException exception ) throws SAXException
+        {
+        }
+    }
+}

Propchange: directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/trunk/xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message