David Jencks schrieb:
I don't know anything about xmllint but I'd assume that for any
validation tool you'd have to tell it about all the schemas it is
supposed to know about? In this case there are 3, not just the apacheds
xbean schema, there are also 2 spring schemas, and the complaint appears
to be about one of them.
You're right. I now wrote a testcase which is run apacheds build. It still throws the same error, but I can't figure out
where my problem is :(
-------------------------------------------------------------------------------
Test set: org.apache.directory.server.ConfigurationValidationTest
-------------------------------------------------------------------------------
Tests run: 4, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 0.379 sec <<<
FAILURE!
testValidationServerXml(org.apache.directory.server.ConfigurationValidationTest) Time
elapsed: 0.302 sec <<< FAILURE!
java.lang.AssertionError: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find
the declaration of element 'spring:beans'.
at org.junit.Assert.fail(Assert.java:74)
at org.junit.Assert.assertTrue(Assert.java:37)
at
org.apache.directory.server.ConfigurationValidationTest.testValidationServerXml(ConfigurationValidationTest.java:80)
Felix
Index:
xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
===================================================================
---
xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
(Revision 0)
+++
xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
(Revision 0)
@@ -0,0 +1,190 @@
+/*
+ * 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 org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @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.0.xsd";
+ static final String springTool =
"target/test-classes/org/springframework/beans/factory/xml/spring-tool-2.0.xsd";
+ static final String springUtil =
"target/test-classes/org/springframework/beans/factory/xml/spring-util-2.0.xsd";
+ static final String xbeanSpring =
"target/test-classes/org/apache/xbean/spring/spring-beans.xsd";
+
+ static final String[] schemas = { apachedsXbeanSchema, springBeans,
+ springTool, springUtil, xbeanSpring };
+
+ /**
+ * Test validation of server.xml file
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testValidationServerXml() throws Exception {
+ 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);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Validator handler = new Validator();
+ builder.setErrorHandler(handler);
+ builder.parse("file:./target/test-classes/server.xml");
+
+ assertTrue(handler.saxParseException.toString(),
+ !handler.validationError);
+ }
+
+ /**
+ * Test validation of serverAuthenticatorInAuthenticationInterceptor.xml
+ * file
+ *
+ * @throws Exception
+ */
+ @Test
+ public void
testValidationServerAuthenticatorInAuthenticationInterceptorXml()
+ throws Exception {
+ 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);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Validator handler = new Validator();
+ builder.setErrorHandler(handler);
+ builder
+
.parse("file:./target/test-classes/serverAuthenticatorInAuthenticationInterceptor.xml");
+
+ assertTrue(handler.saxParseException.toString(),
+ !handler.validationError);
+ }
+
+ /**
+ * Test validation of serverJdbmPartition.xml file
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testValidationServerJdbmPartitionXml() throws Exception {
+ 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);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Validator handler = new Validator();
+ builder.setErrorHandler(handler);
+ builder.parse("file:./target/test-classes/serverJdbmPartition.xml");
+
+ assertTrue(handler.saxParseException.toString(),
+ !handler.validationError);
+ }
+
+ /**
+ * Test validation of serverReplicationInterceptor.xml file
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testValidationServerReplicationInterceptorXml()
+ throws Exception {
+ 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);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Validator handler = new Validator();
+ builder.setErrorHandler(handler);
+ builder
+
.parse("file:./target/test-classes/serverReplicationInterceptor.xml");
+
+ assertTrue(handler.saxParseException.toString(),
+ !handler.validationError);
+ }
+
+ 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 {
+ }
+ }
+}
Eigenschaftsänderungen:
xbean-spring/src/test/java/org/apache/directory/server/ConfigurationValidationTest.java
___________________________________________________________________
Hinzugefügt: svn:keywords
+ Author Date Id Revision
Hinzugefügt: svn:eol-style
+ native
Index: xbean-spring/pom.xml
===================================================================
--- xbean-spring/pom.xml (Revision 748796)
+++ xbean-spring/pom.xml (Arbeitskopie)
@@ -131,6 +131,13 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- replication interceptor xbean config metadata -->
<dependency>
<groupId>org.apache.directory.server</groupId>
@@ -186,6 +193,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>