Updated the JUnit configuration to allow for easier eclipse testing.
Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/0cda9038 Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/0cda9038 Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/0cda9038 Branch: refs/heads/master Commit: 0cda9038bf45d43ac65730f6f86bd7f578692280 Parents: 0172833 Author: Eldon Carman <[email protected]> Authored: Mon Jun 22 17:50:26 2015 -0700 Committer: Eldon Carman <[email protected]> Committed: Tue Jun 23 11:35:53 2015 -0700 ---------------------------------------------------------------------- vxquery-xtest/pom.xml | 10 ++- .../org/apache/vxquery/xtest/TestRunner.java | 3 +- .../vxquery/xtest/AbstractXQueryTest.java | 80 ++++++++++++++++++++ .../org/apache/vxquery/xtest/VXQueryTest.java | 77 +++---------------- .../org/apache/vxquery/xtest/XMarkTest.java | 55 ++++++++++++++ .../java/org/apache/vxquery/xtest/XQTSTest.java | 56 ++++++++++++++ .../Queries/XQuery/XMark/Modified/q08.xq | 2 +- 7 files changed, 214 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/pom.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/pom.xml b/vxquery-xtest/pom.xml index bab2642..6fb2798 100644 --- a/vxquery-xtest/pom.xml +++ b/vxquery-xtest/pom.xml @@ -14,7 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -114,6 +117,11 @@ <artifactId>maven-surefire-plugin</artifactId> <configuration> <!-- <argLine>-agentpath:"${yourkit.home}/bin/mac/libyjpagent.jnilib=sampling"</argLine> --> + <excludes> + <exclude>**/AbstractXQueryTest.java</exclude> + <exclude>**/XMarkTest.java</exclude> + <exclude>**/XQTSTest.java</exclude> + </excludes> </configuration> </plugin> </plugins> http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java index 1e3e4ca..8ca43e2 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java @@ -182,7 +182,8 @@ public class TestRunner { if (opts.showResult) { if (res.result == null) { System.err.println("***Error: "); - System.err.println(res.error.getStackTrace()); + System.err.println("Message: " + res.error.getMessage()); + res.error.printStackTrace(); } else { System.err.println("***Result: "); System.err.println(res.result); http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java new file mode 100644 index 0000000..4f0487a --- /dev/null +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/AbstractXQueryTest.java @@ -0,0 +1,80 @@ +/* +* 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.vxquery.xtest; + +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public abstract class AbstractXQueryTest { + private TestCase tc; + private TestRunner tr; + + protected abstract XTestOptions getTestOptions(); + + protected static XTestOptions getDefaultTestOptions() { + XTestOptions opts = new XTestOptions(); + opts.verbose = false; + opts.threads = 1; + return opts; + } + + protected static void setCatalogToTestOptions(XTestOptions opts, String catalog) { + opts.catalog = catalog; + } + + public AbstractXQueryTest(TestCase tc) throws Exception { + this.tc = tc; + tr = new TestRunner(getTestOptions()); + } + + @Before + public void beforeTest() throws Exception { + tr.open(); + } + + @Test + public void test() throws Exception { + TestCaseResult result = tr.run(tc); + switch (result.state) { + case EXPECTED_ERROR_GOT_DIFFERENT_ERROR: + case EXPECTED_ERROR_GOT_FAILURE: + case EXPECTED_ERROR_GOT_RESULT: + case EXPECTED_RESULT_GOT_DIFFERENT_RESULT: + case EXPECTED_RESULT_GOT_ERROR: + case EXPECTED_RESULT_GOT_FAILURE: + fail(result.state + " (" + result.time + " ms): " + result.testCase.getXQueryDisplayName()); + break; + case EXPECTED_ERROR_GOT_SAME_ERROR: + case EXPECTED_RESULT_GOT_SAME_RESULT: + break; + case NO_RESULT_FILE: + break; + } + } + + @After + public void afterTest() throws Exception { + tr.close(); + } + +} http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java index b889eb6..91adbbf 100644 --- a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/VXQueryTest.java @@ -16,95 +16,40 @@ */ package org.apache.vxquery.xtest; -import static org.junit.Assert.fail; - import java.io.File; import java.util.Collection; import org.apache.commons.lang3.StringUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) -public class VXQueryTest { - private TestCase tc; - private TestRunner tr; +public class VXQueryTest extends AbstractXQueryTest{ private static String VXQUERY_CATALOG = StringUtils.join(new String[] { "src", "test", "resources", "VXQueryCatalog.xml" }, File.separator); - private static String XQTS_CATALOG = StringUtils.join(new String[] { "test-suites", "xqts", "XQTSCatalog.xml" }, - File.separator); - - private static boolean includeXqtsTests() { - return new File(XQTS_CATALOG).isFile(); - } - private static XTestOptions getVXQueryOptions() { - XTestOptions opts = new XTestOptions(); - opts.catalog = VXQUERY_CATALOG; - opts.verbose = false; - opts.threads = 1; - return opts; - } - - private static XTestOptions getPreviousTestOptions() { - XTestOptions opts = new XTestOptions(); - opts.catalog = XQTS_CATALOG; - opts.previousTestResults = StringUtils.join(new String[] { "results", "xqts.txt" }, File.separator); - opts.verbose = false; - opts.threads = 1; - return opts; + public VXQueryTest(TestCase tc) throws Exception { + super(tc); } @Parameters public static Collection<Object[]> tests() throws Exception { - JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getVXQueryOptions()); + JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getOptions()); Collection<Object[]> tests = jtcf_vxquery.getList(); - if (includeXqtsTests()) { - JUnitTestCaseFactory jtcf_previous = new JUnitTestCaseFactory(getPreviousTestOptions()); - // TODO Maven fails to run when including XQTS. (Error to many open files.) - // tests.addAll(jtcf_previous.getList()); - } return tests; } - public VXQueryTest(TestCase tc) throws Exception { - this.tc = tc; - tr = new TestRunner(getVXQueryOptions()); - } - - @Before - public void beforeTest() throws Exception { - tr.open(); - } - - @Test - public void test() throws Exception { - TestCaseResult result = tr.run(tc); - switch (result.state) { - case EXPECTED_ERROR_GOT_DIFFERENT_ERROR: - case EXPECTED_ERROR_GOT_FAILURE: - case EXPECTED_ERROR_GOT_RESULT: - case EXPECTED_RESULT_GOT_DIFFERENT_RESULT: - case EXPECTED_RESULT_GOT_ERROR: - case EXPECTED_RESULT_GOT_FAILURE: - fail(result.state + " (" + result.time + " ms): " + result.testCase.getXQueryDisplayName()); - break; - case EXPECTED_ERROR_GOT_SAME_ERROR: - case EXPECTED_RESULT_GOT_SAME_RESULT: - break; - case NO_RESULT_FILE: - break; - } + public static XTestOptions getOptions() { + XTestOptions options = getDefaultTestOptions(); + setCatalogToTestOptions(options, VXQUERY_CATALOG); + return options; } - @After - public void afterTest() throws Exception { - tr.close(); + @Override + protected XTestOptions getTestOptions() { + return getOptions(); } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XMarkTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XMarkTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XMarkTest.java new file mode 100644 index 0000000..0e7838f --- /dev/null +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XMarkTest.java @@ -0,0 +1,55 @@ +/* +* 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.vxquery.xtest; + +import java.io.File; +import java.util.Collection; + +import org.apache.commons.lang3.StringUtils; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class XMarkTest extends AbstractXQueryTest { + + private static String XMARK_CATALOG = StringUtils.join(new String[] { "src", "test", "resources", + "VXQueryXMarkCatalog.xml" }, File.separator); + + public XMarkTest(TestCase tc) throws Exception { + super(tc); + } + + @Parameters + public static Collection<Object[]> tests() throws Exception { + JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getOptions()); + Collection<Object[]> tests = jtcf_vxquery.getList(); + return tests; + } + + public static XTestOptions getOptions() { + XTestOptions options = getDefaultTestOptions(); + setCatalogToTestOptions(options, XMARK_CATALOG); + return options; + } + + @Override + protected XTestOptions getTestOptions() { + return getOptions(); + } + +} http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XQTSTest.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XQTSTest.java b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XQTSTest.java new file mode 100644 index 0000000..68f00a3 --- /dev/null +++ b/vxquery-xtest/src/test/java/org/apache/vxquery/xtest/XQTSTest.java @@ -0,0 +1,56 @@ +/* +* 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.vxquery.xtest; + +import java.io.File; +import java.util.Collection; + +import org.apache.commons.lang3.StringUtils; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class XQTSTest extends AbstractXQueryTest { + + private static String XQTS_CATALOG = StringUtils.join(new String[] { "test-suites", "xqts", "XQTSCatalog.xml" }, + File.separator); + + public XQTSTest(TestCase tc) throws Exception { + super(tc); + } + + @Parameters + public static Collection<Object[]> tests() throws Exception { + JUnitTestCaseFactory jtcf_vxquery = new JUnitTestCaseFactory(getOptions()); + Collection<Object[]> tests = jtcf_vxquery.getList(); + return tests; + } + + public static XTestOptions getOptions() { + XTestOptions options = getDefaultTestOptions(); + setCatalogToTestOptions(options, XQTS_CATALOG); + options.previousTestResults = StringUtils.join(new String[] { "results", "xqts.txt" }, File.separator); + return options; + } + + @Override + protected XTestOptions getTestOptions() { + return getOptions(); + } + +} http://git-wip-us.apache.org/repos/asf/vxquery/blob/0cda9038/vxquery-xtest/src/test/resources/Queries/XQuery/XMark/Modified/q08.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/XMark/Modified/q08.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/XMark/Modified/q08.xq index fa6c1ea..1f0045a 100644 --- a/vxquery-xtest/src/test/resources/Queries/XQuery/XMark/Modified/q08.xq +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/XMark/Modified/q08.xq @@ -20,7 +20,7 @@ let $collection1 := "people" for $p in collection($collection1)/site/people/person let $a := count( - let $collection2 := "vxquery-xtest/src/test/resources/TestSources/XMarkData/closed_auctions/" + let $collection2 := "closed_auctions" for $t in collection($collection2)/site/closed_auctions/closed_auction where $t/buyer/@person = $p/@id return $t
