Develop test for XSD validation.
diff --git a/gora-lucene/src/test/conf/gora-lucene-mapping-bad.xml b/gora-lucene/src/test/conf/gora-lucene-mapping-bad.xml
new file mode 100644
index 0000000..2d2d1c7
--- /dev/null
+++ b/gora-lucene/src/test/conf/gora-lucene-mapping-bad.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<gora-otd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="gora-lucene.xsd">
+
+ <class name="org.apache.gora.examples.generated.EmployeeInt" keyClass="java.lang.Integer">
+ <!--
+ Remove primarykey to test XSD validation.
+ <primarykey column="ssn"/>
+ -->
+ <field Name="ssn" columns="ssn"/>
+ </class>
+
+</gora-otd>
+
diff --git a/gora-lucene/src/test/java/org/apache/gora/lucene/store/TestLuceneStore.java b/gora-lucene/src/test/java/org/apache/gora/lucene/store/TestLuceneStore.java
index 9d71238..346d8a0 100644
--- a/gora-lucene/src/test/java/org/apache/gora/lucene/store/TestLuceneStore.java
+++ b/gora-lucene/src/test/java/org/apache/gora/lucene/store/TestLuceneStore.java
@@ -17,6 +17,7 @@
*/
package org.apache.gora.lucene.store;
+import java.util.Properties;
import org.apache.gora.examples.WebPageDataCreator;
import static org.apache.gora.examples.WebPageDataCreator.SORTED_URLS;
import static org.apache.gora.examples.WebPageDataCreator.URLS;
@@ -25,6 +26,7 @@
import org.apache.gora.query.Query;
import org.apache.gora.query.Result;
import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
import org.apache.gora.store.DataStoreTestBase;
import static org.apache.gora.store.DataStoreTestBase.log;
import org.apache.gora.store.DataStoreTestUtil;
@@ -52,7 +54,7 @@
setTestDriver(new TestLuceneStoreDriver());
DataStoreTestBase.setUpClass();
}
-
+
@Test(expected = AssertionError.class)
public void testSchemaExists() throws Exception {
super.testSchemaExists();
@@ -168,5 +170,17 @@
}
}
}
+
+ /**
+ * XSD Validation.
+ *
+ * Validate bad formatted XML Mappings.
+ */
+ @Test(expected = GoraException.class)
+ public void testXSDValidation() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("gora.lucenestore.mapping.file", "gora-lucene-mapping-bad.xml");
+ DataStoreTestBase.testDriver.createDataStore(String.class, EmployeeInt.class, properties);
+ }
}