diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a2eeca6bf..0d4cc2c6d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -530,12 +530,13 @@ jobs: else export JAVA_TOOL_OPTIONS="<< pipeline.parameters.java_tool_options >>" fi - $MAVEN_BIN test -Dappbundler.skip=true -Ddocker=false -P !mac-dmg-on-mac,!codesign-mac-app,!codesign-mac-dmg,!mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives + $MAVEN_BIN test integration-test -Dappbundler.skip=true -Ddocker=false -P !mac-dmg-on-mac,!codesign-mac-app,!codesign-mac-dmg,!mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives - run: name: Save test results command: | mkdir -p ~/test-results/junit/ /usr/bin/find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \; + /usr/bin/find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/test-results/junit/ \; when: always - store_test_results: path: ~/test-results diff --git a/build.bat b/build.bat index 6658cbc41c..d242a11495 100644 --- a/build.bat +++ b/build.bat @@ -95,7 +95,7 @@ if "%TARGET%"=="quick" ( ) else if "%TARGET%"=="test" ( set "CMD=%BASE_CMD% clean test -Ddependency-check.skip=true" ) else if "%TARGET%"=="site" ( - set "CMD=%BASE_CMD% clean test -Ddependency-check.skip=true" + set "CMD=%BASE_CMD% clean verify site -Ddependency-check.skip=true" ) else if "%TARGET%"=="license-check" ( set "CMD=%BASE_CMD% license:check" ) else if "%TARGET%"=="license-format" ( diff --git a/build.sh b/build.sh index 86330bb101..d5bce47c7a 100755 --- a/build.sh +++ b/build.sh @@ -141,7 +141,7 @@ if [ "${TARGET}" == "test" ]; then fi if [ "${TARGET}" == "site" ]; then - CMD="${BASE_CMD} clean site -Ddependency-check.skip=true" + CMD="${BASE_CMD} clean verify site -Ddependency-check.skip=true" $CMD exit 0; fi @@ -171,4 +171,4 @@ if [ "${TARGET}" == "dependency-security-check" ]; then fi print-useage -exit 0; \ No newline at end of file +exit 0; diff --git a/elemental-parent/pom.xml b/elemental-parent/pom.xml index f8285542cd..0dea922d7b 100644 --- a/elemental-parent/pom.xml +++ b/elemental-parent/pom.xml @@ -413,6 +413,10 @@ JRE,CLDR,SPI ${project.build.testOutputDirectory}/log4j2.xml + + **/*Test.java + **/*Tests.java + @@ -424,6 +428,11 @@ org.apache.maven.plugins maven-failsafe-plugin 3.5.3 + + + **/*IT.java + + com.github.hazendaz.maven @@ -528,6 +537,26 @@ org.apache.maven.plugins maven-surefire-plugin + + org.apache.maven.plugins + maven-failsafe-plugin + + + integration-test + integration-test + + integration-test + + + + verify + verify + + verify + + + + org.apache.maven.plugins maven-release-plugin diff --git a/exist-ant/src/test/resources/log4j2.xml b/exist-ant/src/test/resources/log4j2.xml index 5d4834fd6a..4b66772f41 100644 --- a/exist-ant/src/test/resources/log4j2.xml +++ b/exist-ant/src/test/resources/log4j2.xml @@ -231,15 +231,15 @@ - + - + - + diff --git a/exist-core/pom.xml b/exist-core/pom.xml index f6540927b8..6f6b81f322 100644 --- a/exist-core/pom.xml +++ b/exist-core/pom.xml @@ -755,9 +755,9 @@ src/test/xquery/xquery3/parse-xml.xqm src/test/xquery/xquery3/serialize.xql src/main/java/org/exist/Indexer.java + src/test/java/org/exist/Indexer2Test.java + src/test/java/org/exist/Indexer3Test.java src/test/java/org/exist/IndexerTest.java - src/test/java/org/exist/IndexerTest2.java - src/test/java/org/exist/IndexerTest3.java src/main/java/org/exist/Namespaces.java src/main/resources-filtered/org/exist/system.properties src/main/java/org/exist/backup/SystemExport.java @@ -790,23 +790,30 @@ src/main/java/org/exist/collections/Collection.java src/main/java/org/exist/collections/CollectionConfiguration.java src/main/java/org/exist/collections/CollectionConfigurationManager.java + src/test/java/org/exist/collections/CollectionStoreTest.java src/main/java/org/exist/collections/LockedCollection.java src/main/java/org/exist/collections/MutableCollection.java + src/test/java/org/exist/collections/OpenCollectionTest src/main/java/org/exist/collections/triggers/CollectionTrigger.java src/main/java/org/exist/collections/triggers/DocumentTrigger.java + src/test/java/org/exist/collections/triggers/MessagesTrigger.java + src/test/java/org/exist/collections/triggers/TriggerConfigTest.java src/main/java/org/exist/collections/triggers/XQueryStartupTrigger.java src/main/java/org/exist/config/Configuration.java src/main/java/org/exist/config/ConfigurationImpl.java src/main/java/org/exist/config/Configurator.java + src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocksTest.java src/main/java/org/exist/dom/NodeListImpl.java src/main/java/org/exist/dom/QName.java src/main/java/org/exist/dom/memtree/AbstractCharacterData.java src/main/java/org/exist/dom/memtree/AttrImpl.java src/main/java/org/exist/dom/memtree/DocumentImpl.java + src/test/java/org/exist/dom/memtree/DocumentImplTest.java src/main/java/org/exist/dom/memtree/DOMIndexer.java src/test/java/org/exist/dom/memtree/DOMIndexerTest.java src/test/java/org/exist/dom/memtree/DOMTest.java src/main/java/org/exist/dom/memtree/ElementImpl.java + src/test/java/org/exist/dom/memtree/MemtreeInXQueryTest.java src/main/java/org/exist/dom/memtree/MemTreeBuilder.java src/main/java/org/exist/dom/memtree/NamespaceNode.java src/main/java/org/exist/dom/memtree/NodeImpl.java @@ -815,6 +822,7 @@ src/main/java/org/exist/dom/persistent/AttrImpl.java src/main/java/org/exist/dom/persistent/BinaryDocument.java src/main/java/org/exist/dom/persistent/CommentImpl.java + src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java src/main/java/org/exist/dom/persistent/DocumentImpl.java src/main/java/org/exist/dom/persistent/DocumentMetadata.java src/main/java/org/exist/dom/persistent/DocumentTypeImpl.java @@ -896,6 +904,8 @@ src/test/java/org/exist/storage/BFileRecoverTest.java src/main/java/org/exist/storage/BrokerFactory.java src/main/java/org/exist/storage/BrokerPool.java + src/test/java/org/exist/storage/BrokerPoolsTest.java + src/test/java/org/exist/storage/BrokerPoolTest.java src/test/java/org/exist/storage/CollectionTest.java src/test/java/org/exist/storage/CopyResourceTest.java src/main/java/org/exist/storage/DBBroker.java @@ -907,8 +917,9 @@ src/main/java/org/exist/storage/NodePath.java src/test/java/org/exist/storage/NodePathTest.java src/main/java/org/exist/storage/ProcessMonitor.java + src/test/java/org/exist/storage/RecoverBinary2Test.java src/test/java/org/exist/storage/RecoveryTest.java - src/test/java/org/exist/storage/RecoveryTest2.java + src/test/java/org/exist/storage/Recovery2Test.java src/main/java/org/exist/storage/StorageAddress.java src/test/java/org/exist/storage/btree/BTreeTest.java src/main/java/org/exist/storage/btree/TreeMetrics.java @@ -924,17 +935,29 @@ src/main/java/org/exist/storage/serializers/Serializer.java src/test/resources-filtered/org/exist/storage/statistics/conf.xml src/main/java/org/exist/storage/sync/SyncTask.java + src/test/java/org/exist/storage/util/PauseFunction.java src/main/java/org/exist/test/ExistXmldbEmbeddedServer.java + src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java + src/main/java/org/exist/test/runner/ExtTestErrorFunction.java src/main/java/org/exist/test/runner/ExtTestFailureFunction.java + src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java + src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java + src/main/java/org/exist/test/runner/ExtTestStartedFunction.java + src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java src/main/java/org/exist/test/runner/XMLTestRunner.java src/main/java/org/exist/test/runner/XQueryTestRunner.java src/main/java/org/exist/test/runner/XSuite.java src/test/java/org/exist/util/AbstractXMLReaderSecurityTest.java src/main/java/org/exist/util/Collations.java + src/test/java/org/exist/util/CollationsTest.java src/main/java/org/exist/util/Configuration.java src/test/java/org/exist/util/DOMSerializerTest.java + src/test/java/org/exist/util/LeasableTest.java src/main/java/org/exist/util/ParametersExtractor.java src/main/java/org/exist/util/crypto/digest/DigestType.java + src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java + src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java + src/test/java/org/exist/util/pool/NodePoolTest.java src/main/java/org/exist/util/serializer/AttrList.java src/main/java/org/exist/util/serializer/DOMStreamer.java src/main/java/org/exist/util/serializer/EXISerializer.java @@ -945,6 +968,12 @@ src/test/java/org/exist/util/serializer/json/JSONObjectTest.java src/main/java/org/exist/util/serializer/json/JSONSerializer.java src/test/java/org/exist/util/serializer/json/JSONWriterTest.java + src/test/java/org/exist/util/sorters/ListChecker.java + src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java + src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java + src/test/java/org/exist/util/sorters/NodeProxyChecker.java + src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java + src/test/java/org/exist/util/sorters/PlainArrayChecker.java src/test/java/org/exist/util/sorters/SortTestNodeId.java src/test/resources/org/exist/validation/catalog.xml src/test/java/org/exist/validation/CollectionConfigurationValidationModeTest.java @@ -953,19 +982,35 @@ src/main/java/org/exist/webstart/JnlpJarFiles.java src/test/java/org/exist/xmldb/ContentAsDOMTest.java src/test/java/org/exist/xmldb/CreateCollectionsTest.java + src/test/java/org/exist/xmldb/EXistXMLSerializeTest.java src/test/java/org/exist/xmldb/IndexingTest.java src/main/java/org/exist/xmldb/LocalResourceSet.java src/main/java/org/exist/xmldb/LocalXMLResource.java src/main/java/org/exist/xmldb/RemoteRestoreService.java + src/test/java/org/exist/xmldb/RemoteDOMTest.java src/test/java/org/exist/xmldb/ResourceTest.java src/test/java/org/exist/xmldb/SerializationTest.java - src/test/java/org/exist/xmldb/TestEXistXMLSerialize.java src/test/java/org/exist/xmldb/TreeLevelOrderTest.java + src/test/java/org/exist/xmldb/concurrent/AbstractConcurrentTest.java + src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentResource2Test.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/DBUtils.java + src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java + src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java src/test/java/org/exist/xmldb/concurrent/XMLGenerator.java + src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java src/main/java/org/exist/xmlrpc/ExistRpcTypeFactory.java src/main/java/org/exist/xmlrpc/RpcConnection.java src/main/java/org/exist/xqj/Marshaller.java src/test/java/org/exist/xqj/MarshallerTest.java + src/test/java/org/exist/xquery/CardinalityTest.java + src/test/java/org/exist/xquery/CleanupTest.java src/main/java/org/exist/xquery/CombiningExpression.java src/test/java/org/exist/xquery/ConstructedNodesRecoveryTest.java src/main/java/org/exist/xquery/DeferredFunctionCall.java @@ -982,9 +1027,12 @@ src/main/java/org/exist/xquery/PerformanceStats.java src/main/java/org/exist/xquery/TryCatchExpression.java src/main/java/org/exist/xquery/UserDefinedFunction.java + src/test/java/org/exist/xquery/XmldbBinariesTest.java + src/test/java/org/exist/xquery/XPathOpOrSpecialCaseTest.java src/main/java/org/exist/xquery/XPathUtil.java src/main/java/org/exist/xquery/XQueryContext.java src/test/java/org/exist/xquery/XQueryFunctionsTest.java + src/test/java/org/exist/xquery/XQueryProcessingInstructionTest.java src/test/java/org/exist/xquery/XQueryTest.java src/main/java/org/exist/xquery/functions/array/ArrayType.java src/test/java/org/exist/xquery/functions/fn/DocTest.java @@ -1107,25 +1155,37 @@ src/main/java/org/exist/xquery/functions/util/FunctionFunction.java src/main/java/org/exist/xquery/functions/util/LogFunction.java src/main/java/org/exist/xquery/functions/util/ModuleInfo.java + src/test/java/org/exist/xquery/functions/validate/JaxvTest.java src/main/java/org/exist/xquery/functions/validation/Jaxp.java + src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java src/main/java/org/exist/xquery/functions/xmldb/XMLDBStore.java src/main/java/org/exist/xquery/functions/xmldb/XMLDBXUpdate.java src/main/antlr/org/exist/xquery/parser/XQueryTree.g src/main/java/org/exist/xquery/pragmas/Optimize.java + src/test/java/org/exist/xquery/update/AbstractUpdateTest.java + src/test/java/org/exist/xquery/update/IndexIntegrationTest.java + src/test/java/org/exist/xquery/update/UpdateInsertTest.java src/test/java/org/exist/xquery/update/UpdateReplaceTest.java + src/test/java/org/exist/xquery/update/UpdateValueTest.java src/main/java/org/exist/xquery/util/ExpressionDumper.java src/main/java/org/exist/xquery/util/SerializerUtils.java src/main/java/org/exist/xquery/value/AbstractDateTimeValue.java + src/main/java/org/exist/xquery/value/AbstractTimeRelatedTest.java src/main/java/org/exist/xquery/value/AnyURIValue.java src/test/java/org/exist/xquery/value/Base64BinaryValueTypeTest.java src/main/java/org/exist/xquery/value/BinaryValue.java src/main/java/org/exist/xquery/value/BooleanValue.java + src/test/java/org/exist/xquery/value/DateTest.java + src/test/java/org/exist/xquery/value/DateTimeStampTest.java src/main/java/org/exist/xquery/value/DateTimeStampValue.java + src/test/java/org/exist/xquery/value/DateTimeTest.java src/main/java/org/exist/xquery/value/DateTimeValue.java src/main/java/org/exist/xquery/value/DateValue.java + src/test/java/org/exist/xquery/value/DayTimeDurationTest.java src/main/java/org/exist/xquery/value/DayTimeDurationValue.java src/main/java/org/exist/xquery/value/DecimalValue.java src/main/java/org/exist/xquery/value/DoubleValue.java + src/test/java/org/exist/xquery/value/DurationTest.java src/main/java/org/exist/xquery/value/DurationValue.java src/main/java/org/exist/xquery/value/FloatValue.java src/main/java/org/exist/xquery/value/GDayValue.java @@ -1136,7 +1196,9 @@ src/main/java/org/exist/xquery/value/IntegerValue.java src/main/java/org/exist/xquery/value/QNameValue.java src/main/java/org/exist/xquery/value/StringValue.java + src/test/java/org/exist/xquery/value/TimeTest.java src/main/java/org/exist/xquery/value/TimeValue.java + src/test/java/org/exist/xquery/value/YearMonthDurationTest.java src/main/java/org/exist/xquery/value/YearMonthDurationValue.java src/main/java/org/exist/xquery/value/SequenceType.java src/main/java/org/exist/xquery/value/TimeUtils.java @@ -1182,9 +1244,9 @@ src/test/xquery/xquery3/postfix-expr.xqm src/test/xquery/xquery3/serialize.xql src/main/java/org/exist/Indexer.java + src/test/java/org/exist/Indexer2Test.java + src/test/java/org/exist/Indexer3Test.java src/test/java/org/exist/IndexerTest.java - src/test/java/org/exist/IndexerTest2.java - src/test/java/org/exist/IndexerTest3.java src/main/java/org/exist/Namespaces.java src/main/resources-filtered/org/exist/system.properties src/main/java/org/exist/backup/SystemExport.java @@ -1217,24 +1279,31 @@ src/main/java/org/exist/collections/Collection.java src/main/java/org/exist/collections/CollectionConfiguration.java src/main/java/org/exist/collections/CollectionConfigurationManager.java + src/test/java/org/exist/collections/CollectionStoreTest.java src/main/java/org/exist/collections/LockedCollection.java src/main/java/org/exist/collections/MutableCollection.java + src/test/java/org/exist/collections/OpenCollectionTest src/main/java/org/exist/collections/triggers/CollectionTrigger.java src/main/java/org/exist/collections/triggers/DocumentTrigger.java + src/test/java/org/exist/collections/triggers/MessagesTrigger.java + src/test/java/org/exist/collections/triggers/TriggerConfigTest.java src/main/java/org/exist/collections/triggers/XQueryStartupTrigger.java src/main/java/org/exist/config/Configuration.java src/main/java/org/exist/config/ConfigurationImpl.java src/main/java/org/exist/config/Configurator.java + src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocksTest.java src/main/java/org/exist/dom/NodeListImpl.java src/main/java/org/exist/dom/QName.java src/main/java/org/exist/dom/memtree/AbstractCharacterData.java src/main/java/org/exist/dom/memtree/AttrImpl.java src/main/java/org/exist/dom/memtree/DocumentImpl.java + src/test/java/org/exist/dom/memtree/DocumentImplTest.java src/main/java/org/exist/dom/memtree/DocumentTypeImpl.java src/main/java/org/exist/dom/memtree/DOMIndexer.java src/test/java/org/exist/dom/memtree/DOMIndexerTest.java src/test/java/org/exist/dom/memtree/DOMTest.java src/main/java/org/exist/dom/memtree/ElementImpl.java + src/test/java/org/exist/dom/memtree/MemtreeInXQueryTest.java src/main/java/org/exist/dom/memtree/MemTreeBuilder.java src/main/java/org/exist/dom/memtree/NamespaceNode.java src/main/java/org/exist/dom/memtree/NodeImpl.java @@ -1249,6 +1318,7 @@ src/main/java/org/exist/dom/persistent/AttrImpl.java src/main/java/org/exist/dom/persistent/BinaryDocument.java src/main/java/org/exist/dom/persistent/CommentImpl.java + src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java src/main/java/org/exist/dom/persistent/DocumentImpl.java src/main/java/org/exist/dom/persistent/DocumentMetadata.java src/main/java/org/exist/dom/persistent/DocumentSet.java @@ -1340,6 +1410,8 @@ src/main/java/org/exist/storage/BrokerPoolServicesManager.java src/main/java/org/exist/storage/BrokerPoolServicesManagerException.java src/test/java/org/exist/storage/BrokerPoolServiceTest.java + src/test/java/org/exist/storage/BrokerPoolsTest.java + src/test/java/org/exist/storage/BrokerPoolTest.java src/test/java/org/exist/storage/CollectionTest.java src/test/java/org/exist/storage/CopyResourceTest.java src/main/java/org/exist/storage/DBBroker.java @@ -1354,9 +1426,10 @@ src/test/java/org/exist/storage/NodePathTest.java src/main/java/org/exist/storage/ProcessMonitor.java src/test/java/org/exist/storage/RecoverBinaryTest.java + src/test/java/org/exist/storage/RecoverBinary2Test.java src/test/java/org/exist/storage/RecoverXmlTest.java src/test/java/org/exist/storage/RecoveryTest.java - src/test/java/org/exist/storage/RecoveryTest2.java + src/test/java/org/exist/storage/Recovery2Test.java src/main/java/org/exist/storage/StorageAddress.java src/main/java/org/exist/storage/XQueryPool.java src/main/java/org/exist/storage/blob/** @@ -1406,6 +1479,7 @@ src/main/java/org/exist/storage/serializers/Serializer.java src/test/resources-filtered/org/exist/storage/statistics/conf.xml src/main/java/org/exist/storage/sync/SyncTask.java + src/test/java/org/exist/storage/util/PauseFunction.java src/test/java/org/exist/storage/txn/ConcurrentTransactionsTest.java src/test/java/org/exist/storage/txn/CountingTxnListener.java src/test/java/org/exist/storage/txn/ReusableTxnTest.java @@ -1415,25 +1489,36 @@ src/main/java/org/exist/test/DiffMatcher.java src/main/java/org/exist/test/ExistXmldbEmbeddedServer.java src/test/java/org/exist/test/Util.java + src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java + src/main/java/org/exist/test/runner/ExtTestErrorFunction.java src/main/java/org/exist/test/runner/ExtTestFailureFunction.java + src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java + src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java + src/main/java/org/exist/test/runner/ExtTestStartedFunction.java + src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java src/main/java/org/exist/test/runner/XMLTestRunner.java src/main/java/org/exist/test/runner/XQueryTestRunner.java src/main/java/org/exist/test/runner/XSuite.java src/test/java/org/exist/util/AbstractXMLReaderSecurityTest.java src/main/java/org/exist/util/ByteOrderMark.java src/main/java/org/exist/util/Collations.java + src/test/java/org/exist/util/CollationsTest.java src/main/java/org/exist/util/CollectionOfArrayIterator.java src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java src/main/java/org/exist/util/Configuration.java src/test/java/org/exist/util/DOMSerializerTest.java src/main/java/org/exist/util/IPUtil.java src/main/java/org/exist/util/JREUtil.java + src/test/java/org/exist/util/LeasableTest.java src/main/java/org/exist/util/MapUtil.java src/main/java/org/exist/util/OSUtil.java src/main/java/org/exist/util/ParametersExtractor.java src/main/java/org/exist/util/StringUtil.java src/main/java/org/exist/util/UTF8.java src/main/java/org/exist/util/crypto/digest/DigestType.java + src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java + src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java + src/test/java/org/exist/util/pool/NodePoolTest.java src/main/java/org/exist/util/serializer/AttrList.java src/main/java/org/exist/util/serializer/DOMStreamer.java src/main/java/org/exist/util/serializer/EXISerializer.java @@ -1445,6 +1530,12 @@ src/test/java/org/exist/util/serializer/json/JSONObjectTest.java src/main/java/org/exist/util/serializer/json/JSONSerializer.java src/test/java/org/exist/util/serializer/json/JSONWriterTest.java + src/test/java/org/exist/util/sorters/ListChecker.java + src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java + src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java + src/test/java/org/exist/util/sorters/NodeProxyChecker.java + src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java + src/test/java/org/exist/util/sorters/PlainArrayChecker.java src/test/java/org/exist/util/sorters/SortTestNodeId.java src/test/resources/org/exist/validation/catalog.xml src/test/java/org/exist/validation/CollectionConfigurationValidationModeTest.java @@ -1453,15 +1544,29 @@ src/main/java/org/exist/webstart/JnlpJarFiles.java src/test/java/org/exist/xmldb/ContentAsDOMTest.java src/test/java/org/exist/xmldb/CreateCollectionsTest.java + src/test/java/org/exist/xmldb/EXistXMLSerializeTest.java src/test/java/org/exist/xmldb/IndexingTest.java src/main/java/org/exist/xmldb/LocalResourceSet.java src/main/java/org/exist/xmldb/LocalXMLResource.java src/main/java/org/exist/xmldb/RemoteRestoreService.java + src/test/java/org/exist/xmldb/RemoteDOMTest.java src/test/java/org/exist/xmldb/ResourceTest.java src/test/java/org/exist/xmldb/SerializationTest.java - src/test/java/org/exist/xmldb/TestEXistXMLSerialize.java src/test/java/org/exist/xmldb/TreeLevelOrderTest.java + src/test/java/org/exist/xmldb/concurrent/AbstractConcurrentTest.java + src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentResource2Test.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java + src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/DBUtils.java + src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java + src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java + src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java src/test/java/org/exist/xmldb/concurrent/XMLGenerator.java + src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java src/main/java/org/exist/xmlrpc/ACEAiderParser.java src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java src/main/java/org/exist/xmlrpc/ExistRpcTypeFactory.java @@ -1469,6 +1574,9 @@ src/main/java/org/exist/xqj/Marshaller.java src/test/java/org/exist/xqj/MarshallerTest.java src/main/java/org/exist/xquery/Cardinality.java + src/test/java/org/exist/xquery/CardinalityTest.java + src/test/java/org/exist/xquery/CastExpressionTest.java + src/test/java/org/exist/xquery/CleanupTest.java src/main/java/org/exist/xquery/CombiningExpression.java src/test/java/org/exist/xquery/ConstructedNodesRecoveryTest.java src/main/java/org/exist/xquery/DeferredFunctionCall.java @@ -1495,10 +1603,14 @@ src/main/java/org/exist/xquery/TryCatchExpression.java src/main/java/org/exist/xquery/UserDefinedFunction.java src/test/java/org/exist/xquery/WatchdogTest.java + src/test/java/org/exist/xquery/WindowClauseTest.java + src/test/java/org/exist/xquery/XmldbBinariesTest.java + src/test/java/org/exist/xquery/XPathOpOrSpecialCaseTest.java src/main/java/org/exist/xquery/XPathUtil.java src/main/java/org/exist/xquery/XQueryContext.java src/test/java/org/exist/xquery/XQueryContextAttributesTest.java src/test/java/org/exist/xquery/XQueryFunctionsTest.java + src/test/java/org/exist/xquery/XQueryProcessingInstructionTest.java src/test/java/org/exist/xquery/XQueryTest.java src/main/java/org/exist/xquery/functions/array/ArrayType.java src/main/java/org/exist/xquery/functions/fn/ExtCollection.java @@ -1631,8 +1743,10 @@ src/main/java/org/exist/xquery/functions/util/FunctionFunction.java src/main/java/org/exist/xquery/functions/util/LogFunction.java src/main/java/org/exist/xquery/functions/util/ModuleInfo.java + src/test/java/org/exist/xquery/functions/validate/JaxvTest.java src/main/java/org/exist/xquery/functions/validation/Jaxp.java src/test/java/org/exist/xquery/functions/xmldb/AbstractXMLDBTest.java + src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java src/test/java/org/exist/xquery/functions/xmldb/XMLDBAuthenticateTest.java src/main/java/org/exist/xquery/functions/xmldb/XMLDBStore.java src/test/java/org/exist/xquery/functions/xmldb/XMLDBStoreTest.java @@ -1641,11 +1755,16 @@ src/main/antlr/org/exist/xquery/parser/XQueryTree.g src/main/java/org/exist/xquery/pragmas/Optimize.java src/main/java/org/exist/xquery/pragmas/TimePragma.java + src/test/java/org/exist/xquery/update/AbstractUpdateTest.java + src/test/java/org/exist/xquery/update/IndexIntegrationTest.java + src/test/java/org/exist/xquery/update/UpdateInsertTest.java src/test/java/org/exist/xquery/update/UpdateReplaceTest.java + src/test/java/org/exist/xquery/update/UpdateValueTest.java src/main/java/org/exist/xquery/util/ExpressionDumper.java src/main/java/org/exist/xquery/util/SerializerUtils.java src/test/java/org/exist/xquery/util/URIUtilsTest.java src/main/java/org/exist/xquery/value/AbstractDateTimeValue.java + src/main/java/org/exist/xquery/value/AbstractTimeRelatedTest.java src/main/java/org/exist/xquery/value/AnyURIValue.java src/main/java/org/exist/xquery/value/ArrayListValueSequence.java src/main/java/org/exist/xquery/value/AtomicValueComparator.java @@ -1653,13 +1772,18 @@ src/test/java/org/exist/xquery/value/BifurcanMapTest.java src/main/java/org/exist/xquery/value/BinaryValue.java src/main/java/org/exist/xquery/value/BooleanValue.java + src/test/java/org/exist/xquery/value/DateTest.java + src/test/java/org/exist/xquery/value/DateTimeStampTest.java src/main/java/org/exist/xquery/value/DateTimeStampValue.java + src/test/java/org/exist/xquery/value/DateTimeTest.java src/test/java/org/exist/xquery/value/DateTimeTypesTest.java src/main/java/org/exist/xquery/value/DateTimeValue.java src/main/java/org/exist/xquery/value/DateValue.java + src/test/java/org/exist/xquery/value/DayTimeDurationTest.java src/main/java/org/exist/xquery/value/DayTimeDurationValue.java src/main/java/org/exist/xquery/value/DecimalValue.java src/main/java/org/exist/xquery/value/DoubleValue.java + src/test/java/org/exist/xquery/value/DurationTest.java src/main/java/org/exist/xquery/value/DurationValue.java src/main/java/org/exist/xquery/value/FloatValue.java src/main/java/org/exist/xquery/value/GDayValue.java @@ -1676,9 +1800,11 @@ src/main/java/org/exist/xquery/value/SubSequence.java src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java src/test/java/org/exist/xquery/value/SubSequenceTest.java + src/test/java/org/exist/xquery/value/TimeTest.java src/main/java/org/exist/xquery/value/TimeValue.java src/main/java/org/exist/xquery/value/TimeUtils.java src/main/java/org/exist/xquery/value/Type.java + src/test/java/org/exist/xquery/value/YearMonthDurationTest.java src/main/java/org/exist/xquery/value/YearMonthDurationValue.java src/main/java/org/exist/xslt/EXistURIResolver.java src/main/java/org/exist/xslt/XsltURIResolverHelper.java @@ -1703,7 +1829,7 @@ src/main/java/org/exist/util/io/ByteBufferAccessor.java src/main/java/org/exist/util/io/ByteBufferInputStream.java src/main/java/org/exist/util/io/CachingFilterInputStream.java - src/test/java/org/exist/util/io/CachingFilterInputStreamTest_NonMarkableByteArrayInputStream.java + src/test/java/org/exist/util/io/CachingFilterInputStreamNonMarkableByteArrayInputStreamTest.java src/main/java/org/exist/util/io/FileFilterInputStreamCache.java src/main/java/org/exist/util/io/FilterInputStreamCache.java src/main/java/org/exist/util/io/FilterInputStreamCacheFactory.java @@ -1746,7 +1872,7 @@ The original license statement is also included below.]]> src/main/java/org/exist/util/io/ByteBufferAccessor.java src/main/java/org/exist/util/io/ByteBufferInputStream.java src/main/java/org/exist/util/io/CachingFilterInputStream.java - src/test/java/org/exist/util/io/CachingFilterInputStreamTest_NonMarkableByteArrayInputStream.java + src/test/java/org/exist/util/io/CachingFilterInputStreamNonMarkableByteArrayInputStreamTest.java src/main/java/org/exist/util/io/FileFilterInputStreamCache.java src/main/java/org/exist/util/io/FilterInputStreamCache.java src/main/java/org/exist/util/io/FilterInputStreamCacheFactory.java @@ -1818,6 +1944,7 @@ The original license statement is also included below.]]> src/main/java/org/exist/xmlrpc/ACEAiderParser.java src/main/java/org/exist/xmlrpc/ACEAiderSerializer.java src/main/java/org/exist/xquery/Cardinality.java + src/test/java/org/exist/xquery/CastExpressionTest.java src/test/java/org/exist/xquery/ImportModuleTest.java src/main/java/org/exist/xquery/Materializable.java src/test/java/org/exist/xquery/XQueryContextAttributesTest.java @@ -1998,10 +2125,6 @@ The BaseX Team. The original license statement is also included below.]]>org.exist.collections.ConcurrencyTest org.exist.xmldb.concurrent.FragmentsTest - - org.exist.xmldb.concurrent.ConcurrentResourceTest2 - org.exist.xmldb.concurrent.ConcurrentResourceTest3 - org.exist.http.underheavyload.DatabaseUnderLoadTest org.exist.storage.lock.DeadlockTest @@ -2111,10 +2234,6 @@ The BaseX Team. The original license statement is also included below.]]>org.exist.collections.ConcurrencyTest org.exist.xmldb.concurrent.FragmentsTest - - org.exist.xmldb.concurrent.ConcurrentResourceTest2 - org.exist.xmldb.concurrent.ConcurrentResourceTest3 - org.exist.http.underheavyload.DatabaseUnderLoadTest org.exist.storage.lock.DeadlockTest diff --git a/exist-core/src/main/java/org/exist/storage/recovery/RecoveryManager.java b/exist-core/src/main/java/org/exist/storage/recovery/RecoveryManager.java index 1d3153f6a0..78c0790df1 100644 --- a/exist-core/src/main/java/org/exist/storage/recovery/RecoveryManager.java +++ b/exist-core/src/main/java/org/exist/storage/recovery/RecoveryManager.java @@ -325,10 +325,10 @@ private void doRecovery(final int txnCount, final Path last, final JournalReader } catch (final Exception e) { LOG.error("Exception caught while redoing transactions. Aborting recovery to avoid possible damage. " + "Before starting again, make sure to run a check via the emergency export tool.", e); - if (next != null) - { - LOG.info("Log entry that caused the exception: {}", next.dump());} - throw new LogException("Recovery aborted. "); + if (next != null) { + LOG.info("Log entry that caused the exception: {}", next.dump()); + } + throw new LogException("Recovery aborted: " + e.getMessage(), e); } finally { LOG.info("Redo processed {} out of {} transactions.", redoCnt, txnCount); } @@ -375,10 +375,10 @@ private void doRecovery(final int txnCount, final Path last, final JournalReader } } catch (final Exception e) { LOG.warn("Exception caught while undoing dirty transactions. Remaining transactions to be undone: {}. Aborting recovery to avoid possible damage. Before starting again, make sure to run a check via the emergency export tool.", runningTxns.size(), e); - if (next != null) - { - LOG.warn("Log entry that caused the exception: {}", next.dump());} - throw new LogException("Recovery aborted", e); + if (next != null) { + LOG.warn("Log entry that caused the exception: {}", next.dump()); + } + throw new LogException("Recovery aborted: " + e.getMessage(), e); } } } finally { diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java index febafc9a1c..0b68ee73e9 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestAssumptionFailedFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; import org.exist.xquery.XPathException; @@ -34,11 +57,16 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; +import javax.annotation.Nullable; + import static org.exist.xquery.FunctionDSL.optParam; import static org.exist.xquery.FunctionDSL.param; import static org.exist.xquery.FunctionDSL.params; public class ExtTestAssumptionFailedFunction extends JUnitIntegrationFunction { + + private static final StringValue NAME_MAP_KEY = new StringValue("name"); + public ExtTestAssumptionFailedFunction(final XQueryContext context, final String parentName, final RunNotifier notifier) { super("ext-test-assumption-failed-function", params( @@ -49,47 +77,41 @@ public ExtTestAssumptionFailedFunction(final XQueryContext context, final String @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 2) { + throw new XPathException(this, "ext-test-assumption-failed-function requires 2 parameters"); + } - final Sequence arg2 = getCurrentArguments().length == 2 ? getCurrentArguments()[1] : null; - final MapType assumption = arg2 != null ? (MapType)arg2.itemAt(0) : null; + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-assumption-failed-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); + + final Sequence argAssumptionError = args[1]; + @Nullable final MapType assumptionError = argAssumptionError.isEmpty() ? null : (MapType) argAssumptionError.itemAt(0); final Description description = createTestDescription(name); // notify JUnit try { - final AssumptionViolatedException assumptionFailureReason = assumptionMapAsAssumptionViolationException(assumption); + final AssumptionViolatedException assumptionFailureReason = assumptionMapAsAssumptionViolationException(assumptionError); // NOTE: We remove the StackTrace, because it is not useful to have a Java Stack Trace pointing into the XML XQuery Test Suite code assumptionFailureReason.setStackTrace(new StackTraceElement[0]); notifier.fireTestAssumptionFailed(new Failure(description, assumptionFailureReason)); - } catch (final XPathException e) { + } catch (final Throwable t) { //signal internal failure - notifier.fireTestFailure(new Failure(description, e)); + notifier.fireTestFailure(new Failure(description, t)); } return Sequence.EMPTY_SEQUENCE; } - public AssumptionViolatedException assumptionMapAsAssumptionViolationException(final MapType assumptionMap) throws XPathException { - final Sequence seqName = assumptionMap.get(new StringValue(this, "name")); - final String name; - if(seqName != null && !seqName.isEmpty()) { - name = seqName.itemAt(0).getStringValue(); - } else { - name = ""; - } - - final Sequence seqValue = assumptionMap.get(new StringValue(this, "value")); - final String value; - if(seqValue != null && !seqValue.isEmpty()) { - value = seqValue.itemAt(0).getStringValue(); - } else { - value = ""; - } - + public AssumptionViolatedException assumptionMapAsAssumptionViolationException(final MapType assumptionMap) { + final String name = safeGetMapStringValue(NAME_MAP_KEY, assumptionMap, ""); + final String value = safeGetMapStringValue(VALUE_MAP_KEY, assumptionMap, ""); return new AssumptionViolatedException("Assumption %" + name + " does not hold for: " + value); } } diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestErrorFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestErrorFunction.java index 76d571427d..75414add64 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestErrorFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestErrorFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; import org.exist.xquery.ErrorCodes; @@ -40,6 +63,12 @@ public class ExtTestErrorFunction extends JUnitIntegrationFunction { + private static final StringValue DESCRIPTION_MAP_KEY = new StringValue("description"); + private static final StringValue CODE_MAP_KEY = new StringValue("code"); + private static final StringValue LINE_NUMBER_MAP_KEY = new StringValue("line-number"); + private static final StringValue COLUMN_NUMBER_MAP_KEY = new StringValue("column-number"); + private static final StringValue JAVA_STACK_TRACE_MAP_KEY = new StringValue("java-stack-trace"); + public ExtTestErrorFunction(final XQueryContext context, final String parentName, final RunNotifier notifier) { super("ext-test-error-function", params( @@ -50,36 +79,45 @@ public ExtTestErrorFunction(final XQueryContext context, final String parentName @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 2) { + throw new XPathException(this, "ext-test-error-function requires 2 parameters"); + } + + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-error-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); - final Sequence arg2 = getCurrentArguments().length == 2 ? getCurrentArguments()[1] : null; - final MapType error = arg2 != null ? (MapType)arg2.itemAt(0) : null; + final Sequence argError = args[1]; + @Nullable final MapType error = argError.isEmpty() ? null : (MapType) argError.itemAt(0); final Description description = createTestDescription(name); // notify JUnit try { - final XPathException errorReason = errorMapAsXPathException(error); - notifier.fireTestFailure(new Failure(description, errorReason)); - } catch (final XPathException e) { + final Failure failure; + if (error != null) { + final XPathException errorReason = errorMapAsXPathException(error); + failure = new Failure(description, errorReason); + } else { + failure = new Failure(description, new XPathException(this, "No error map provided to ext-test-error-function")); + } + notifier.fireTestFailure(failure); + } catch (final Throwable t) { //signal internal failure - notifier.fireTestFailure(new Failure(description, e)); + notifier.fireTestFailure(new Failure(description, t)); } return Sequence.EMPTY_SEQUENCE; } - private XPathException errorMapAsXPathException(final MapType errorMap) throws XPathException { - final Sequence seqDescription = errorMap.get(new StringValue(this, "description")); - final String description; - if(seqDescription != null && !seqDescription.isEmpty()) { - description = seqDescription.itemAt(0).getStringValue(); - } else { - description = ""; - } + private XPathException errorMapAsXPathException(final MapType errorMap) { + final Sequence seqDescription = errorMap.get(DESCRIPTION_MAP_KEY); + final String description = safeGetMapStringValue(DESCRIPTION_MAP_KEY, errorMap, ""); - final Sequence seqErrorCode = errorMap.get(new StringValue(this, "code")); + final Sequence seqErrorCode = errorMap.get(CODE_MAP_KEY); final ErrorCodes.ErrorCode errorCode; if(seqErrorCode != null && !seqErrorCode.isEmpty()) { errorCode = new ErrorCodes.ErrorCode(((QNameValue)seqErrorCode.itemAt(0)).getQName(), description); @@ -87,30 +125,21 @@ private XPathException errorMapAsXPathException(final MapType errorMap) throws X errorCode = ErrorCodes.ERROR; } - final Sequence seqLineNumber = errorMap.get(new StringValue(this, "line-number")); - final int lineNumber; - if(seqLineNumber != null && !seqLineNumber.isEmpty()) { - lineNumber = seqLineNumber.itemAt(0).toJavaObject(int.class); - } else { - lineNumber = -1; - } + final Sequence seqLineNumber = errorMap.get(LINE_NUMBER_MAP_KEY); + final int lineNumber = safeGetIntValue(seqLineNumber, 0); - final Sequence seqColumnNumber = errorMap.get(new StringValue(this, "column-number")); - final int columnNumber; - if(seqColumnNumber != null && !seqColumnNumber.isEmpty()) { - columnNumber = seqColumnNumber.itemAt(0).toJavaObject(int.class); - } else { - columnNumber = -1; + final Sequence seqColumnNumber = errorMap.get(COLUMN_NUMBER_MAP_KEY); + final int columnNumber = safeGetIntValue(seqColumnNumber, 0); + + @Nullable StackTraceElement[] stackTraceElements = null; + @Nullable final Sequence seqJavaStackTrace = errorMap.get(JAVA_STACK_TRACE_MAP_KEY); + if (seqJavaStackTrace != null && !seqJavaStackTrace.isEmpty()) { + stackTraceElements = convertStackTraceElements(seqJavaStackTrace); } final XPathException xpe = new XPathException(lineNumber, columnNumber, errorCode, description); - - @Nullable final Sequence seqJavaStackTrace = errorMap.get(new StringValue(this, "java-stack-trace")); - if (seqJavaStackTrace != null && !seqJavaStackTrace.isEmpty()) { - @Nullable final StackTraceElement[] stackTraceElements = convertStackTraceElements(seqJavaStackTrace); - if (stackTraceElements != null) { - xpe.setStackTrace(stackTraceElements); - } + if (stackTraceElements != null) { + xpe.setStackTrace(stackTraceElements); } return xpe; @@ -119,7 +148,7 @@ private XPathException errorMapAsXPathException(final MapType errorMap) throws X private static final Pattern PTN_CAUSED_BY = Pattern.compile("Caused by:\\s([a-zA-Z0-9_$\\.]+)(?::\\s(.+))?"); private static final Pattern PTN_AT = Pattern.compile("at\\s((?:[a-zA-Z0-9_$]+)(?:\\.[a-zA-Z0-9_$]+)*)\\.((?:[a-zA-Z0-9_$-]+)|(?:))\\(([a-zA-Z0-9_]+\\.java):([0-9]+)\\)"); - protected @Nullable StackTraceElement[] convertStackTraceElements(final Sequence seqJavaStackTrace) throws XPathException { + protected @Nullable StackTraceElement[] convertStackTraceElements(final Sequence seqJavaStackTrace) { StackTraceElement[] traceElements = null; final Matcher matcherAt = PTN_AT.matcher(""); @@ -127,8 +156,8 @@ private XPathException errorMapAsXPathException(final MapType errorMap) throws X // index 0 is the first `Caused by: ...` int i = 1; for ( ; i < seqJavaStackTrace.getItemCount(); i++) { - final String item = seqJavaStackTrace.itemAt(i).getStringValue(); - final StackTraceElement stackTraceElement = convertStackTraceElement(matcherAt, item); + final String item = safeGetStringValue(seqJavaStackTrace.itemAt(i)); + @Nullable final StackTraceElement stackTraceElement = convertStackTraceElement(matcherAt, item); if (stackTraceElement == null) { break; } @@ -153,7 +182,7 @@ private XPathException errorMapAsXPathException(final MapType errorMap) throws X final String methodName = matcherAt.group(2); final String fileName = matcherAt.group(3); final String lineNumber = matcherAt.group(4); - return new StackTraceElement(declaringClass, methodName, fileName, Integer.valueOf(lineNumber)); + return new StackTraceElement(declaringClass, methodName, fileName, Integer.parseInt(lineNumber)); } else { return null; } diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestFailureFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestFailureFunction.java index 7dc1a9f53f..939ac1ef44 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestFailureFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestFailureFunction.java @@ -45,8 +45,6 @@ */ package org.exist.test.runner; -import org.apache.commons.io.output.StringBuilderWriter; -import org.exist.util.serializer.XQuerySerializer; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; import org.exist.xquery.functions.map.MapType; @@ -58,17 +56,16 @@ import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; -import org.xml.sax.SAXException; - -import javax.xml.transform.OutputKeys; -import java.io.IOException; -import java.util.Properties; import static org.exist.xquery.FunctionDSL.param; import static org.exist.xquery.FunctionDSL.params; public class ExtTestFailureFunction extends JUnitIntegrationFunction { + private static final StringValue XPATH_MAP_KEY = new StringValue("xpath"); + private static final StringValue ERROR_MAP_KEY = new StringValue("error"); + private static final StringValue RESULT_MAP_KEY = new StringValue("result"); + public ExtTestFailureFunction(final XQueryContext context, final String parentName, final RunNotifier notifier) { super("ext-test-failure-function", params( @@ -80,14 +77,28 @@ public ExtTestFailureFunction(final XQueryContext context, final String parentNa @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 3) { + throw new XPathException(this, "ext-test-failure-function requires 3 parameters"); + } - final Sequence arg2 = getCurrentArguments()[1]; - final MapType expected = (MapType)arg2.itemAt(0); + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-failure-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); - final Sequence arg3 = getCurrentArguments()[2]; - final MapType actual = (MapType)arg3.itemAt(0); + final Sequence argExpected = args[1]; + if (argExpected.isEmpty()) { + throw new XPathException(this, "ext-test-failure-function requires an 'expected' parameter"); + } + final MapType expected = (MapType) argExpected.itemAt(0); + + final Sequence argActual = args[2]; + if (argActual.isEmpty()) { + throw new XPathException(this, "ext-test-failure-function requires an 'actual' parameter"); + } + final MapType actual = (MapType) argActual.itemAt(0); final Description description = createTestDescription(name); @@ -99,63 +110,44 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr failureReason.setStackTrace(new StackTraceElement[0]); notifier.fireTestFailure(new Failure(description, failureReason)); - } catch (final XPathException | SAXException | IOException | IllegalStateException e) { + } catch (final Throwable t) { //signal internal failure - notifier.fireTestFailure(new Failure(description, e)); + notifier.fireTestFailure(new Failure(description, t)); } return Sequence.EMPTY_SEQUENCE; } - private String expectedToString(final MapType expected) throws XPathException, SAXException, IOException { - final Sequence seqExpectedValue = expected.get(new StringValue(this, "value")); - if(!seqExpectedValue.isEmpty()) { - return seqToString(seqExpectedValue); + private String expectedToString(final MapType expected) { + final Sequence seqExpectedValue = expected.get(VALUE_MAP_KEY); + if (!seqExpectedValue.isEmpty()) { + return safeSequenceToXmlString(context, seqExpectedValue); } - final Sequence seqExpectedXPath = expected.get(new StringValue(this, "xpath")); - if(!seqExpectedXPath.isEmpty()) { - return "XPath: " + seqToString(seqExpectedXPath); + final Sequence seqExpectedXPath = expected.get(XPATH_MAP_KEY); + if (!seqExpectedXPath.isEmpty()) { + return "XPath: " + safeSequenceToXmlString(context, seqExpectedXPath); } - final Sequence seqExpectedError = expected.get(new StringValue(this, "error")); - if(!seqExpectedError.isEmpty()) { - return "Error: " + seqToString(seqExpectedError); + final Sequence seqExpectedError = expected.get(ERROR_MAP_KEY); + if (!seqExpectedError.isEmpty()) { + return "Error: " + safeSequenceToXmlString(context, seqExpectedError); } throw new IllegalStateException("Could not extract expected value"); } - private String actualToString(final MapType actual) throws XPathException, SAXException, IOException { - final Sequence seqActualError = actual.get(new StringValue(this, "error")); + private String actualToString(final MapType actual) { + final Sequence seqActualError = actual.get(ERROR_MAP_KEY); if (!seqActualError.isEmpty()) { - return errorMapToString(seqActualError); + return safeSequenceToAdaptiveString(context, seqActualError); } - final Sequence seqActualResult = actual.get(new StringValue(this, "result")); + final Sequence seqActualResult = actual.get(RESULT_MAP_KEY); if (!seqActualResult.isEmpty()) { - return seqToString(seqActualResult); + return safeSequenceToXmlString(context, seqActualResult); } else { return ""; // empty-sequence() } } - - private String seqToString(final Sequence seq) throws XPathException, SAXException { - try(final StringBuilderWriter writer = new StringBuilderWriter()) { - final XQuerySerializer xquerySerializer = new XQuerySerializer(context.getBroker(), new Properties(), writer); - xquerySerializer.serialize(seq); - return writer.toString(); - } - } - - private String errorMapToString(final Sequence seqErrorMap) throws XPathException, SAXException { - try(final StringBuilderWriter writer = new StringBuilderWriter()) { - final Properties properties = new Properties(); - properties.setProperty(OutputKeys.METHOD, "adaptive"); - - final XQuerySerializer xquerySerializer = new XQuerySerializer(context.getBroker(), properties, writer); - xquerySerializer.serialize(seqErrorMap); - return writer.toString(); - } - } } diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java index b3018742bb..cd97300fe7 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestFinishedFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; import org.exist.xquery.XPathException; @@ -41,8 +64,16 @@ public ExtTestFinishedFunction(final XQueryContext context, final String parentN @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 1) { + throw new XPathException(this, "ext-test-finished-function requires 1 parameter"); + } + + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-finished-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); // notify JUnit final Description description = createTestDescription(name); diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java index fe9c9525cb..831e784ed0 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestIgnoredFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; import org.exist.xquery.XPathException; @@ -41,8 +64,16 @@ public ExtTestIgnoredFunction(final XQueryContext context, final String parentNa @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 1) { + throw new XPathException(this, "ext-test-ignored-function requires 1 parameter"); + } + + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-ignored-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); // notify JUnit final Description description = createTestDescription(name); diff --git a/exist-core/src/main/java/org/exist/test/runner/ExtTestStartedFunction.java b/exist-core/src/main/java/org/exist/test/runner/ExtTestStartedFunction.java index c962b35ed6..2f6571c2b5 100644 --- a/exist-core/src/main/java/org/exist/test/runner/ExtTestStartedFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/ExtTestStartedFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; import org.exist.xquery.XPathException; @@ -41,8 +64,16 @@ public ExtTestStartedFunction(final XQueryContext context, final String parentNa @Override public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { - final Sequence arg1 = getCurrentArguments()[0]; - final String name = arg1.itemAt(0).getStringValue(); + final Sequence[] args = getCurrentArguments(); + if (args.length != 1) { + throw new XPathException(this, "ext-test-started-function requires 1 parameter"); + } + + final Sequence argName = args[0]; + if (argName.isEmpty()) { + throw new XPathException(this, "ext-test-started-function requires a 'name' parameter"); + } + final String name = safeGetStringValue(argName.itemAt(0)); // notify JUnit final Description description = createTestDescription(name); diff --git a/exist-core/src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java b/exist-core/src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java index fa24c4bc9d..2ebc556535 100644 --- a/exist-core/src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java +++ b/exist-core/src/main/java/org/exist/test/runner/JUnitIntegrationFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,18 +43,29 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.test.runner; +import org.apache.commons.io.output.StringBuilderWriter; import org.exist.dom.QName; +import org.exist.util.serializer.XQuerySerializer; import org.exist.xquery.ExpressionVisitor; import org.exist.xquery.UserDefinedFunction; +import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; +import org.exist.xquery.functions.map.MapType; import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.StringValue; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; +import org.xml.sax.SAXException; +import javax.annotation.Nullable; import javax.xml.XMLConstants; +import javax.xml.transform.OutputKeys; + +import java.util.Properties; import static org.exist.xquery.FunctionDSL.functionSignature; import static org.exist.xquery.FunctionDSL.returnsNothing; @@ -42,6 +77,18 @@ */ public abstract class JUnitIntegrationFunction extends UserDefinedFunction { + protected static final StringValue VALUE_MAP_KEY = new StringValue("value"); + + private static final Properties XML_SERIALIZATION_PROPERTIES = new Properties(); + static { + XML_SERIALIZATION_PROPERTIES.setProperty(OutputKeys.METHOD, "xml"); + } + + private static final Properties ADAPTIVE_SERIALIZATION_PROPERTIES = new Properties(); + static { + ADAPTIVE_SERIALIZATION_PROPERTIES.setProperty(OutputKeys.METHOD, "adaptive"); + } + protected final String suiteName; protected final RunNotifier notifier; @@ -75,4 +122,59 @@ public void accept(final ExpressionVisitor visitor) { protected Description createTestDescription(final String name) { return Description.createTestDescription(suiteName, name); } + + protected static String safeGetStringValue(final Item item) { + try { + return item.getStringValue(); + } catch (final XPathException e) { + LOG.error("Unable to get String Value of item: " + e.getMessage(), e); + return ""; + } + } + + protected static int safeGetIntValue(@Nullable final Sequence sequence, final int index) { + if (sequence != null && !sequence.isEmpty()) { + return safeGetIntValue(sequence.itemAt(index)); + } + return -1; + } + + protected static int safeGetIntValue(final Item item) { + try { + return item.toJavaObject(int.class); + } catch (final XPathException e) { + LOG.error("Unable to get Int Value of item: " + e.getMessage(), e); + return -1; + } + } + + protected static String safeSequenceToXmlString(final XQueryContext context, final Sequence sequence) { + return safeSequenceToString(context, sequence, XML_SERIALIZATION_PROPERTIES); + } + + protected static String safeSequenceToAdaptiveString(final XQueryContext context, final Sequence sequence) { + return safeSequenceToString(context, sequence, ADAPTIVE_SERIALIZATION_PROPERTIES); + } + + private static String safeSequenceToString(final XQueryContext context, final Sequence sequence, final Properties properties) { + try (final StringBuilderWriter writer = new StringBuilderWriter()) { + final XQuerySerializer xquerySerializer = new XQuerySerializer(context.getBroker(), properties, writer); + xquerySerializer.serialize(sequence); + return writer.toString(); + } catch (final XPathException | SAXException e) { + LOG.error("Unable to convert Sequence to String: " + e.getMessage(), e); + return ""; + } + } + + protected static @Nullable String safeGetMapStringValue(final StringValue key, final MapType map, @Nullable final String defaultValue) { + final Sequence mapValue = map.get(key); + final String value; + if (mapValue != null && !mapValue.isEmpty()) { + value = safeGetStringValue(mapValue.itemAt(0)); + } else { + value = defaultValue; + } + return value; + } } diff --git a/exist-core/src/test/java/org/exist/IndexerTest2.java b/exist-core/src/test/java/org/exist/Indexer2Test.java similarity index 99% rename from exist-core/src/test/java/org/exist/IndexerTest2.java rename to exist-core/src/test/java/org/exist/Indexer2Test.java index a24787f0c4..0b3a0f3bf6 100644 --- a/exist-core/src/test/java/org/exist/IndexerTest2.java +++ b/exist-core/src/test/java/org/exist/Indexer2Test.java @@ -84,7 +84,7 @@ * * @author ljo */ -public class IndexerTest2 { +public class Indexer2Test { private final static String XML = "\n" + diff --git a/exist-core/src/test/java/org/exist/IndexerTest3.java b/exist-core/src/test/java/org/exist/Indexer3Test.java similarity index 99% rename from exist-core/src/test/java/org/exist/IndexerTest3.java rename to exist-core/src/test/java/org/exist/Indexer3Test.java index 61f771be94..7d95874c00 100644 --- a/exist-core/src/test/java/org/exist/IndexerTest3.java +++ b/exist-core/src/test/java/org/exist/Indexer3Test.java @@ -80,7 +80,7 @@ * * @author ljo */ -public class IndexerTest3 { +public class Indexer3Test { @ClassRule public static final ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); diff --git a/exist-core/src/test/java/org/exist/collections/CollectionStoreTest.java b/exist-core/src/test/java/org/exist/collections/CollectionStoreTest.java index 5f077a8d07..9de35afbfa 100644 --- a/exist-core/src/test/java/org/exist/collections/CollectionStoreTest.java +++ b/exist-core/src/test/java/org/exist/collections/CollectionStoreTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.collections; import com.evolvedbinary.j8fu.Try; @@ -54,10 +77,10 @@ import java.util.Optional; import static java.nio.charset.StandardCharsets.UTF_8; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class CollectionStoreTest { diff --git a/exist-core/src/test/java/org/exist/collections/OpenCollectionTest.java b/exist-core/src/test/java/org/exist/collections/OpenCollectionTest.java index 6385086a57..78b4ada06c 100644 --- a/exist-core/src/test/java/org/exist/collections/OpenCollectionTest.java +++ b/exist-core/src/test/java/org/exist/collections/OpenCollectionTest.java @@ -40,7 +40,7 @@ import java.net.URISyntaxException; import java.util.Optional; -import static junit.framework.TestCase.assertNotNull; +import static org.junit.Assert.assertNotNull; public class OpenCollectionTest { diff --git a/exist-core/src/test/java/org/exist/collections/triggers/TestTrigger.java b/exist-core/src/test/java/org/exist/collections/triggers/MessagesTrigger.java similarity index 85% rename from exist-core/src/test/java/org/exist/collections/triggers/TestTrigger.java rename to exist-core/src/test/java/org/exist/collections/triggers/MessagesTrigger.java index 174f542160..b74a836038 100644 --- a/exist-core/src/test/java/org/exist/collections/triggers/TestTrigger.java +++ b/exist-core/src/test/java/org/exist/collections/triggers/MessagesTrigger.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -42,7 +66,7 @@ /** * Test trigger to check if trigger configuration is working properly. */ -public class TestTrigger extends SAXTrigger implements DocumentTrigger { +public class MessagesTrigger extends SAXTrigger implements DocumentTrigger { protected Logger LOG = LogManager.getLogger(getClass()); diff --git a/exist-core/src/test/java/org/exist/collections/triggers/TriggerConfigTest.java b/exist-core/src/test/java/org/exist/collections/triggers/TriggerConfigTest.java index c62bb65191..25390ad5a6 100644 --- a/exist-core/src/test/java/org/exist/collections/triggers/TriggerConfigTest.java +++ b/exist-core/src/test/java/org/exist/collections/triggers/TriggerConfigTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -21,22 +45,16 @@ */ package org.exist.collections.triggers; -import java.io.IOException; import java.util.Arrays; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.exist.EXistException; -import org.exist.TestUtils; -import org.exist.security.PermissionDeniedException; import org.exist.test.ExistXmldbEmbeddedServer; -import org.exist.util.LockException; import org.exist.xmldb.IndexQueryService; import org.junit.*; import static org.exist.collections.CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -44,6 +62,7 @@ import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.*; import org.xmldb.api.modules.CollectionManagementService; +import org.xmldb.api.modules.XMLResource; import org.xmldb.api.modules.XQueryService; import org.junit.runners.Parameterized.Parameters; @@ -73,7 +92,7 @@ public static java.util.Collection data() { private static final String COLLECTION_CONFIG = "" + " " + - " " + + " " + " " + ""; @@ -94,131 +113,102 @@ public static java.util.Collection data() { @Parameter public String testCollection; - @Test - public void storeDocument() { - try { - Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); - IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); - iqs.configureCollection(COLLECTION_CONFIG); - - Resource resource = root.createResource("data.xml", "XMLResource"); - resource.setContent(DOCUMENT_CONTENT); - root.storeResource(resource); - XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); - ResourceSet result = qs.queryResource("messages.xml", "string(//event[last()]/@collection)"); - assertEquals(1, result.getSize()); - assertEquals(testCollection, result.getResource(0).getContent()); - } catch (XMLDBException e) { - LOG.error(e.getMessage(), e); - fail(e.getMessage()); - } - } - @Test - public void removeDocument() { - try { - Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); - IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); - iqs.configureCollection(COLLECTION_CONFIG); + @BeforeClass + public static void initDB() throws XMLDBException { + CollectionManagementService mgmt = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0"); + Collection testCol = mgmt.createCollection("triggers"); - Resource resource = root.createResource("data.xml", "XMLResource"); - resource.setContent(DOCUMENT_CONTENT); - root.storeResource(resource); + for (int i = 1; i <= 2; i++) { + mgmt = (CollectionManagementService) testCol.getService("CollectionManagementService", "1.0"); + testCol = mgmt.createCollection("sub" + i); + } + } + @After + public void cleanDB() throws XMLDBException { + Collection config = DatabaseManager.getCollection(BASE_URI + "/db/system/config" + testCollection, "admin", ""); + if (config != null) { + CollectionManagementService mgmt = (CollectionManagementService) config.getService("CollectionManagementService", "1.0"); + mgmt.removeCollection("."); + } + Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); + Resource resource = root.getResource("messages.xml"); + if (resource != null) { + root.removeResource(resource); + } + resource = root.getResource("data.xml"); + if (resource != null) { root.removeResource(resource); - - XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); - ResourceSet result = qs.queryResource("messages.xml", "string(//event[last()]/@collection)"); - assertEquals(1, result.getSize()); - assertEquals(testCollection, result.getResource(0).getContent()); - } catch (XMLDBException e) { - LOG.error(e.getMessage(), e); - fail(e.getMessage()); } } @Test - public void removeTriggers() { - try { - Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); - IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); - iqs.configureCollection(EMPTY_COLLECTION_CONFIG); - - Resource resource = root.createResource("data.xml", "XMLResource"); - resource.setContent(DOCUMENT_CONTENT); - root.storeResource(resource); - - XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); - ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT'] else ()"); - assertEquals("No trigger should have fired. Configuration was removed", 0, result.getSize()); - } catch (XMLDBException e) { - LOG.error(e.getMessage(), e); - fail(e.getMessage()); - } + public void storeDocument() throws XMLDBException { + Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); + IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); + iqs.configureCollection(COLLECTION_CONFIG); + + Resource resource = root.createResource("data.xml", "XMLResource"); + resource.setContent(DOCUMENT_CONTENT); + root.storeResource(resource); + XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); + ResourceSet result = qs.queryResource("messages.xml", "string(//event[last()]/@collection)"); + assertEquals(1, result.getSize()); + assertEquals(testCollection, result.getResource(0).getContent()); } @Test - public void updateTriggers() { - try { - Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); - IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); - iqs.configureCollection(EMPTY_COLLECTION_CONFIG); - - Collection configCol = DatabaseManager.getCollection(BASE_URI + "/db/system/config" + testCollection, "admin", ""); - Resource resource = configCol.createResource(DEFAULT_COLLECTION_CONFIG_FILE, "XMLResource"); - resource.setContent(COLLECTION_CONFIG); - configCol.storeResource(resource); - - resource = root.createResource("data.xml", "XMLResource"); - resource.setContent(DOCUMENT_CONTENT); - root.storeResource(resource); - - XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); - ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT']/string(@collection) else ()"); - assertEquals(1, result.getSize()); - assertEquals(testCollection, result.getResource(0).getContent()); - } catch (XMLDBException e) { - LOG.error(e.getMessage(), e); - fail(e.getMessage()); - } - } + public void removeDocument() throws XMLDBException { + Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); + IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); + iqs.configureCollection(COLLECTION_CONFIG); - @After - public void cleanDB() { - try { - Collection config = DatabaseManager.getCollection(BASE_URI + "/db/system/config" + testCollection, "admin", ""); - if (config != null) { - CollectionManagementService mgmt = (CollectionManagementService) config.getService("CollectionManagementService", "1.0"); - mgmt.removeCollection("."); - } - Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); - Resource resource = root.getResource("messages.xml"); - if (resource != null) { - root.removeResource(resource); - } - resource = root.getResource("data.xml"); - if (resource != null) { - root.removeResource(resource); - } - } catch (XMLDBException e) { - LOG.error(e.getMessage(), e); - fail(e.getMessage()); - } - } + Resource resource = root.createResource("data.xml", "XMLResource"); + resource.setContent(DOCUMENT_CONTENT); + root.storeResource(resource); - @BeforeClass - public static void initDB() throws XMLDBException { - CollectionManagementService mgmt = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0"); - Collection testCol = mgmt.createCollection("triggers"); + root.removeResource(resource); - for (int i = 1; i <= 2; i++) { - mgmt = (CollectionManagementService) testCol.getService("CollectionManagementService", "1.0"); - testCol = mgmt.createCollection("sub" + i); - } + XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); + ResourceSet result = qs.queryResource("messages.xml", "string(//event[last()]/@collection)"); + assertEquals(1, result.getSize()); + assertEquals(testCollection, result.getResource(0).getContent()); + } + + @Test + public void removeTriggers() throws XMLDBException { + Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); + IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); + iqs.configureCollection(EMPTY_COLLECTION_CONFIG); + + Resource resource = root.createResource("data.xml", "XMLResource"); + resource.setContent(DOCUMENT_CONTENT); + root.storeResource(resource); + + XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); + ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT'] else ()"); + assertEquals("No trigger should have fired. Configuration was removed", 0, result.getSize()); } - @AfterClass - public static void closeDB() throws LockException, TriggerException, PermissionDeniedException, EXistException, IOException { - TestUtils.cleanupDB(); + @Test + public void updateTriggers() throws XMLDBException { + Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", ""); + IndexQueryService iqs = (IndexQueryService) root.getService("IndexQueryService", "1.0"); + iqs.configureCollection(EMPTY_COLLECTION_CONFIG); + + Collection configCol = DatabaseManager.getCollection(BASE_URI + "/db/system/config" + testCollection, "admin", ""); + Resource resource = configCol.createResource(DEFAULT_COLLECTION_CONFIG_FILE, "XMLResource"); + resource.setContent(COLLECTION_CONFIG); + configCol.storeResource(resource); + + resource = root.createResource("data.xml", "XMLResource"); + resource.setContent(DOCUMENT_CONTENT); + root.storeResource(resource); + + XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0"); + ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT']/string(@collection) else ()"); + assertEquals(1, result.getSize()); + assertEquals(testCollection, result.getResource(0).getContent()); } -} \ No newline at end of file +} diff --git a/exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java b/exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocksTest.java similarity index 81% rename from exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java rename to exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocksTest.java index 27dfcbaa11..884ac2a3b1 100644 --- a/exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java +++ b/exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocksTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -42,9 +66,9 @@ * @author Dmitriy Shabanov * */ -public class GetReleaseBrokerDeadlocks { +public class GetReleaseBrokerDeadlocksTest { - private static final Logger LOG = LogManager.getLogger(GetReleaseBrokerDeadlocks.class); + private static final Logger LOG = LogManager.getLogger(GetReleaseBrokerDeadlocksTest.class); private static Random rd = new Random(); @@ -103,7 +127,7 @@ public void testingGetReleaseCycle() { boolean debug = false; try { Configuration config = new Configuration(); - config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); + config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, Boolean.FALSE); BrokerPool.configure(1, 5, config); Database db = BrokerPool.getInstance(); diff --git a/exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java b/exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java index c485b63a05..a405ac48c2 100644 --- a/exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java +++ b/exist-core/src/test/java/org/exist/dom/memtree/DocumentImplTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.dom.memtree; import com.googlecode.junittoolbox.ParallelRunner; @@ -37,8 +60,8 @@ import java.io.IOException; import java.io.InputStream; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static java.nio.charset.StandardCharsets.UTF_8; /** diff --git a/exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQuery.java b/exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQueryTest.java similarity index 79% rename from exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQuery.java rename to exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQueryTest.java index 9f9372e6ac..b1d92c5f8b 100644 --- a/exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQuery.java +++ b/exist-core/src/test/java/org/exist/dom/memtree/MemtreeInXQueryTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -34,7 +58,7 @@ * @author Adam Retter */ @RunWith(ParallelRunner.class) -public class MemtreeInXQuery { +public class MemtreeInXQueryTest { @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(true, true, true); diff --git a/exist-core/src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java b/exist-core/src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java index 3316f8699d..a0db5cfbe9 100644 --- a/exist-core/src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java +++ b/exist-core/src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.dom.persistent; import com.googlecode.junittoolbox.ParallelRunner; @@ -29,11 +52,11 @@ import java.util.Iterator; -import static junit.framework.TestCase.assertFalse; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** diff --git a/exist-core/src/test/java/org/exist/storage/AbstractUpdateTest.java b/exist-core/src/test/java/org/exist/storage/AbstractUpdateTest.java index 44201bdc4e..b61babf681 100644 --- a/exist-core/src/test/java/org/exist/storage/AbstractUpdateTest.java +++ b/exist-core/src/test/java/org/exist/storage/AbstractUpdateTest.java @@ -138,6 +138,7 @@ protected BrokerPool startDb() throws DatabaseConfigurationException, EXistExcep @AfterClass public static void cleanup() { + // restore the flag in-case of a test failure BrokerPool.FORCE_CORRUPTION = false; } } diff --git a/exist-core/src/test/java/org/exist/storage/BrokerPoolTest.java b/exist-core/src/test/java/org/exist/storage/BrokerPoolTest.java index 42fda2d6e8..e61598b4ef 100644 --- a/exist-core/src/test/java/org/exist/storage/BrokerPoolTest.java +++ b/exist-core/src/test/java/org/exist/storage/BrokerPoolTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -33,8 +57,8 @@ import java.util.Optional; import java.util.concurrent.*; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** diff --git a/exist-core/src/test/java/org/exist/storage/BrokerPoolsTest.java b/exist-core/src/test/java/org/exist/storage/BrokerPoolsTest.java index ae0ce3ebef..b076aa9560 100644 --- a/exist-core/src/test/java/org/exist/storage/BrokerPoolsTest.java +++ b/exist-core/src/test/java/org/exist/storage/BrokerPoolsTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -34,7 +58,6 @@ import java.util.*; import java.util.concurrent.*; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.*; /** diff --git a/exist-core/src/test/java/org/exist/storage/RecoverBinaryTest2.java b/exist-core/src/test/java/org/exist/storage/RecoverBinary2Test.java similarity index 71% rename from exist-core/src/test/java/org/exist/storage/RecoverBinaryTest2.java rename to exist-core/src/test/java/org/exist/storage/RecoverBinary2Test.java index 58b81ffaa4..2104900e5f 100644 --- a/exist-core/src/test/java/org/exist/storage/RecoverBinaryTest2.java +++ b/exist-core/src/test/java/org/exist/storage/RecoverBinary2Test.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -22,10 +46,9 @@ package org.exist.storage; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; +import java.io.InputStream; +import java.net.URISyntaxException; import java.util.Iterator; -import java.util.List; import java.util.Optional; import org.exist.EXistException; @@ -33,28 +56,29 @@ import org.exist.collections.triggers.TriggerException; import org.exist.dom.persistent.BinaryDocument; import org.exist.dom.persistent.DocumentImpl; +import org.exist.samples.Samples; import org.exist.security.PermissionDeniedException; import org.exist.storage.txn.TransactionManager; import org.exist.storage.txn.Txn; import org.exist.test.ExistEmbeddedServer; import org.exist.test.TestConstants; import org.exist.util.*; +import org.exist.util.io.InputStreamUtil; import org.exist.xmldb.XmldbURI; import org.junit.After; import org.junit.Test; import org.xml.sax.SAXException; +import static org.exist.samples.Samples.SAMPLES; import static org.junit.Assert.assertNotNull; -public class RecoverBinaryTest2 { +public class RecoverBinary2Test { // we don't use @ClassRule/@Rule as we want to force corruption in some tests - private ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); - - private static String directory = "webapp/resources"; + private ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, false); @Test - public void storeAndRead() throws SAXException, PermissionDeniedException, DatabaseConfigurationException, IOException, LockException, EXistException { + public void storeAndRead() throws SAXException, PermissionDeniedException, DatabaseConfigurationException, IOException, LockException, EXistException, URISyntaxException { BrokerPool.FORCE_CORRUPTION = true; BrokerPool pool = startDb(); store(pool); @@ -72,7 +96,7 @@ public void storeAndRead() throws SAXException, PermissionDeniedException, Datab read2(pool); } - public void store(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, IOException, SAXException, LockException { + public void store(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, IOException, SAXException, LockException, URISyntaxException { final TransactionManager transact = pool.getTransactionManager(); try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject())); @@ -91,7 +115,7 @@ public void store(final BrokerPool pool) throws EXistException, DatabaseConfigur } } - public void read(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, LockException, IOException, SAXException { + public void read(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, LockException, IOException, SAXException, URISyntaxException { try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) { final Collection test2 = broker.getCollection(TestConstants.TEST_COLLECTION_URI2); for (final Iterator i = test2.iterator(broker); i.hasNext(); ) { @@ -110,7 +134,7 @@ public void read(final BrokerPool pool) throws EXistException, DatabaseConfigura } } - public void read2(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, IOException, TriggerException, LockException { + public void read2(final BrokerPool pool) throws EXistException, PermissionDeniedException, IOException, TriggerException, LockException { try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) { final Collection test2 = broker.getCollection(TestConstants.TEST_COLLECTION_URI2); @@ -130,22 +154,17 @@ public void read2(final BrokerPool pool) throws EXistException, DatabaseConfigur } private void storeFiles(final DBBroker broker, final Txn transaction, final Collection test2) throws IOException, EXistException, PermissionDeniedException, LockException, SAXException { - // Get files in directory - final Path dir = FileUtils.resolve(ConfigurationHelper.getExistHome(), directory); - final List files = FileUtils.list(dir); - assertNotNull("Check directory '"+dir.toAbsolutePath().toString()+"'.",files); - // store some documents. for (int j = 0; j < 10; j++) { - for (final Path f : files) { - assertNotNull(f); - if (Files.isRegularFile(f)) { - final XmldbURI uri = test2.getURI().append(j + "_" + FileUtils.fileName(f)); - - broker.storeDocument(transaction, uri, new FileInputSource(f), MimeType.BINARY_TYPE, test2); - final BinaryDocument doc = (BinaryDocument) test2.getDocument(broker, uri); - assertNotNull(doc); + for (final String modsFilename : Samples.SAMPLES.getModsXmlSampleNames()) { + final XmldbURI uri = test2.getURI().append(j + "_" + modsFilename); + final byte[] modsContent; + try (final InputStream is = SAMPLES.getModsSample(modsFilename)) { + modsContent = InputStreamUtil.readAll(is); } + broker.storeDocument(transaction, uri, new StringInputSource(modsContent), MimeType.BINARY_TYPE, test2); + final BinaryDocument doc = (BinaryDocument) test2.getDocument(broker, uri); + assertNotNull(doc); } } } @@ -157,6 +176,7 @@ private BrokerPool startDb() throws EXistException, IOException, DatabaseConfigu @After public void stopDb() { + BrokerPool.FORCE_CORRUPTION = false; existEmbeddedServer.stopDb(); } } diff --git a/exist-core/src/test/java/org/exist/storage/RecoveryTest2.java b/exist-core/src/test/java/org/exist/storage/Recovery2Test.java similarity index 70% rename from exist-core/src/test/java/org/exist/storage/RecoveryTest2.java rename to exist-core/src/test/java/org/exist/storage/Recovery2Test.java index a45d82283b..5ecd459303 100644 --- a/exist-core/src/test/java/org/exist/storage/RecoveryTest2.java +++ b/exist-core/src/test/java/org/exist/storage/Recovery2Test.java @@ -46,6 +46,8 @@ package org.exist.storage; import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -55,6 +57,7 @@ import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.dom.persistent.LockedDocument; +import org.exist.samples.Samples; import org.exist.security.PermissionDeniedException; import org.exist.storage.btree.BTreeException; import org.exist.storage.dom.DOMFile; @@ -64,16 +67,19 @@ import org.exist.storage.txn.Txn; import org.exist.test.ExistEmbeddedServer; import org.exist.test.TestConstants; -import org.exist.util.DatabaseConfigurationException; -import org.exist.util.FileUtils; -import org.exist.util.LockException; -import org.exist.util.MimeType; +import org.exist.util.*; +import org.exist.util.io.InputStreamUtil; import org.exist.xmldb.XmldbURI; +import org.exist.xquery.XPathException; import org.junit.After; +import org.junit.AfterClass; +import org.junit.Rule; import org.junit.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.exist.samples.Samples.SAMPLES; import static org.junit.Assert.assertNotNull; /** @@ -82,25 +88,27 @@ * @author wolf * */ -public class RecoveryTest2 { +public class Recovery2Test { - // we don't use @ClassRule/@Rule as we want to force corruption in some tests - private ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); - - private static String xmlDir = "/home/wolf/xml/Saami"; - - @SuppressWarnings("unused") - private static String TEST_XML = - "" + - "" + - " Hello" + - " Hello World!" + - ""; + @Rule + public ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); @Test - public void store() throws DatabaseConfigurationException, EXistException, PermissionDeniedException, IOException, SAXException, BTreeException, LockException { + public void storeRead() throws PermissionDeniedException, DatabaseConfigurationException, IOException, LockException, SAXException, EXistException, BTreeException, XPathException, URISyntaxException { + BrokerPool.FORCE_CORRUPTION = true; - final BrokerPool pool = startDb(); + store(existEmbeddedServer.getBrokerPool()); + + // flush journal + existEmbeddedServer.getBrokerPool().getJournalManager().get().flush(true, false); + + existEmbeddedServer.restart(); + BrokerPool.FORCE_CORRUPTION = false; + + read(existEmbeddedServer.getBrokerPool()); + } + + private void store(final BrokerPool pool) throws DatabaseConfigurationException, EXistException, PermissionDeniedException, IOException, SAXException, BTreeException, LockException, URISyntaxException { final TransactionManager transact = pool.getTransactionManager(); try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject())); @@ -121,26 +129,24 @@ public void store() throws DatabaseConfigurationException, EXistException, Permi } // store some documents. Will be replaced below - final Path dir = Paths.get(xmlDir); - final List docs = FileUtils.list(dir); - for (final Path f : docs) { - broker.storeDocument(transaction, XmldbURI.create(FileUtils.fileName(f)), new InputSource(f.toUri().toASCIIString()), MimeType.XML_TYPE, test2); + for (final String modsFilename : Samples.SAMPLES.getModsXmlSampleNames()) { + final String modsContent; + try (final InputStream is = SAMPLES.getModsSample(modsFilename)) { + modsContent = InputStreamUtil.readString(is, UTF_8); + } + broker.storeDocument(transaction, XmldbURI.create(modsFilename), new StringInputSource(modsContent), MimeType.XML_TYPE, test2); } transact.commit(transaction); } } - @Test - public void read() throws EXistException, DatabaseConfigurationException, PermissionDeniedException, SAXException, IOException { - BrokerPool.FORCE_CORRUPTION = false; - BrokerPool pool = startDb(); - + private void read(final BrokerPool pool) throws EXistException, DatabaseConfigurationException, PermissionDeniedException, SAXException, IOException { try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) { assertNotNull(broker); final Serializer serializer = broker.borrowSerializer(); - try(final LockedDocument lockedDoc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append("terms-eng.xml"), LockMode.READ_LOCK)) { + try(final LockedDocument lockedDoc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append("0d569a0b-2738-4865-8b47-a9f8b821a653.xml"), LockMode.READ_LOCK)) { assertNotNull("Document should not be null", lockedDoc); String data = serializer.serialize(lockedDoc.getDocument()); assertNotNull(data); @@ -150,13 +156,9 @@ public void read() throws EXistException, DatabaseConfigurationException, Permis } } - private BrokerPool startDb() throws EXistException, IOException, DatabaseConfigurationException { - existEmbeddedServer.startDb(); - return existEmbeddedServer.getBrokerPool(); - } - - @After - public void stopDb() { - existEmbeddedServer.stopDb(); + @AfterClass + public static void cleanup() { + // restore the flag in-case of a test failure + BrokerPool.FORCE_CORRUPTION = false; } } diff --git a/exist-core/src/test/java/org/exist/storage/RecoveryTest3.java b/exist-core/src/test/java/org/exist/storage/RecoveryTest3.java deleted file mode 100644 index 13f49c31d9..0000000000 --- a/exist-core/src/test/java/org/exist/storage/RecoveryTest3.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.storage; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Optional; - -import org.exist.EXistException; -import org.exist.collections.Collection; -import org.exist.collections.triggers.TriggerException; -import org.exist.security.PermissionDeniedException; -import org.exist.storage.lock.Lock.LockMode; -import org.exist.storage.txn.TransactionManager; -import org.exist.storage.txn.Txn; -import org.exist.test.ExistEmbeddedServer; -import org.exist.test.TestConstants; -import org.exist.util.*; -import org.exist.xmldb.XmldbURI; -import org.junit.After; -import org.junit.Test; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -/** - * Add a larger number of documents into a collection, - * crash the database, restart, remove the collection and add some - * more documents. - * - * This test needs quite a few documents to be in the collection. Change - * the directory path below to point to a directory with at least 1000 docs. - * - * @author wolf - * - */ -public class RecoveryTest3 { - - // we don't use @ClassRule/@Rule as we want to force corruption in some tests - private ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); - - private final static int RESOURCE_COUNT = 5000; - - private static String directory = "/media/Shared/XML/movies"; - - private static Path dir = Paths.get(directory); - - @Test - public void store() throws DatabaseConfigurationException, EXistException, PermissionDeniedException, IOException, TriggerException, LockException { - BrokerPool.FORCE_CORRUPTION = true; - final BrokerPool pool = startDb(); - final TransactionManager transact = pool.getTransactionManager(); - - try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject())); - final Txn transaction = transact.beginTransaction()) { - - Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI); - assertNotNull(root); - broker.saveCollection(transaction, root); - - Collection test2 = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI2); - assertNotNull(test2); - broker.saveCollection(transaction, test2); - - final List files = FileUtils.list(dir, XMLFilenameFilter.asPredicate()); - assertNotNull(files); - - // store some documents. - for (int i = 0; i < files.size() && i < RESOURCE_COUNT; i++) { - final Path f = files.get(i); - try { - broker.storeDocument(transaction, XmldbURI.create(FileUtils.fileName(f)), new InputSource(f.toUri().toASCIIString()), MimeType.XML_TYPE, test2); - } catch (final SAXException e) { - fail("Error found while parsing document: " + FileUtils.fileName(f) + ": " + e.getMessage()); - } - } - - transact.commit(transaction); - } - } - - @Test - public void read() throws DatabaseConfigurationException, EXistException, PermissionDeniedException, IOException, TriggerException, LockException { - - BrokerPool.FORCE_CORRUPTION = false; - final BrokerPool pool = startDb(); - final TransactionManager transact = pool.getTransactionManager(); - - try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) { - - BrokerPool.FORCE_CORRUPTION = true; - - try (final Txn transaction = transact.beginTransaction(); - final Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, LockMode.WRITE_LOCK)) { - assertNotNull(root); - transaction.acquireCollectionLock(() -> broker.getBrokerPool().getLockManager().acquireCollectionWriteLock(root.getURI())); - broker.removeCollection(transaction, root); - - transact.commit(transaction); - } - - try (final Txn transaction = transact.beginTransaction(); - final Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI)) { - assertNotNull(root); - broker.saveCollection(transaction, root); - - //TODO(AR) needs write lock - try(final Collection test2 = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI2)) { - assertNotNull(test2); - broker.saveCollection(transaction, test2); - - final List files = FileUtils.list(dir, XMLFilenameFilter.asPredicate()); - - // store some documents. - for (int i = 0; i < files.size() && i < RESOURCE_COUNT; i++) { - final Path f = files.get(i); - try { - broker.storeDocument(transaction, XmldbURI.create(FileUtils.fileName(f)), new InputSource(f.toUri().toASCIIString()), MimeType.XML_TYPE, test2); - } catch (SAXException e) { - fail("Error found while parsing document: " + FileUtils.fileName(f) + ": " + e.getMessage()); - } - } - } - - transact.commit(transaction); - } - } - } - - @Test - public void read2() throws DatabaseConfigurationException, EXistException, IOException { - BrokerPool.FORCE_CORRUPTION = false; - BrokerPool pool = startDb(); - - try(final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) { - - assertNotNull(broker); - - //TODO : do something ? - } - } - - private BrokerPool startDb() throws EXistException, IOException, DatabaseConfigurationException { - existEmbeddedServer.startDb(); - return existEmbeddedServer.getBrokerPool(); - } - - @After - public void stopDb() { - existEmbeddedServer.stopDb(); - } - -} diff --git a/exist-core/src/test/java/org/exist/storage/util/PauseFunction.java b/exist-core/src/test/java/org/exist/storage/util/PauseFunction.java index cd23bfa9f0..0a7aeda146 100755 --- a/exist-core/src/test/java/org/exist/storage/util/PauseFunction.java +++ b/exist-core/src/test/java/org/exist/storage/util/PauseFunction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -53,6 +77,8 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce try { wait(t * 1000); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new XPathException(e); } } return Sequence.EMPTY_SEQUENCE; diff --git a/exist-core/src/test/java/org/exist/util/CollationsTest.java b/exist-core/src/test/java/org/exist/util/CollationsTest.java index a5a9dc5826..bb50223a47 100644 --- a/exist-core/src/test/java/org/exist/util/CollationsTest.java +++ b/exist-core/src/test/java/org/exist/util/CollationsTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,15 +43,14 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util; import com.ibm.icu.text.Collator; import org.exist.xquery.XPathException; import org.junit.Test; -import static junit.framework.TestCase.assertFalse; import static org.exist.util.Collations.HTML_ASCII_CASE_INSENSITIVE_COLLATION_URI; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class CollationsTest { diff --git a/exist-core/src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java b/exist-core/src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java index f3a445683b..bf584259dd 100644 --- a/exist-core/src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java +++ b/exist-core/src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java @@ -39,9 +39,9 @@ import java.util.List; import java.util.NoSuchElementException; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class CollectionOfArrayIteratorTest { diff --git a/exist-core/src/test/java/org/exist/util/LeasableTest.java b/exist-core/src/test/java/org/exist/util/LeasableTest.java index 8c16f53e1c..6c5d6e3ab0 100644 --- a/exist-core/src/test/java/org/exist/util/LeasableTest.java +++ b/exist-core/src/test/java/org/exist/util/LeasableTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,14 +43,13 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util; import org.easymock.EasyMock; import org.junit.Test; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class LeasableTest { diff --git a/exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamTest_NonMarkableByteArrayInputStream.java b/exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamNonMarkableByteArrayInputStreamTest.java similarity index 99% rename from exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamTest_NonMarkableByteArrayInputStream.java rename to exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamNonMarkableByteArrayInputStreamTest.java index 654652f3dd..21056cc40b 100644 --- a/exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamTest_NonMarkableByteArrayInputStream.java +++ b/exist-core/src/test/java/org/exist/util/io/CachingFilterInputStreamNonMarkableByteArrayInputStreamTest.java @@ -52,7 +52,7 @@ * @author Adam Retter */ @RunWith(value = ParallelParameterized.class) -public class CachingFilterInputStreamTest_NonMarkableByteArrayInputStream { +public class CachingFilterInputStreamNonMarkableByteArrayInputStreamTest { @Parameters public static Collection data() { @@ -72,7 +72,7 @@ public static Collection data() { private final Class cacheClass; - public CachingFilterInputStreamTest_NonMarkableByteArrayInputStream(final Class cacheClass) { + public CachingFilterInputStreamNonMarkableByteArrayInputStreamTest(final Class cacheClass) { this.cacheClass = cacheClass; } diff --git a/exist-core/src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java b/exist-core/src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java index eb7138b1a6..a2a3686716 100644 --- a/exist-core/src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java +++ b/exist-core/src/test/java/org/exist/util/io/FilterInputStreamCacheMonitorTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.io; import org.apache.logging.log4j.LogManager; @@ -43,7 +66,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.*; public class FilterInputStreamCacheMonitorTest { diff --git a/exist-core/src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java b/exist-core/src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java index 87764e38a8..34245fe7bf 100644 --- a/exist-core/src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java +++ b/exist-core/src/test/java/org/exist/util/io/OverflowToDiskStreamTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.io; import org.junit.Before; @@ -28,8 +51,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; import static org.easymock.EasyMock.aryEq; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.eq; @@ -37,6 +58,8 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Patrick Reinhart diff --git a/exist-core/src/test/java/org/exist/util/pool/NodePoolTest.java b/exist-core/src/test/java/org/exist/util/pool/NodePoolTest.java index d9a8a50933..3ce9988482 100644 --- a/exist-core/src/test/java/org/exist/util/pool/NodePoolTest.java +++ b/exist-core/src/test/java/org/exist/util/pool/NodePoolTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -24,7 +48,8 @@ import org.junit.Test; import org.w3c.dom.Node; import org.exist.dom.persistent.NodeImpl; -import static junit.framework.Assert.*; + +import static org.junit.Assert.assertEquals; public class NodePoolTest { diff --git a/exist-core/src/test/java/org/exist/util/sorters/ListChecker.java b/exist-core/src/test/java/org/exist/util/sorters/ListChecker.java index b0db624796..27dca8b22d 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/ListChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/ListChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; diff --git a/exist-core/src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java b/exist-core/src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java index 7f1509c2ff..2005e1c53c 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/LongArrayAndObjectChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * check sort(long[], Object[]) diff --git a/exist-core/src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java b/exist-core/src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java index f8e6d4df75..e20fb26d1d 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/NodeProxyByIdChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.exist.dom.persistent.NodeProxy; diff --git a/exist-core/src/test/java/org/exist/util/sorters/NodeProxyChecker.java b/exist-core/src/test/java/org/exist/util/sorters/NodeProxyChecker.java index c2ab451deb..76a3092f7a 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/NodeProxyChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/NodeProxyChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.exist.dom.persistent.NodeProxy; diff --git a/exist-core/src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java b/exist-core/src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java index 4b68ad88fb..22ef70f1ab 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/ObjectAndIntArrayChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * check sort(Object[], int[]) diff --git a/exist-core/src/test/java/org/exist/util/sorters/PlainArrayChecker.java b/exist-core/src/test/java/org/exist/util/sorters/PlainArrayChecker.java index 57ae4cd878..1db681867c 100644 --- a/exist-core/src/test/java/org/exist/util/sorters/PlainArrayChecker.java +++ b/exist-core/src/test/java/org/exist/util/sorters/PlainArrayChecker.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,11 +43,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.util.sorters; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.Comparator; diff --git a/exist-core/src/test/java/org/exist/w3c/tests/TestCase.java b/exist-core/src/test/java/org/exist/w3c/tests/TestCase.java deleted file mode 100644 index fc42fa1177..0000000000 --- a/exist-core/src/test/java/org/exist/w3c/tests/TestCase.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Elemental - * Copyright (C) 2024, Evolved Binary Ltd - * - * admin@evolvedbinary.com - * https://www.evolvedbinary.com | https://www.elemental.xyz - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; version 2.1. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * NOTE: Parts of this file contain code from 'The eXist-db Authors'. - * The original license header is included below. - * - * ===================================================================== - * - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.w3c.tests; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.lang.reflect.Field; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; -import java.util.Properties; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.OutputKeys; - -import junit.framework.Assert; - -import org.custommonkey.xmlunit.Diff; -import org.exist.Namespaces; -import org.exist.collections.Collection; -import org.exist.dom.persistent.NodeProxy; -import org.exist.dom.memtree.NodeImpl; -import org.exist.dom.memtree.SAXAdapter; -import org.exist.security.Subject; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.serializers.EXistOutputKeys; -import org.exist.test.ExistEmbeddedServer; -import org.exist.util.ExistSAXParserFactory; -import org.exist.util.FileUtils; -import org.exist.xmldb.LocalCollection; -import org.exist.xmldb.LocalXMLResource; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.AtomicValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceIterator; -import org.junit.*; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xmldb.api.base.ErrorCodes; -import org.xmldb.api.base.Resource; -import org.xmldb.api.base.XMLDBException; - -/** - * @author Dmitriy Shabanov - * - */ -public abstract class TestCase { - protected static DBBroker broker = null; - protected static Collection testCollection = null; - - public static final String testLocation = "test/external/"; - - @ClassRule - public static final ExistEmbeddedServer existEmbeddedServer = new ExistEmbeddedServer(true, true); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - final BrokerPool pool = existEmbeddedServer.getBrokerPool(); - broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject())); - Assert.assertNotNull(broker); - } - - @Before - public void setUp() throws Exception { - if (testCollection == null) { - final BrokerPool pool = existEmbeddedServer.getBrokerPool(); - synchronized (pool) { - if (testCollection == null) { - testCollection = broker.getCollection(getCollection()); - if (testCollection == null) { - loadTS(); - testCollection = broker.getCollection(getCollection()); - if (testCollection == null) { - Assert.fail("There is no Test Suite data at database"); - } - } - } - } - } - } - - public abstract void loadTS() throws Exception; - - @AfterClass - public static void tearDownAfterClass() throws Exception { - if(broker != null) { - broker.close(); - } - } - - protected abstract XmldbURI getCollection(); - - public Exception catchError(Sequence result) { - - try { - for(SequenceIterator i = result.iterate(); i.hasNext(); ) { - Resource xmldbResource = getResource(i.nextItem()); - - xmldbResource.getContent().toString(); - } - } catch (Exception e) { - return e; - } - return null; - } - - public boolean compareResult(String testCase, String folder, Element outputFile, Sequence result) { - if (outputFile == null) - Assert.fail("no expected result information"); - - Path expectedResult = Paths.get(testLocation+folder, outputFile.getTextContent()); - if (!Files.isReadable(expectedResult)) { - Assert.fail("can't read expected result"); - } - - String compare = outputFile.getAttribute("compare"); - if (compare.isEmpty()) { - compare = "Fragment"; - } - compare = compare.toUpperCase(); - - try(final Reader reader = Files.newBufferedReader(expectedResult)) { - - if (result.isEmpty() && FileUtils.sizeQuietly(expectedResult) > 0) { - return false; - } - - int pos = 0; - for(SequenceIterator i = result.iterate(); i.hasNext(); ) { - Resource xmldbResource = getResource(i.nextItem()); - -// StringBuilderWriter writer = new StringBuilderWriter(); -// Properties outputProperties = new Properties(); -// outputProperties.setProperty("indent", "yes"); -// SAXSerializer serializer = new SAXSerializer(writer, outputProperties); -// xmldbResource.getContentAsSAX(serializer); - - String res = xmldbResource.getContent().toString(); - - int l; - //expected result length is only one result - if (result.getItemCount() == 1) { - l = (int) FileUtils.sizeQuietly(expectedResult); - } - - //caught-on length on last result - else if (!i.hasNext()) { - l = (int) FileUtils.sizeQuietly(expectedResult); - } - - else - l = res.length(); - - l += fixResultLength(testCase); - - int skipped = 0; - char[] chars = new char[l]; - for (int x = 0; x < l; x++) { - - if (!reader.ready()) { - skipped += l - x; - break; - } - - chars[x] = (char)reader.read(); - - if (chars[x] == '\r') { - chars[x] = (char)reader.read(); - pos++; - } - - pos++; - } - - if ( (result.getItemCount() == 1 || !i.hasNext() ) && skipped != 0) { - char[] oldChars = chars; - chars = new char[l-skipped]; - System.arraycopy(oldChars, 0, chars, 0, l-skipped); - } - - String expResult = String.copyValueOf(chars); - - boolean ok = false; - - if (compare.equals("XML")) { - try { - ok = diffXML(expResult, res); - } catch (Exception e) { - } - } - - if (!ok) { - if (!expResult.equals(res)) - if (compare.equals("FRAGMENT") || compare.equals("INSPECT")) { - - try { - ok = diffXML(expResult, res); - } catch (Exception e) { - } - - if (!ok) { - //workaround problematic results - if (expResult.equals("") && (res.equals(""))) - ; - else - return false; - } - - } else { - //workaround problematic results - if (expResult.equals("&") && res.equals("&")) - ; - else if (expResult.equals("<") && res.equals("<")) - ; - else { - //last try - expResult = expResult.replaceAll("<","<"); - expResult = expResult.replaceAll(">",">"); - expResult = expResult.replaceAll("&","&"); - if (!expResult.equals(res)) - return false; - } - } - - if ((compare.equals("TEXT") || compare.equals("FRAGMENT")) && (i.hasNext())) { - reader.mark(1); - if (' ' != (char)reader.read()) - reader.reset(); - else - pos++; - } - } - } - } catch (Exception e) { - return false; - } - - return true; - } - - public int fixResultLength(String testCase) { - return 0; - } - - private boolean diffXML(String expResult, String res) throws SAXException, IOException { - res = res.replaceAll("\n", ""); - res = res.replaceAll("\t", ""); - expResult = expResult.replaceAll("\n", ""); - expResult = expResult.replaceAll("\t", ""); - - Diff diff = new Diff(expResult.trim(), res); - if (!diff.identical()) { - System.out.println("expected:"); - System.out.println(expResult); - System.out.println("get:"); - System.out.println(res); - System.out.println(diff.toString()); - return false; - } - - return true; - } - - public final static String NORMALIZE_HTML = "normalize-html"; - - protected final static Properties defaultProperties = new Properties(); - static { - defaultProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); - defaultProperties.setProperty(OutputKeys.INDENT, "no"); - defaultProperties.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "yes"); - defaultProperties.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no"); - defaultProperties.setProperty(NORMALIZE_HTML, "yes"); - } - - public Resource getResource(Object r) throws XMLDBException { - LocalCollection collection = null; - Subject user = null; - - LocalXMLResource res = null; - final BrokerPool pool = existEmbeddedServer.getBrokerPool(); - if (r instanceof NodeProxy) { - NodeProxy p = (NodeProxy) r; - res = new LocalXMLResource(user, pool, collection, p); - } else if (r instanceof Node) { - res = new LocalXMLResource(user, pool, collection, XmldbURI.EMPTY_URI); - res.setContentAsDOM((Node)r); - } else if (r instanceof AtomicValue) { - res = new LocalXMLResource(user, pool, collection, XmldbURI.EMPTY_URI); - res.setContent(r); - } else if (r instanceof LocalXMLResource) - res = (LocalXMLResource) r; - else - throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "unknown object "+r.getClass()); - - try { - Field field = res.getClass().getDeclaredField("outputProperties"); - field.setAccessible(true); - field.set(res, new Properties(defaultProperties)); - } catch (Exception e) { - } - return res; - } - - public NodeImpl loadVarFromURI(XQueryContext context, String uri) throws IOException { - SAXAdapter adapter = new SAXAdapter(null, context); - - SAXParserFactory factory = ExistSAXParserFactory.getSAXParserFactory(); - factory.setNamespaceAware(true); - - XMLReader xr; - try { - SAXParser parser = factory.newSAXParser(); - - xr = parser.getXMLReader(); - xr.setContentHandler(adapter); - xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter); - - } catch (Exception e) { - throw new IOException(e); - } - - try(final InputStreamReader isr = new InputStreamReader(new FileInputStream(uri), "UTF-8")) { -// URL url = new URL(uri); -// InputStreamReader isr = new InputStreamReader(url.openStream(), "UTF-8"); - InputSource src = new InputSource(isr); - xr.parse(src); - - adapter.getDocument().setDocumentURI(new File(uri).getAbsoluteFile().toString()); - - return (NodeImpl) adapter.getDocument(); - } catch (SAXException e) { - - //workaround BOM - if (e.getMessage().equals("Content is not allowed in prolog.")) { - try { - String xml = readFileAsString(Paths.get(uri)); - xml = xml.trim().replaceFirst("^([\\W]+)<","<"); - InputSource src = new InputSource(new StringReader(xml)); - xr.parse(src); - - adapter.getDocument().setDocumentURI(new File(uri).getAbsoluteFile().toString()); - - return (NodeImpl) adapter.getDocument(); - } catch (SAXException e1) { - throw new IOException(e); - } - } - throw new IOException(e); - } - } - - public NodeImpl loadVarFromString(XQueryContext context, String source) throws IOException { - SAXAdapter adapter = new SAXAdapter(null, context); - - SAXParserFactory factory = ExistSAXParserFactory.getSAXParserFactory(); - factory.setNamespaceAware(true); - - XMLReader xr; - try { - SAXParser parser = factory.newSAXParser(); - - xr = parser.getXMLReader(); - xr.setContentHandler(adapter); - xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter); - - } catch (Exception e) { - throw new IOException(e); - } - - try { - InputSource src = new InputSource(new StringReader(source)); - xr.parse(src); - - return (NodeImpl) adapter.getDocument(); - } catch (SAXException e) { - throw new IOException(e); - } - } - - public static String readFileAsString(final Path file) throws IOException { - return new String(Files.readAllBytes(file)); - } - - public static String readFileAsString(final Path file, final long limit) throws IOException { - if (FileUtils.sizeQuietly(file) >= limit) { - return "DATA TOO BIG"; - } - return readFileAsString(file); - } - - public String sequenceToString(Sequence seq) { - StringBuilder res = new StringBuilder(); - try { - for(SequenceIterator i = seq.iterate(); i.hasNext(); ) { - Resource resource = getResource(i.nextItem()); - res.append(resource.getContent().toString()); - if (i.hasNext()) res.append(" "); - - //avoid to big output - if (res.length() >= 1024) return "{TOO BIG}"; - } - } catch (Exception e) { - res.append(e.getMessage()); - } - return res.toString(); - } -} diff --git a/exist-core/src/test/java/org/exist/xmldb/TestEXistXMLSerialize.java b/exist-core/src/test/java/org/exist/xmldb/EXistXMLSerializeTest.java similarity index 99% rename from exist-core/src/test/java/org/exist/xmldb/TestEXistXMLSerialize.java rename to exist-core/src/test/java/org/exist/xmldb/EXistXMLSerializeTest.java index 1fc318c44a..75f4e5be76 100644 --- a/exist-core/src/test/java/org/exist/xmldb/TestEXistXMLSerialize.java +++ b/exist-core/src/test/java/org/exist/xmldb/EXistXMLSerializeTest.java @@ -89,7 +89,7 @@ * * @author bmadigan */ -public class TestEXistXMLSerialize { +public class EXistXMLSerializeTest { @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); diff --git a/exist-core/src/test/java/org/exist/xmldb/DOMTestJUnit.java b/exist-core/src/test/java/org/exist/xmldb/RemoteDOMTest.java similarity index 77% rename from exist-core/src/test/java/org/exist/xmldb/DOMTestJUnit.java rename to exist-core/src/test/java/org/exist/xmldb/RemoteDOMTest.java index 44a252d10e..e327b28cb8 100644 --- a/exist-core/src/test/java/org/exist/xmldb/DOMTestJUnit.java +++ b/exist-core/src/test/java/org/exist/xmldb/RemoteDOMTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -40,7 +64,7 @@ * @author jmv * @author Pierrick Brihaye */ -public class DOMTestJUnit extends RemoteDBTest { +public class RemoteDOMTest extends RemoteDBTest { private static String name = "test.xml"; private Collection rootColl; private Database database; diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentTestBase.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/AbstractConcurrentTest.java similarity index 86% rename from exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentTestBase.java rename to exist-core/src/test/java/org/exist/xmldb/concurrent/AbstractConcurrentTest.java index d49f547650..12d1d3d8fa 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentTestBase.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/AbstractConcurrentTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -44,7 +68,7 @@ * @author wolf * @author aretter */ -public abstract class ConcurrentTestBase { +public abstract class AbstractConcurrentTest { private static String COLLECTION_CONFIG = "" + @@ -95,7 +119,7 @@ public final void tearDownDb() throws XMLDBException { * * @return the runners for the test. */ - public abstract List getRunners(); + public abstract List getRunners() throws IOException; public Collection getTestCollection() { return testCol; @@ -155,6 +179,8 @@ public void concurrent() throws Exception { try { Thread.sleep(50); } catch (final InterruptedException e) { + // Restore the interrupted status + Thread.currentThread().interrupt(); failed = true; failedException = e; break; // exit while-loop diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java index 9acc1b8cd2..c8a0d0f64d 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ComplexUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -32,7 +56,7 @@ /** * @author wolf */ -public class ComplexUpdateTest extends ConcurrentTestBase { +public class ComplexUpdateTest extends AbstractConcurrentTest { private static final String XML = ""; diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java index 5e8fe60d91..3e48a53717 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentAttrUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -37,7 +61,7 @@ /** * @author wolf */ -public class ConcurrentAttrUpdateTest extends ConcurrentTestBase { +public class ConcurrentAttrUpdateTest extends AbstractConcurrentTest { // private static final String QUERY = // "//ELEMENT[@attribute-1]"; diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java index 660da26016..97c7b26c92 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -35,7 +59,7 @@ /** * @author wolf */ -public class ConcurrentQueryTest extends ConcurrentTestBase { +public class ConcurrentQueryTest extends AbstractConcurrentTest { private static final String QUERY0 = "/ROOT-ELEMENT/ELEMENT/ELEMENT-1/ELEMENT-2[@attribute-3]"; private static final String QUERY1 = "distinct-values(//ELEMENT/@attribute-2)"; diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java index c7c0b8d90f..69d60ed4fe 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentQueryUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -35,7 +59,7 @@ import static org.junit.Assert.assertEquals; -public class ConcurrentQueryUpdateTest extends ConcurrentTestBase { +public class ConcurrentQueryUpdateTest extends AbstractConcurrentTest { @Before public void setUp() throws Exception { diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResource2Test.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResource2Test.java new file mode 100644 index 0000000000..e0c5109281 --- /dev/null +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResource2Test.java @@ -0,0 +1,112 @@ +/* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * + * eXist-db Open Source Native XML Database + * Copyright (C) 2001 The eXist-db Authors + * + * info@exist-db.org + * http://www.exist-db.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.exist.xmldb.concurrent; + +import com.evolvedbinary.j8fu.tuple.Tuple2; +import org.exist.samples.Samples; +import org.exist.util.StringInputSource; +import org.exist.util.io.InputStreamUtil; +import org.exist.xmldb.XmldbURI; +import org.exist.xmldb.concurrent.action.MultiResourcesAction; +import org.exist.xmldb.concurrent.action.XQueryAction; +import org.junit.Before; +import org.xml.sax.InputSource; +import org.xmldb.api.base.Collection; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static com.evolvedbinary.j8fu.tuple.Tuple.Tuple; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertNotNull; + +/** + * @author wolf + */ +public class ConcurrentResource2Test extends AbstractConcurrentTest { + + private static final String QUERY0 = + "declare default element namespace 'http://www.loc.gov/mods/v3';" + + "collection(\"" + XmldbURI.ROOT_COLLECTION + "\")//mods[contains(titleInfo/title, 'germany')]"; + + private static final String QUERY1 = + "declare default element namespace 'http://www.loc.gov/mods/v3';" + + "{for $t in distinct-values(collection(\"" + XmldbURI.ROOT_COLLECTION + "\")//mods/subject/topic) order by $t return {$t}}"; + + @Before + public void setUp() throws Exception { + Collection c1 = DBUtils.addCollection(getTestCollection(), "C1-C2"); + assertNotNull(c1); + } + + @Override + public String getTestCollectionName() { + return "C1"; + } + + @Override + public List getRunners() throws IOException { + final List> sources = new ArrayList<>(); + for (final String modsFilename : Samples.SAMPLES.getModsXmlSampleNames()) { + try (final InputStream is = Samples.SAMPLES.getModsSample(modsFilename)) { + final String modsContent = InputStreamUtil.readString(is, UTF_8); + sources.add(Tuple(modsFilename, new StringInputSource(modsContent))); + } + } + + return Arrays.asList( + new Runner(new MultiResourcesAction(sources, XmldbURI.LOCAL_DB + "/C1/C1-C2"), 100, 0, 50), + new Runner(new MultiResourcesAction(sources, XmldbURI.LOCAL_DB + "/C1/C1-C2"), 100, 0, 50), + new Runner(new XQueryAction(XmldbURI.LOCAL_DB + "/C1/C1-C2", "R1.xml", QUERY0), 100, 200, 100), + new Runner(new XQueryAction(XmldbURI.LOCAL_DB + "/C1/C1-C2", "R1.xml", QUERY1), 100, 300, 100) + //new Runner(new XQueryAction(getUri + "/C1/C1-C2", "R1.xml", QUERY0), 200, 400, 500), + //new Runner(new XQueryAction(getUri + "/C1/C1-C2", "R1.xml", QUERY1), 200, 500, 500) + ); + } +} diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java index e10ff56d06..302204de33 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -37,7 +61,7 @@ * * @author wolf */ -public class ConcurrentResourceTest extends ConcurrentTestBase { +public class ConcurrentResourceTest extends AbstractConcurrentTest { @Before public void setUp() throws Exception { diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest2.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest2.java deleted file mode 100644 index 8be9e44128..0000000000 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest2.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.xmldb.concurrent; - -import org.exist.xmldb.XmldbURI; -import org.exist.xmldb.concurrent.action.MultiResourcesAction; -import org.exist.xmldb.concurrent.action.XQueryAction; -import org.junit.Before; -import org.xmldb.api.base.Collection; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertNotNull; - -/** - * @author wolf - */ -public class ConcurrentResourceTest2 extends ConcurrentTestBase { - - private static final String QUERY0 = - "declare default element namespace 'http://www.loc.gov/mods/v3';" + - "collection(\"" + XmldbURI.ROOT_COLLECTION + "\")//mods[titleInfo/title &= 'germany']"; - - private static final String QUERY1 = - "declare default element namespace 'http://www.loc.gov/mods/v3';" + - "{for $t in distinct-values(\"" + XmldbURI.ROOT_COLLECTION + "\")//mods/subject/topic) order by $t return {$t}}"; - - @Before - public void setUp() throws Exception { - Collection c1 = DBUtils.addCollection(getTestCollection(), "C1-C2"); - assertNotNull(c1); - } - - @Override - public String getTestCollectionName() { - return "C1"; - } - - @Override - public List getRunners() { - return Arrays.asList( - new Runner(new MultiResourcesAction("samples/mods", XmldbURI.LOCAL_DB + "/C1/C1-C2"), 200, 0, 50), - new Runner(new MultiResourcesAction("samples/mods", XmldbURI.LOCAL_DB + "/C1/C1-C2"), 200, 0, 50), - new Runner(new XQueryAction(XmldbURI.LOCAL_DB + "/C1/C1-C2", "R1.xml", QUERY0), 200, 200, 100), - new Runner(new XQueryAction(XmldbURI.LOCAL_DB + "/C1/C1-C2", "R1.xml", QUERY1), 200, 300, 100) - //new Runner(new XQueryAction(getUri + "/C1/C1-C2", "R1.xml", QUERY0), 200, 400, 500), - //new Runner(new XQueryAction(getUri + "/C1/C1-C2", "R1.xml", QUERY1), 200, 500, 500) - ); - } -} diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest3.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest3.java deleted file mode 100644 index 86d0f3624f..0000000000 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentResourceTest3.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.xmldb.concurrent; - -import org.exist.xmldb.XmldbURI; -import org.exist.xmldb.concurrent.action.MultiResourcesAction; -import org.exist.xmldb.concurrent.action.XQueryAction; -import org.junit.Before; -import org.xmldb.api.base.Collection; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertNotNull; - -/** - * @author wolf - */ -public class ConcurrentResourceTest3 extends ConcurrentTestBase { - - private static final String FILES_DIR = "/home/wolf/xml/movies"; - private static final String QUERY0 = "collection('" + XmldbURI.ROOT_COLLECTION + "')/movie"; - - @Before - public void setUp() throws Exception { - final Collection c1 = DBUtils.addCollection(getTestCollection(), "C1-C2"); - assertNotNull(c1); - } - - @Override - public String getTestCollectionName() { - return "C1"; - } - - @Override - public List getRunners() { - return Arrays.asList( - new Runner(new MultiResourcesAction(FILES_DIR, XmldbURI.LOCAL_DB + "/C1/C1-C2"), 1, 0, 0), - new Runner(new XQueryAction(XmldbURI.LOCAL_DB + "/C1/C1-C2", "R1.xml", QUERY0), 1500, 200, 100) - ); - } -} diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java index 3cd1ae888c..ef22696433 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ConcurrentXUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -41,7 +65,7 @@ * * @author wolf */ -public class ConcurrentXUpdateTest extends ConcurrentTestBase { +public class ConcurrentXUpdateTest extends AbstractConcurrentTest { private static final String CONFIG = "" + diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/DBUtils.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/DBUtils.java index f7fc3102d6..926c13924f 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/DBUtils.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/DBUtils.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -29,6 +53,7 @@ import org.exist.source.Source; import org.exist.source.StringSource; import org.exist.xmldb.EXistXQueryService; +import org.xml.sax.InputSource; import org.xmldb.api.base.*; import org.xmldb.api.modules.CollectionManagementService; import org.xmldb.api.modules.XMLResource; @@ -123,6 +148,13 @@ public static void addXMLResource(final Collection col, final String resourceId, col.storeResource(res); } + + public static void addXMLResource(final Collection col, final String resourceId, final InputSource source) throws XMLDBException { + final XMLResource res = (XMLResource) col.createResource(resourceId, "XMLResource"); + res.setContent(source); + col.storeResource(res); + } + public static ResourceSet query(final Collection collection, final String xpath) throws XMLDBException { final XPathQueryService service = getQueryService(collection); @@ -173,4 +205,5 @@ public static String[] wordList() throws XMLDBException { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e); } } + } diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java index 907eb41182..6bc2af5486 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/FragmentsTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -28,7 +52,7 @@ import java.util.Arrays; import java.util.List; -public class FragmentsTest extends ConcurrentTestBase { +public class FragmentsTest extends AbstractConcurrentTest { private final static String QUERY = "let $node := " + diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java index 6af89b91f0..67110a6e28 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/TextUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -31,7 +55,7 @@ /** * @author wolf */ -public class TextUpdateTest extends ConcurrentTestBase { +public class TextUpdateTest extends AbstractConcurrentTest { private static final String XML = "
"; diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java index 5acc4a2eeb..1e73ff96e8 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/ValueIndexUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -32,7 +56,7 @@ /** * @author wolf */ -public class ValueIndexUpdateTest extends ConcurrentTestBase { +public class ValueIndexUpdateTest extends AbstractConcurrentTest { private static final String XCONF = "" + diff --git a/exist-core/src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java b/exist-core/src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java index 1cbff274a3..f71f9bd134 100644 --- a/exist-core/src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java +++ b/exist-core/src/test/java/org/exist/xmldb/concurrent/action/MultiResourcesAction.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -22,13 +46,11 @@ package org.exist.xmldb.concurrent.action; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; -import org.exist.util.FileUtils; +import com.evolvedbinary.j8fu.tuple.Tuple2; import org.exist.xmldb.concurrent.DBUtils; +import org.xml.sax.InputSource; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; @@ -37,12 +59,11 @@ * @author wolf */ public class MultiResourcesAction extends Action { - - private final String dirPath; + private final List> sources; - public MultiResourcesAction(final String dirPath, final String collectionPath) { + public MultiResourcesAction(final List> sources, final String collectionPath) { super(collectionPath, ""); - this.dirPath = dirPath; + this.sources = sources; } @Override @@ -52,17 +73,9 @@ public boolean execute() throws XMLDBException, IOException { return true; } - private void addFiles(final Collection col) throws XMLDBException, IOException { - final Path d = Paths.get(dirPath); - if(!(Files.isReadable(d) && Files.isDirectory(d))) { - throw new RuntimeException("Cannot read directory: " + dirPath); - } - - final List files = FileUtils.list(d); - for(final Path file : files) { - if(Files.isRegularFile(file)) { - DBUtils.addXMLResource(col, FileUtils.fileName(file), file); - } + private void addFiles(final Collection col) throws XMLDBException { + for (final Tuple2 source : sources) { + DBUtils.addXMLResource(col, source._1, source._2); } } } diff --git a/exist-core/src/test/java/org/exist/xquery/CardinalityTest.java b/exist-core/src/test/java/org/exist/xquery/CardinalityTest.java index 5b4e588487..8d53ab485a 100644 --- a/exist-core/src/test/java/org/exist/xquery/CardinalityTest.java +++ b/exist-core/src/test/java/org/exist/xquery/CardinalityTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -23,10 +47,10 @@ import org.junit.Test; -import static junit.framework.TestCase.assertTrue; import static org.exist.xquery.Cardinality.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Adam Retter diff --git a/exist-core/src/test/java/org/exist/xquery/CleanupTest.java b/exist-core/src/test/java/org/exist/xquery/CleanupTest.java index c5d8c92a22..16797c3e9c 100644 --- a/exist-core/src/test/java/org/exist/xquery/CleanupTest.java +++ b/exist-core/src/test/java/org/exist/xquery/CleanupTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.xquery; import org.exist.EXistException; @@ -41,9 +64,9 @@ import java.util.List; import java.util.Optional; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; /** * Test if inline functions and functions defined in imported modules are properly reset. diff --git a/exist-core/src/test/java/org/exist/xquery/ImportFromPkgTest.java b/exist-core/src/test/java/org/exist/xquery/ImportFromPkgTest.java index 0b8ceb14f5..c99b5d33a5 100644 --- a/exist-core/src/test/java/org/exist/xquery/ImportFromPkgTest.java +++ b/exist-core/src/test/java/org/exist/xquery/ImportFromPkgTest.java @@ -63,9 +63,9 @@ public void printPackages() throws XMLDBException { final ResourceSet resultSet = existXmldbEmbeddedServer.executeQuery(query); - for (int i = 0; i < resultSet.getSize(); i++) { - System.out.println(resultSet.getResource(i).getContent().toString()); - } + assertEquals(2, resultSet.getSize()); + assertEquals("functx.xsl", resultSet.getResource(0).getContent().toString()); + assertEquals("functx.xq", resultSet.getResource(1).getContent().toString()); } @Test diff --git a/exist-core/src/test/java/org/exist/xquery/TestXPathOpOrSpecialCase.java b/exist-core/src/test/java/org/exist/xquery/XPathOpOrSpecialCaseTest.java similarity index 74% rename from exist-core/src/test/java/org/exist/xquery/TestXPathOpOrSpecialCase.java rename to exist-core/src/test/java/org/exist/xquery/XPathOpOrSpecialCaseTest.java index 5d070278a4..92b09e7d8f 100644 --- a/exist-core/src/test/java/org/exist/xquery/TestXPathOpOrSpecialCase.java +++ b/exist-core/src/test/java/org/exist/xquery/XPathOpOrSpecialCaseTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -38,9 +62,9 @@ * source code. * @author Jason Smith */ -public class TestXPathOpOrSpecialCase extends Assert { +public class XPathOpOrSpecialCaseTest extends Assert { - private static final Logger LOG = LogManager.getLogger(TestXPathOpOrSpecialCase.class); + private static final Logger LOG = LogManager.getLogger(XPathOpOrSpecialCaseTest.class); @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); diff --git a/exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstruction.java b/exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstructionTest.java similarity index 63% rename from exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstruction.java rename to exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstructionTest.java index 30c1883a44..9f647a9439 100644 --- a/exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstruction.java +++ b/exist-core/src/test/java/org/exist/xquery/XQueryProcessingInstructionTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -36,7 +60,7 @@ * * @author jimfuller */ -public class XQueryProcessingInstruction { +public class XQueryProcessingInstructionTest { @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); diff --git a/exist-core/src/test/java/org/exist/xquery/XmldbBinariesTest.java b/exist-core/src/test/java/org/exist/xquery/XmldbBinariesTest.java index 3bdacdb9d9..312b1b18d5 100644 --- a/exist-core/src/test/java/org/exist/xquery/XmldbBinariesTest.java +++ b/exist-core/src/test/java/org/exist/xquery/XmldbBinariesTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -19,7 +43,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - package org.exist.xquery; import org.exist.test.ExistWebServer; @@ -53,7 +76,7 @@ public class XmldbBinariesTest extends AbstractBinariesTest data() { return Arrays.asList(new Object[][] { -// { "local", "xmldb:exist://" }, + { "local", "xmldb:exist://" }, { "remote", "xmldb:exist://localhost:" + PORT_PLACEHOLDER + "/xmlrpc" } }); } diff --git a/exist-core/src/test/java/org/exist/xquery/functions/validate/JaxvTest.java b/exist-core/src/test/java/org/exist/xquery/functions/validate/JaxvTest.java index 321811e64b..e6167b3cc5 100644 --- a/exist-core/src/test/java/org/exist/xquery/functions/validate/JaxvTest.java +++ b/exist-core/src/test/java/org/exist/xquery/functions/validate/JaxvTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -99,6 +123,18 @@ public void xsd_stored_valid() throws XMLDBException { results.getResource(0).getContent().toString()); } + @Test + public void xsd_stored_invalid() throws XMLDBException { + final String query = "validation:jaxv( " + + "doc('/db/personal/personal-invalid.xml'), " + + "doc('/db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "false", + results.getResource(0).getContent().toString()); + } + @Test public void xsd_stored_report_valid() throws XMLDBException, SAXException, IOException, XpathException { final String query = "validation:jaxv-report( " + @@ -113,7 +149,7 @@ public void xsd_stored_report_valid() throws XMLDBException, SAXException, IOExc } @Test - public void xsd_stored_invalid() throws XMLDBException, SAXException, IOException, XpathException { + public void xsd_stored_report_invalid() throws XMLDBException, SAXException, IOException, XpathException { final String query = "validation:jaxv-report( " + "doc('/db/personal/personal-invalid.xml'), " + "doc('/db/personal/personal.xsd') )"; @@ -127,6 +163,30 @@ public void xsd_stored_invalid() throws XMLDBException, SAXException, IOExceptio @Test public void xsd_anyuri_valid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-valid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "true", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_anyuri_invalid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-invalid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "false", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_anyuri_report_valid() throws XMLDBException, SAXException, IOException, XpathException { final String query = "validation:jaxv-report( " + "xs:anyURI('xmldb:exist:///db/personal/personal-valid.xml'), " + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; @@ -139,7 +199,7 @@ public void xsd_anyuri_valid() throws XMLDBException, SAXException, IOException, } @Test - public void xsd_anyuri_invalid() throws XMLDBException, SAXException, IOException, XpathException { + public void xsd_anyuri_report_invalid() throws XMLDBException, SAXException, IOException, XpathException { final String query = "validation:jaxv-report( " + "xs:anyURI('xmldb:exist:///db/personal/personal-invalid.xml'), " + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; @@ -150,4 +210,104 @@ public void xsd_anyuri_invalid() throws XMLDBException, SAXException, IOExceptio final String r = (String) results.getResource(0).getContent(); assertXpathEvaluatesTo("invalid", "//status/text()", r); } + + @Test + public void xsd_stored_anyuri_valid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "doc('/db/personal/personal-valid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "true", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_stored_anyuri_invalid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "doc('/db/personal/personal-invalid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "false", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_stored_anyuri_report_valid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv-report( " + + "doc('/db/personal/personal-valid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + + final String r = (String) results.getResource(0).getContent(); + assertXpathEvaluatesTo("valid", "//status/text()", r); + } + + @Test + public void xsd_stored_anyuri_report_invalid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv-report( " + + "doc('/db/personal/personal-invalid.xml'), " + + "xs:anyURI('xmldb:exist:///db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + + final String r = (String) results.getResource(0).getContent(); + assertXpathEvaluatesTo("invalid", "//status/text()", r); + } + + @Test + public void xsd_anyuri_stored_valid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-valid.xml'), " + + "doc('/db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "true", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_anyuri_stored_invalid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-invalid.xml'), " + + "doc('/db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + assertEquals(query, "false", + results.getResource(0).getContent().toString()); + } + + @Test + public void xsd_anyuri_stored_report_valid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv-report( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-valid.xml'), " + + "doc('/db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + + final String r = (String) results.getResource(0).getContent(); + assertXpathEvaluatesTo("valid", "//status/text()", r); + } + + @Test + public void xsd_anyuri_stored_report_invalid() throws XMLDBException, SAXException, IOException, XpathException { + final String query = "validation:jaxv-report( " + + "xs:anyURI('xmldb:exist:///db/personal/personal-invalid.xml'), " + + "doc('/db/personal/personal.xsd') )"; + + final ResourceSet results = existEmbeddedServer.executeQuery(query); + assertEquals(1, results.getSize()); + + final String r = (String) results.getResource(0).getContent(); + assertXpathEvaluatesTo("invalid", "//status/text()", r); + } } diff --git a/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseDtdTestNOK.java b/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseDtdTestNOK.java deleted file mode 100644 index 6f7265033c..0000000000 --- a/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseDtdTestNOK.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.xquery.functions.validate; - -import org.custommonkey.xmlunit.exceptions.XpathException; -import org.exist.test.ExistXmldbEmbeddedServer; -import org.exist.util.io.InputStreamUtil; -import org.junit.*; - -import static org.exist.collections.CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE; -import static org.junit.Assert.*; -import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo; -import static org.exist.samples.Samples.SAMPLES; - -import java.io.IOException; -import java.io.InputStream; - -import org.xml.sax.SAXException; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; - -/** - * Tests for the validation:jaxp() function with DTDss. - * - * @author dizzzz@exist-db.org - */ -public class ParseDtdTestNOK { - - @ClassRule - public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); - - private static final String noValidation = "" + - "" + - "" + - ""; - - @BeforeClass - public static void prepareResources() throws Exception { - - // Switch off validation - Collection conf = null; - try { - conf = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "system/config/db/hamlet"); - ExistXmldbEmbeddedServer.storeResource(conf, DEFAULT_COLLECTION_CONFIG_FILE, noValidation.getBytes()); - } finally { - if(conf != null) { - conf.close(); - } - } - - // Store dtd test files - final String[] dtdTestFiles = { "catalog.xml", "hamlet_invalid.xml", "hamlet_nodoctype.xml", "hamlet_valid.xml", "hamlet_wrongdoctype.xml" }; - Collection collection = null; - try { - collection = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "hamlet"); - - for (final String dtdTestFile : dtdTestFiles) { - try (final InputStream is = SAMPLES.getSample("validation/dtd/" + dtdTestFile)) { - ExistXmldbEmbeddedServer.storeResource(collection, dtdTestFile, InputStreamUtil.readAll(is)); - } - } - } finally { - if(collection != null) { - collection.close(); - } - } - - Collection collection1 = null; - try { - collection1 = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "hamlet/dtd"); - try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet.dtd")) { - ExistXmldbEmbeddedServer.storeResource(collection1, "hamlet.dtd", InputStreamUtil.readAll(is)); - } - } finally { - if(collection1 != null) { - collection1.close(); - } - } - - } - - @Test - public void xsd_stored_valid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( " + - "doc('/db/hamlet/hamlet_valid.xml'), " + - "xs:anyURI('/db/hamlet/dtd/hamlet.dtd'), () )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("valid", "//status/text()", r); - } - - @Test - public void xsd_stored_invalid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report(doc('/db/hamlet/hamlet_invalid.xml'), " + - "xs:anyURI('/db/hamlet/dtd/hamlet.dtd'), () )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("invalid", "//status/text()", r); - } - - @Test - public void xsd_anyuri_valid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( " + - "xs:anyURI('/db/hamlet/hamlet_valid.xml'), " + - "xs:anyURI('/db/hamlet/dtd/hamlet.dtd'), () )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("valid", "//status/text()", r); - } - - @Test - public void xsd_anyuri_invalid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( " + - "xs:anyURI('/db/hamlet/hamlet_invalid.xml'), " + - "xs:anyURI('/db/hamlet/dtd/hamlet.dtd'), () )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("invalid", "//status/text()", r); - } -} diff --git a/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseXsdTestNOK.java b/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseXsdTestNOK.java deleted file mode 100644 index 291285e45e..0000000000 --- a/exist-core/src/test/java/org/exist/xquery/functions/validate/ParseXsdTestNOK.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * eXist-db Open Source Native XML Database - * Copyright (C) 2001 The eXist-db Authors - * - * info@exist-db.org - * http://www.exist-db.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.xquery.functions.validate; - -import org.custommonkey.xmlunit.exceptions.XpathException; -import org.exist.test.ExistXmldbEmbeddedServer; -import org.exist.util.io.InputStreamUtil; -import org.junit.*; - -import static org.exist.collections.CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE; -import static org.junit.Assert.*; -import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo; -import static org.exist.samples.Samples.SAMPLES; - -import java.io.IOException; -import java.io.InputStream; - -import org.xml.sax.SAXException; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; - -/** - * Tests for the validation:jing() function with SCHs. - * - * @author dizzzz@exist-db.org - */ -public class ParseXsdTestNOK { - - @ClassRule - public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); - - private static final String noValidation = "" + - "" + - "" + - ""; - - @BeforeClass - public static void prepareResources() throws Exception { - - // Switch off validation - Collection conf = null; - try { - conf = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "system/config/db/addressbook"); - ExistXmldbEmbeddedServer.storeResource(conf, DEFAULT_COLLECTION_CONFIG_FILE, noValidation.getBytes()); - } finally { - if(conf != null) { - conf.close(); - } - } - - // Store schematron 1.5 test files - Collection collection = null; - try { - collection = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "addressbook"); - - final String[] xsdTestFiles = { "addressbook.xsd", "addressbook_invalid.xml", "addressbook_valid.xml"}; - - for (final String xsdTestFile : xsdTestFiles) { - try (final InputStream is = SAMPLES.getSample("validation/addressbook/" + xsdTestFile)) { - ExistXmldbEmbeddedServer.storeResource(collection, xsdTestFile, InputStreamUtil.readAll(is)); - } - } - } finally { - if(collection != null) { - collection.close(); - } - } - } - - @Test - public void xsd_stored_valid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( " + - "doc('/db/addressbook/addressbook_valid.xml'), " + - "xs:anyURI('/db/addressbook/addressbook.xsd'), () )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("valid", "//status/text()", r); - } - - @Test @Ignore("todo") - public void xsd_stored_invalid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( doc('/db/tournament/1.5/Tournament-invalid.xml'), " + - "doc('/db/tournament/1.5/tournament-schema.sch') )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("invalid", "//status/text()", r); - } - - @Test @Ignore("todo") - public void xsd_anyuri_valid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( xs:anyURI('xmldb:exist:///db/tournament/1.5/Tournament-valid.xml'), " + - "xs:anyURI('xmldb:exist:///db/tournament/1.5/tournament-schema.sch') )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("valid", "//status/text()", r); - } - - @Test @Ignore("todo") - public void xsd_anyuri_invalid() throws XMLDBException, SAXException, IOException, XpathException { - final String query = "validation:jaxp-report( xs:anyURI('xmldb:exist:///db/tournament/1.5/Tournament-invalid.xml'), " + - "xs:anyURI('xmldb:exist:///db/tournament/1.5/tournament-schema.sch') )"; - - final ResourceSet results = existEmbeddedServer.executeQuery(query); - assertEquals(1, results.getSize()); - - final String r = (String) results.getResource(0).getContent(); - assertXpathEvaluatesTo("invalid", "//status/text()", r); - } -} diff --git a/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStoreTest2.java b/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java similarity index 85% rename from exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStoreTest2.java rename to exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java index 64cbb9411c..63ab771945 100644 --- a/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStoreTest2.java +++ b/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -50,7 +74,7 @@ * Due to limitation of ExistXmldbEmbeddedServer we need to split this test to two files. * It's not possible to have two instances of ExistXmldbEmbeddedServer at the same time. */ -public class DbStoreTest2 { +public class DbStore2Test { @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServerWithAnyURI = new ExistXmldbEmbeddedServer(false, true, diff --git a/exist-core/src/test/java/org/exist/xquery/update/AbstractTestUpdate.java b/exist-core/src/test/java/org/exist/xquery/update/AbstractUpdateTest.java similarity index 82% rename from exist-core/src/test/java/org/exist/xquery/update/AbstractTestUpdate.java rename to exist-core/src/test/java/org/exist/xquery/update/AbstractUpdateTest.java index 2d73d76c61..02d015b6d6 100644 --- a/exist-core/src/test/java/org/exist/xquery/update/AbstractTestUpdate.java +++ b/exist-core/src/test/java/org/exist/xquery/update/AbstractUpdateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -40,7 +64,7 @@ /** * @author Adam Retter */ -public abstract class AbstractTestUpdate { +public abstract class AbstractUpdateTest { @ClassRule public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); diff --git a/exist-core/src/test/java/org/exist/xquery/update/IndexIntegrationTest.java b/exist-core/src/test/java/org/exist/xquery/update/IndexIntegrationTest.java index fc1d0f1f71..c55aebedcb 100644 --- a/exist-core/src/test/java/org/exist/xquery/update/IndexIntegrationTest.java +++ b/exist-core/src/test/java/org/exist/xquery/update/IndexIntegrationTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -41,7 +65,7 @@ import static org.easymock.EasyMock.anyBoolean; -public class IndexIntegrationTest extends AbstractTestUpdate { +public class IndexIntegrationTest extends AbstractUpdateTest { private void run(final XmldbURI docUri, final String data, final BiConsumer setup, ConsumerE test) throws Exception { final XQueryService service = storeXMLStringAndGetQueryService(docUri.lastSegment().toString(), data); diff --git a/exist-core/src/test/java/org/exist/xquery/update/UpdateInsertTest.java b/exist-core/src/test/java/org/exist/xquery/update/UpdateInsertTest.java index ac097ded06..b564912172 100644 --- a/exist-core/src/test/java/org/exist/xquery/update/UpdateInsertTest.java +++ b/exist-core/src/test/java/org/exist/xquery/update/UpdateInsertTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -30,7 +54,7 @@ /** * @author Adam Retter */ -public class UpdateInsertTest extends AbstractTestUpdate { +public class UpdateInsertTest extends AbstractUpdateTest { private static final String EOL = System.getProperty("line.separator"); diff --git a/exist-core/src/test/java/org/exist/xquery/update/UpdateReplaceTest.java b/exist-core/src/test/java/org/exist/xquery/update/UpdateReplaceTest.java index 8ceddc4357..149a4ea1e2 100644 --- a/exist-core/src/test/java/org/exist/xquery/update/UpdateReplaceTest.java +++ b/exist-core/src/test/java/org/exist/xquery/update/UpdateReplaceTest.java @@ -60,7 +60,7 @@ import static org.junit.Assert.*; -public class UpdateReplaceTest extends AbstractTestUpdate { +public class UpdateReplaceTest extends AbstractUpdateTest { @Test public void replaceOnlyChildWhereParentHasNoAttributes() throws XMLDBException { diff --git a/exist-core/src/test/java/org/exist/xquery/update/UpdateValueTest.java b/exist-core/src/test/java/org/exist/xquery/update/UpdateValueTest.java index e2894380d7..bce889f6f9 100644 --- a/exist-core/src/test/java/org/exist/xquery/update/UpdateValueTest.java +++ b/exist-core/src/test/java/org/exist/xquery/update/UpdateValueTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -29,7 +53,7 @@ /** * @author Adam Retter */ -public class UpdateValueTest extends AbstractTestUpdate { +public class UpdateValueTest extends AbstractUpdateTest { @Test public void updateNamespacedAttribute() throws XMLDBException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTestCase.java b/exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTest.java similarity index 98% rename from exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTestCase.java rename to exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTest.java index 9e216aa47c..1ee5ae3662 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTestCase.java +++ b/exist-core/src/test/java/org/exist/xquery/value/AbstractTimeRelatedTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.fail; -public abstract class AbstractTimeRelatedTestCase { +public abstract class AbstractTimeRelatedTest { @BeforeClass public static void setUp() throws Exception { diff --git a/exist-core/src/test/java/org/exist/xquery/value/DateTest.java b/exist-core/src/test/java/org/exist/xquery/value/DateTest.java index 7e838ce6b9..aab5da89c3 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/DateTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/DateTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -37,7 +61,7 @@ * @author Piotr Kaminski */ @RunWith(ParallelRunner.class) -public class DateTest extends AbstractTimeRelatedTestCase { +public class DateTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) public void create1() throws XPathException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/DateTimeStampTest.java b/exist-core/src/test/java/org/exist/xquery/value/DateTimeStampTest.java index 4d27acc9fb..c529a861d1 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/DateTimeStampTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/DateTimeStampTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -26,7 +50,7 @@ import static org.junit.Assert.assertEquals; -public class DateTimeStampTest extends AbstractTimeRelatedTestCase { +public class DateTimeStampTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) diff --git a/exist-core/src/test/java/org/exist/xquery/value/DateTimeTest.java b/exist-core/src/test/java/org/exist/xquery/value/DateTimeTest.java index 12d1165d0e..c696a9d883 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/DateTimeTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/DateTimeTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -38,7 +62,7 @@ * @author Piotr Kaminski */ @RunWith(ParallelRunner.class) -public class DateTimeTest extends AbstractTimeRelatedTestCase { +public class DateTimeTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) public void create1() throws XPathException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/DayTimeDurationTest.java b/exist-core/src/test/java/org/exist/xquery/value/DayTimeDurationTest.java index c21280fd48..eab3d517e4 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/DayTimeDurationTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/DayTimeDurationTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -32,7 +56,7 @@ import static org.junit.Assert.assertTrue; @RunWith(ParallelRunner.class) -public class DayTimeDurationTest extends AbstractTimeRelatedTestCase { +public class DayTimeDurationTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) public void create1() throws XPathException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/DurationTest.java b/exist-core/src/test/java/org/exist/xquery/value/DurationTest.java index eeecca7a9a..806922acb6 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/DurationTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/DurationTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -34,7 +58,7 @@ * @author Piotr Kaminski */ @RunWith(ParallelRunner.class) -public class DurationTest extends AbstractTimeRelatedTestCase { +public class DurationTest extends AbstractTimeRelatedTest { @Test public void stringFormat1() throws XPathException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java b/exist-core/src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java index 52347e548d..5ad8d96fbd 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/SubSequenceRangeTest.java @@ -43,9 +43,9 @@ import java.util.Arrays; -import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Adam Retter diff --git a/exist-core/src/test/java/org/exist/xquery/value/TimeTest.java b/exist-core/src/test/java/org/exist/xquery/value/TimeTest.java index 7cac19b437..75052afa91 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/TimeTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/TimeTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -37,7 +61,7 @@ * @author Piotr Kaminski */ @RunWith(ParallelRunner.class) -public class TimeTest extends AbstractTimeRelatedTestCase { +public class TimeTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) public void create1() throws XPathException { diff --git a/exist-core/src/test/java/org/exist/xquery/value/YearMonthDurationTest.java b/exist-core/src/test/java/org/exist/xquery/value/YearMonthDurationTest.java index bd7ce51510..414c361b10 100644 --- a/exist-core/src/test/java/org/exist/xquery/value/YearMonthDurationTest.java +++ b/exist-core/src/test/java/org/exist/xquery/value/YearMonthDurationTest.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -32,7 +56,7 @@ import static org.junit.Assert.assertTrue; @RunWith(ParallelRunner.class) -public class YearMonthDurationTest extends AbstractTimeRelatedTestCase { +public class YearMonthDurationTest extends AbstractTimeRelatedTest { @Test(expected = XPathException.class) public void create1() throws XPathException { diff --git a/exist-core/src/test/resources/log4j2.xml b/exist-core/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/exist-core/src/test/resources/log4j2.xml +++ b/exist-core/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/exist-samples/pom.xml b/exist-samples/pom.xml index b4d6eaef46..a93bab55a3 100644 --- a/exist-samples/pom.xml +++ b/exist-samples/pom.xml @@ -109,6 +109,7 @@ pom.xml + src/main/java/org/exist/samples/Samples.java src/main/resources/org/exist/samples/ant/migrate.xml src/main/resources/org/exist/samples/xinclude/db2html.xsl src/main/resources/org/exist/samples/xinclude/xinclude.xml @@ -123,7 +124,9 @@ pom.xml src/main/resources/org/exist/samples/biblio.rdf + src/main/java/org/exist/samples/Samples.java src/main/resources/org/exist/samples/ant/migrate.xml + src/main/resources/org/exist/samples/mods/** src/main/resources/org/exist/samples/shakespeare/hamlet.xml src/main/resources/org/exist/samples/shakespeare/macbeth.xml src/main/resources/org/exist/samples/shakespeare/play.dtd diff --git a/exist-samples/src/main/java/org/exist/samples/Samples.java b/exist-samples/src/main/java/org/exist/samples/Samples.java index 98a9cfe4f5..f5146f45c8 100644 --- a/exist-samples/src/main/java/org/exist/samples/Samples.java +++ b/exist-samples/src/main/java/org/exist/samples/Samples.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -32,45 +56,45 @@ public class Samples { private Samples() {} /** - * Gets the path of the Address Book sample. + * Gets the Address Book sample. * - * @return The path to the Address Book sample + * @return The stream of the Address Book sample */ public @Nullable InputStream getAddressBookSample() { return getSample("validation/addressbook/addressbook.xsd"); } /** - * Gets the path of the Shakespeare Hamlet sample. + * Gets the Shakespeare Hamlet sample. * - * @return The path to the Shakespeare Hamlet sample + * @return The stream of the Shakespeare Hamlet sample */ public @Nullable InputStream getHamletSample() { return getShakespeareSample("hamlet.xml"); } /** - * Gets the path of the Shakespeare Romeo and Juliet sample. + * Gets the Shakespeare Romeo and Juliet sample. * - * @return The path to the Shakespeare Romeo and Juliet sample + * @return The stream of the Shakespeare Romeo and Juliet sample */ public @Nullable InputStream getRomeoAndJulietSample() { return getShakespeareSample("r_and_j.xml"); } /** - * Gets the path of the Macbeth sample. + * Gets the Shakespeare Macbeth sample. * - * @return The path to the Macbeth sample + * @return The stream of the Macbeth sample */ - public@Nullable InputStream getMacbethSample() { + public@Nullable InputStream getMacbethSample() { return getShakespeareSample("macbeth.xml"); } /** - * Get the names of just the Shakespeare XML data sample files. + * Get the names of just the Shakespeare XML sample files. * - * @return the names of the Shakespeare XML data files. + * @return the names of the Shakespeare XML files. */ public String[] getShakespeareXmlSampleNames() { return new String[] { "hamlet.xml", "macbeth.xml", "r_and_j.xml"}; @@ -86,11 +110,11 @@ public String[] getShakespeareSampleNames() { } /** - * Gets the path of the shakespeare sample. + * Gets the shakespeare sample. * * @param sampleFileName the name of the shakespeare sample. * - * @return The path to the shakespeare sample + * @return The stream of the Shakespeare sample */ public @Nullable InputStream getShakespeareSample(final String sampleFileName) { return getSample("shakespeare/" + sampleFileName); @@ -99,18 +123,59 @@ public String[] getShakespeareSampleNames() { /** * Gets the path of the Bibliographic sample. * - * @return The path to the Bibliographic sample + * @return The stream of the Bibliographic sample */ public @Nullable InputStream getBiblioSample() { return getSample("biblio.rdf"); } + /** + * Get the names of just the MODS XML data sample files. + * + * @return the names of the MODS XML data files. + */ + public String[] getModsXmlSampleNames() { + return new String[] { + "02db3b51-146d-4740-81c5-c22dcdadecfb.xml", + "0d569a0b-2738-4865-8b47-a9f8b821a653.xml", + "1a186ea9-d41a-4e03-8f0a-d3389cbcf769.xml", + "1a745d88-0d42-42e7-b911-26f1976bf41f.xml", + "321a0f72-8ecc-419c-992f-05b4000124e0.xml", + "36fe6751-7d83-4155-81f8-c00e515f07d1.xml", + "494ebe80-aa3c-457c-8c20-7de246bf5f72.xml", + "49afb9d1-71d8-49c2-8566-13eff9ff0935.xml", + "58f1eb27-0cec-4e2e-83f5-57d03123c194.xml", + "6bbce50c-8e1c-46cb-b804-9cd020816f63.xml", + "6fd69e78-77ca-4b2a-84c1-b22a24d676b3.xml", + "78f221c8-5bb0-4bf1-ad43-cf0aff6d53c7.xml", + "81fb0a7e-f268-4091-aae2-1e6ccb867930.xml", + "9f8877f7-2064-4ee5-92f5-a1b6afe68714.xml", + "b5c28abd-8a78-4a2d-b2eb-30d06d7dac10.xml", + "ba45cdc0-96d4-4181-a519-ed3f1f9f89cc.xml", + "ba5f637f-2ca5-4d07-b8b3-804dab7fbdb7.xml", + "be884622-f29f-42ba-8903-e5eda73bcf34.xml", + "dae9118e-573a-4230-b781-5007c0579f27.xml", + "f3ad5614-d1b4-4860-a108-542c42dceebf.xml" + }; + } + + /** + * Gets the MODS sample. + * + * @param sampleFileName the name of the MODS sample. + * + * @return The stream of the MODS sample + */ + public @Nullable InputStream getModsSample(final String sampleFileName) { + return getSample("mods/" + sampleFileName); + } + /** * Gets the sample. * * @param sample relative path to the sample * - * @return The stream to the sample + * @return The stream of the sample */ public @Nullable InputStream getSample(final String sample) { return getClass().getResourceAsStream(sample); diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/02db3b51-146d-4740-81c5-c22dcdadecfb.xml b/exist-samples/src/main/resources/org/exist/samples/mods/02db3b51-146d-4740-81c5-c22dcdadecfb.xml new file mode 100644 index 0000000000..60d7a48080 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/02db3b51-146d-4740-81c5-c22dcdadecfb.xml @@ -0,0 +1,49 @@ + + + + Motivational and Structural Prerequisites of Knowledge Management + Paper presented at the XV World Congress of + Sociology, Brisbane, Australia, July 7-13, 2002, RC 30 + Sociology of Work: Thematic Seminar II: The organisation of + knowledge production (Diskussionspapiere aus der Fakultät + für Sozialwissenschaft, Ruhr-Universität Bochum, Nr. 02-2) + + Our main question in this paper is: Which + motivational and structural prerequisites support knowledge + management? We will develop a theoretical model to answer + these questions and illustrate it with three case studies. + + Wilkesmann, Uwe + + + Rascher, Ingolf + + + http://www.ruhr-uni-bochum.de/sowi/top/sowibibliothek/dkpaper/dp02-2.pdf + + + Fakultät für Sozialwissenschaft, Ruhr-Universität Bochum + 2002-06-12 + + + application/pdf + + + knowledge management + + 10204 + 10207 + 10219 + + Bedingung + + + Informationsmanagement + + + Informationssystem + + + Wissenssoziologie + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/0d569a0b-2738-4865-8b47-a9f8b821a653.xml b/exist-samples/src/main/resources/org/exist/samples/mods/0d569a0b-2738-4865-8b47-a9f8b821a653.xml new file mode 100644 index 0000000000..15334bbc5d --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/0d569a0b-2738-4865-8b47-a9f8b821a653.xml @@ -0,0 +1,39 @@ + + + + The Interplay of Cash and Tax Benefits for Children in Ten European Countries + + Whereas cross-sectional comparative research on monetary support for families with children linking quantitative data on cash and tax benefits with institutional regulations and system characteristics seems to be well established, systematic analyses of the long-term lines of development, however, are still lacking. This article therefore aims at analysing the child-related elements of both instruments over a longer span of time. Partly based on a newly accessible database, the presentation uses a descriptive and institution-orientated approach. + + Maucher, Mathias + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no12-13/feature.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 2000 + + + text/html + + + + EURODATA Newsletter No.12/13 + + + 11007 + 1090303 + + Familienpolitik + + + Steuern + + + Steuerpolitik + + + Umverteilung + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/1a186ea9-d41a-4e03-8f0a-d3389cbcf769.xml b/exist-samples/src/main/resources/org/exist/samples/mods/1a186ea9-d41a-4e03-8f0a-d3389cbcf769.xml new file mode 100644 index 0000000000..2ee467dd53 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/1a186ea9-d41a-4e03-8f0a-d3389cbcf769.xml @@ -0,0 +1,63 @@ + + + + Causal Inference from Series of Events + + Recent years have witnessed an increased interest, + both in statistics and in the social sciences, in time + dependent models as a vehicle for the causal interpretation + of series of events. The Humean and empiricist tradition in + the philosophy of science uses the constant temporal order + of cause and effect as a decisive delineation of causal + processes from mere coincidences. To mimic the philosophical + distinction, series of events are modelled as dynamic + stochastic processes and the precedence of cause over effect + is expressed through conditional expectations given the + history of the process and the history of the causes. A main + technical tool in this development is the concept of + conditional independence. In this article we examine some + difficulties in the application of the approach within + empirical social research. Specifically, the role of + probabilistic concepts of causality and of conditional + independence, the nature of events that reasonalby qualify + as causes or effects, and the time order used in empirical + research are considered. + + Pötter, Ulrich + + + Blossfeld, H.-P. + + + http://www.stat.ruhr-uni-bochum.de/papers/cause2.ps + + + 2000-06-01 + + + application/postscript + + 10105 + 10102 + + Analyse + + + Erklärung + + + Inferenz + + + Kausalität + + + Methodenforschung + + + Modellanalyse + + + Wissenschaftsgeschichte + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/1a745d88-0d42-42e7-b911-26f1976bf41f.xml b/exist-samples/src/main/resources/org/exist/samples/mods/1a745d88-0d42-42e7-b911-26f1976bf41f.xml new file mode 100644 index 0000000000..431c62d945 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/1a745d88-0d42-42e7-b911-26f1976bf41f.xml @@ -0,0 +1,42 @@ + + + + The European population 1850-1945: A Historical Data Handbook + + This contribution describes the project which is to publish a historical data handbook on the European population in 21 European countries, covering the time period of the first demographic transition, the years 1850-1945. All eighteen Western European nations are included plus the three Eastern European countries Czechoslovakia, Hungary and Poland. The handbook covers such topics as population development; the population structure by sex, age and marital status; the regional population structure; annual vital statistics developments in the fields of population growth and migration, fertility and legitimacy, infant mortality and life expectancy, nuptiality and divortiality. Furthermore, household and family data have been collected systematically using the population censuses as a basis. The book comprises several introductory comparative chapters and 21 national chapters for each country. Extensive documentation of available data and sources concludes the volume. + + Rothenbacher, Franz + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no11/feature.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 2000 + + + text/html + + + + EURODATA Newsletter No.11 + + + 10303 + 10209 + + Bevölkerungsentwicklung + + + Demographie + + + Rezension + + + historisch + + + internationaler Vergleich + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/321a0f72-8ecc-419c-992f-05b4000124e0.xml b/exist-samples/src/main/resources/org/exist/samples/mods/321a0f72-8ecc-419c-992f-05b4000124e0.xml new file mode 100644 index 0000000000..7876ea415f --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/321a0f72-8ecc-419c-992f-05b4000124e0.xml @@ -0,0 +1,60 @@ + + + + Demography of Germany + Concepts, Data and Methods + + This text is an introduction to concepts and methods of demographic description and analysis. The substantial focus is on the demographic development ofgermany, all data refer to this country. The main reason for this focus on a single country is that we want to show how the tools of demography can actually be used for theanalysis of demographic problems. The text consists of two parts. Part I introduces the conceptual framework and explains basic statistical notions. This part also includesa short chapter that explains how we speak of "models" and why we do not make a sharp distinction between "describing" and "modeling" demographic processes. Then followsPart II that deals with data and methods. In the present version of the text, we almost exclusively discuss mortality and fertility data. + + Rohwer, Götz + + + Pötter, Ulrich + + + ftp://ftp.stat.ruhr-uni-bochum.de/pub/eha/ddem.ps + + + 2002-10-01 + 2003-03-01 + + + application/postscript + + 10301 + 10303 + 10105 + + Altersstruktur + + + Bevölkerungsstatistik + + + Kohortenanalyse + + + Lebensdauer + + + Lebenserwartung + + + Methodenlehre + + + Panel + + + Volkszählung + + + amtliche Statistik + + + deskriptive Statistik + + + statistische Analyse + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/36fe6751-7d83-4155-81f8-c00e515f07d1.xml b/exist-samples/src/main/resources/org/exist/samples/mods/36fe6751-7d83-4155-81f8-c00e515f07d1.xml new file mode 100644 index 0000000000..8cac8468eb --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/36fe6751-7d83-4155-81f8-c00e515f07d1.xml @@ -0,0 +1,47 @@ + + + + CATEWE - A Comparative Analysis of Transitions from Education to Work in Europe + + The transition from education to work is one of the most crucial phases in the life-cycle of individuals because it often channels and shapes individual careers and life chances. These transitions differ between European countries due to different educational systems, labour markets, and organization of societal work. + + Gangl, Markus + + + Hannan, Damian + + + Raffe, David + + + Smyth, Emer + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no8/catewe.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 1998 + + + text/html + + + + EURODATA Newsletter No.8 + + + 10208 + + Bildungswesen + + + berufliche Integration + + + dreigliedriges Schulwesen + + + internationaler Vergleich + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/494ebe80-aa3c-457c-8c20-7de246bf5f72.xml b/exist-samples/src/main/resources/org/exist/samples/mods/494ebe80-aa3c-457c-8c20-7de246bf5f72.xml new file mode 100644 index 0000000000..c017e9bdcc --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/494ebe80-aa3c-457c-8c20-7de246bf5f72.xml @@ -0,0 +1,79 @@ + + + + Who is Self-Employed in France, the United Kingdom and + West Germany? + Patterns of Non-Agricultural Self-Employment + + This paper investigates the patterns of male + non-agricultural self-employment and how they have changed + over time in France, Germany and the UK. It is arguedthatthe + development of self-employment in the three + countries is based on specific institutional frameworks + resulting in different opportunities for the + self-employed.Thus, weexpect that the dynamics of growth, + the sectors of activity and the + socio-demographic characteristics of the + self-employed differ between the countries. + Theempiricalanalyses are based on the national Labour Force + Surveys of 1984 and 1994 (Germany 1982 and 1995). Our + findings indicate that educational requirements + differfundamentally betweenthe three countries and along + industrial branches. Further, we could observe some + country-specific developments in some sectors of activitybut + also a remarkable number of commongeneral patterns in + the development of self-employment. + + Lohmann, Henning + + + Luber, Silvia + + + Müller, Walter + + + http://www.mzes.uni-mannheim.de/publications/wp/wp-11.pdf + + + Mannheimer Zentrum für Europäische Sozialforschung (MZES) + 1999 + 2003-06-13 + + + application/pdf + + + + Arbeitspapiere / Mannheimer Zentrum für + Europäische Sozialforschung, Nr. 11, ISSN 1437-8574 + + + 20101 + 20102 + 10205 + + Arbeitsmarkt + + + Bundesrepublik Deutschland + + + Frankreich + + + Großbritannien + + + Selbständiger + + + berufliche Selbständigkeit + + + freier Beruf + + + institutionelle Faktoren + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/49afb9d1-71d8-49c2-8566-13eff9ff0935.xml b/exist-samples/src/main/resources/org/exist/samples/mods/49afb9d1-71d8-49c2-8566-13eff9ff0935.xml new file mode 100644 index 0000000000..f6e1c290b2 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/49afb9d1-71d8-49c2-8566-13eff9ff0935.xml @@ -0,0 +1,38 @@ + + + + Comparative Electoral Systems: The German Experience + Constitution of Kenya Review Commission: Seminar on Electoral Systems and Political Parties. March 19-20, 2002, Serena Hotel Nairobi + + The mixed-member proportional system (MMPS), first introduced in the Federal Republic of Germany in 1949, is currently receiving increasing attention in countries in which electoral reforms are being considered. Are electoral experts and politicians, especially in Southern countries, right to consider the MMPS a model for electoral reform? And if so, which lessons can be drawn from the German experience for transferring the MMPS to other countries? In this paper, these questions are being addressed at both a theoretical and at an emprical level. At first, the MMPS will be situated within a broader typology of electoral systems. How the MMPS has worked in the context of German politics is discussed in a second section; the conclusion contains some recommendations for reform debates, especially the Kenyan context. + + Hartmann, Christof + + + http://homepage.ruhr-uni-bochum.de/christof.hartmann/downloads/2002-Kenia-Wahlen.PDF + + + 2002-03-19 + + + application/pdf + + 10503 + 10505 + 10504 + + Bundesrepublik Deutschland + + + Kenia + + + Systemvergleich + + + Wahlsystem + + + politische Reform + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/58f1eb27-0cec-4e2e-83f5-57d03123c194.xml b/exist-samples/src/main/resources/org/exist/samples/mods/58f1eb27-0cec-4e2e-83f5-57d03123c194.xml new file mode 100644 index 0000000000..124d6f1c60 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/58f1eb27-0cec-4e2e-83f5-57d03123c194.xml @@ -0,0 +1,39 @@ + + + + The Development of Trade Unions in Western Europe: Global Convergence or Cross-national Diversity? + + Trade unions play an important role in Western Europe. They have been subject to, and agents of, social and political changes that reshaped the post-war industrial society. In recent years, trade unions have been facing the threat of membership decline and the challenges of global competition and European economic integration. This poses the question whether union movements are under pressure to adapt in a similar way or whether they differ in their responses. Do we find a trend towards global convergence or does cross-national diversity persist among union movements in Western Europe? Drawing on comparative data from an international research project, we will provide a short portrait of the main patterns in union density and organisational concentration. Instead of a general trend toward convergence, we find signs of persisting diversity across Western Europe in union responses to both social changes and global challenges. + + Ebbinghaus,Bernhard + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no2/feature.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 1995 + + + text/html + + + + EURODATA Newsletter No.2 + + + 10204 + 10504 + + Europa + + + Gewerkschaft + + + Gewerkschaftsbewegung + + + historische Entwicklung + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/6bbce50c-8e1c-46cb-b804-9cd020816f63.xml b/exist-samples/src/main/resources/org/exist/samples/mods/6bbce50c-8e1c-46cb-b804-9cd020816f63.xml new file mode 100644 index 0000000000..99386243e1 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/6bbce50c-8e1c-46cb-b804-9cd020816f63.xml @@ -0,0 +1,47 @@ + + + + Managing Conflict Through Democratic Institutions: A Tentative Balance Sheet + African Studies Association in Germany (VAD): Biennial Conference "Africa's Diversity: Ending the Monologues?", Hamburg, May 23-26, 2002 + + The paper starts from the premise that the specific role of democratic institutions in conflict management is still not adequately considered in the African context, especially with regard to crisis prevention. Some of the main hypothesis drawn from the general literature on the topic are presented and three levers of democratic intervention, i.e. the system of government, the electoral system, and the territorial structure of the state, are tested with regard to Africa (including discussion of case studies). As a last step the paper deals with the specific African contexts of democratic reform that have to be taken into account in processes of institutional engineering. + + Hartmann, Christof + + + http://homepage.ruhr-uni-bochum.de/christof.hartmann/downloads/2002-VAD-Paper.pdf + + + 2002-05-23 + + + application/pdf + + 10507 + 10503 + 10505 + + Afrika + + + Demokratisierung + + + Staatsform + + + Staatsgebiet + + + Systemvergleich + + + Transformation + + + Wahlsystem + + + ethnischer Konflikt + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/6fd69e78-77ca-4b2a-84c1-b22a24d676b3.xml b/exist-samples/src/main/resources/org/exist/samples/mods/6fd69e78-77ca-4b2a-84c1-b22a24d676b3.xml new file mode 100644 index 0000000000..3183b012c2 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/6fd69e78-77ca-4b2a-84c1-b22a24d676b3.xml @@ -0,0 +1,41 @@ + + + + The Project on Comparative European Electoral History: 1830-1995. A computerised data handbook + + This project is aimed at collecting electoral data for all European countries both in a historical and a regional perspective. Data were made machine readable from the beginning of national elections in the 19th century until the present in a disaggregated form down to the level of electoral districts. The data will we published as an electronic data handbook, comprising full documentation and introductory chapters. + + Caramani, Daniele + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no4/feature.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 1996 + + + text/html + + + + EURODATA Newsletter No.4 + + + 10504 + + Datenaufbereitung + + + Datenbank + + + Europa + + + Wahlergebnis + + + politische Geschichte + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/78f221c8-5bb0-4bf1-ad43-cf0aff6d53c7.xml b/exist-samples/src/main/resources/org/exist/samples/mods/78f221c8-5bb0-4bf1-ad43-cf0aff6d53c7.xml new file mode 100644 index 0000000000..0d5f773abf --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/78f221c8-5bb0-4bf1-ad43-cf0aff6d53c7.xml @@ -0,0 +1,42 @@ + + + + Social Indicators for East European Transition Countries + + The East European transition countries have been facing severe problems regarding both economic performance and living conditions in general since the beginning of the transformation process in 1989. This is the reason why this topic has been chosen. It is intended to present some fundamental social indicators for the East European transition countries. The data presented refer to the whole of Eastern and South Eastern Europe, including the Western follow-up states of the former Soviet Union, i.e. the Baltic countries, Russia, Moldavia, Ukraine and Belarus. + + Rothenbacher, Franz + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no4/rothenb1.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 1996 + + + text/html + + + + EURODATA Newsletter No.4 + + + 10303 + 10305 + + Altersstruktur + + + Arbeitsmarktanalyse + + + Geburtenentwicklung + + + Osteuropaforschung + + + soziale Indikatoren + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/81fb0a7e-f268-4091-aae2-1e6ccb867930.xml b/exist-samples/src/main/resources/org/exist/samples/mods/81fb0a7e-f268-4091-aae2-1e6ccb867930.xml new file mode 100644 index 0000000000..85424eb8a9 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/81fb0a7e-f268-4091-aae2-1e6ccb867930.xml @@ -0,0 +1,60 @@ + + + + Renaissance of the German Carmakers during the 1990s: + Successful Japanization or the Development of a Genuine + Business Model? + + This chapter aims at explaining the renaissance of + the three German carmakers within the context of the + international automobile industry. The main argument is that + this revival can only be understood by referring to some + common elements of the business models in place at all three + companies. These business models include four basic pillars, + each of which answers a basic question at the core of the + firms activities: (1) the corporate structure and profit + strategies, (2) product structure and market strategies, (3) + the production system and (4) the labour relations regime. + A business model could thus be understood as the specific + configuration of structures and strategies in these four + activity fields and transformation spaces. This + configuration does not represent a deterministic and fixed + system but a sort of loosely coupled 'regime of affinity'. + + Pries, Ludger + + + http://www.ruhr-uni-bochum.de/soaps/download/publ-2003_lp_renaissancegercarmakers.pdf + + + 2003 + + + application/pdf + + + + Faust, Michael; Voskamp, Ulrich; Wittke, Volker + (eds.): European Industrial Restructuring in a Global + Economy: Fragmentation and Relocation of Value Chains. SOFI + Berichte, Göttingen: SOFI + + + + Geschäftsmodell + + + Volkswagen + + 10204 + 10207 + + Kraftfahrzeugindustrie + + + Unternehmenspolitik + + + internationaler Vergleich + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/9f8877f7-2064-4ee5-92f5-a1b6afe68714.xml b/exist-samples/src/main/resources/org/exist/samples/mods/9f8877f7-2064-4ee5-92f5-a1b6afe68714.xml new file mode 100644 index 0000000000..9fbdfe6028 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/9f8877f7-2064-4ee5-92f5-a1b6afe68714.xml @@ -0,0 +1,41 @@ + + + + The strengths and weaknesses of existing electoral models as instruments for managing ethnic conflict + Paper for the Centre of Conflict Resolution Seminar "Constitutionalism as a Primary Tool for Managing Ethnic Conflict in Africa", Cape Town, 24-26 May 2000 + + The paper argues that the choice of electoral systems has an impact on the change or the stability of inter-ethnic relations, and that electoral models may actually become an instrument for managing ethnic conflict. Cleverly designed electoral systems are, however, not considered being the only or most powerful of such instruments. For example, the decision for a more centralized or a more federal state or the introduction of some meaningful local government may be of more relevance to ethnic conflict management. The paper is divided in five main parts: Key terms and elements of electoral systems are introduced, followed by a typology of the most important parliamentary electoral systems. This general overview will cover a range of states with most empirical examples drawn from African contexts. The third part will briefly discuss the multiple criteria that might be used to evaluate electoral systems, followed by an assessment of the various electoral systems and their relationsship to conflict management. The last section deals with the generally neglected topic of different presidential electoral formulas and its impact on ethnic relationships. + + Hartmann, Christof + + + http://homepage.ruhr-uni-bochum.de/christof.hartmann/downloads/2000-Kapstadt.PDF + + + 2000-05-24 + + + application/pdf + + 10507 + 10503 + 10504 + + Afrika südlich der Sahara + + + Konfliktlösung + + + Systemvergleich + + + Wahlsystem + + + ethnischer Konflikt + + + politisches System + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/b5c28abd-8a78-4a2d-b2eb-30d06d7dac10.xml b/exist-samples/src/main/resources/org/exist/samples/mods/b5c28abd-8a78-4a2d-b2eb-30d06d7dac10.xml new file mode 100644 index 0000000000..56d1dd0e37 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/b5c28abd-8a78-4a2d-b2eb-30d06d7dac10.xml @@ -0,0 +1,42 @@ + + + + Household and Family Trends in Europe: from Convergence to Divergence + + The International Year of the Family 1994 together with the World Population Conference have drawn greater attention to the changing family. On the level of the European Union interest in the family was intensified, as the first steps taken towards the creation of a European household and family statistics and the strengthening of the European Observatory on National Family Policies (EONFP) show. In addition, other international organisations, such as the Council of Europe or the United Nations Economic Commission for Europe (ECE), have intensified their activities in the field of population and family research. In this context the question may be posed how household and family structures in Europe evolve. Not only for the European Union but also for sociological research in general the question of divergence or convergence of national household and family structures and of national demographic developments is of great importance. + + Rothenbacher, Franz + + + http://www.mzes.uni-mannheim.de/eurodata/newsletter/no1/househol.html + + + EURODATA Research Archive. Mannheim Centre for European Social Research (MZES) + 1995 + + + text/html + + + + EURODATA Newsletter No.1 + + + 10303 + 10209 + + Europa + + + Familiensoziologie + + + Familienstand + + + Familienstruktur + + + internationaler Vergleich + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/ba45cdc0-96d4-4181-a519-ed3f1f9f89cc.xml b/exist-samples/src/main/resources/org/exist/samples/mods/ba45cdc0-96d4-4181-a519-ed3f1f9f89cc.xml new file mode 100644 index 0000000000..d21c9e9737 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/ba45cdc0-96d4-4181-a519-ed3f1f9f89cc.xml @@ -0,0 +1,58 @@ + + + + Household Labor Demand and Household Labor Supply + An empirical analysis of the employment of + domestic help in German private households and its effect on + female labor force participation (Diskussionspapiere aus der + Fakultät für Sozialwissenschaft, Ruhr-Universität Bochum, + Nr. 98-14) + + In this paper, data from the German Socio-Economic + Panel (SOEP) will be used to examine the hypothesis that the + demand for domestic servants and women’s supply of market + work are joint decisions. + + Hank, Karsten + + + http://www.ruhr-uni-bochum.de/sowi/top/sowibibliothek/dkpaper/dp98-14.rtf + + + Fakultät für Sozialwissenschaft, Ruhr-Universität Bochum + 1998 + + + other + + + domestic work + + 20101 + 20102 + 20200 + + Arbeitsangebot + + + Arbeitskräftebedarf + + + Frauenerwerbstätigkeit + + + Hausarbeit + + + Panel + + + Privathaushalt + + + informeller Sektor + + + ungeschützte Beschäftigung + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/ba5f637f-2ca5-4d07-b8b3-804dab7fbdb7.xml b/exist-samples/src/main/resources/org/exist/samples/mods/ba5f637f-2ca5-4d07-b8b3-804dab7fbdb7.xml new file mode 100644 index 0000000000..949e6ac10a --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/ba5f637f-2ca5-4d07-b8b3-804dab7fbdb7.xml @@ -0,0 +1,40 @@ + + + + A Woman is Born. Production of Femininity in German o.b. Tampon Advertisements + Paper presented at 'Menstruation. Blood, Body, Brand.' Institute for Feminist Theory and Research, Liverpool, 24 January to 26. January 2003. + + Western feminists have criticised advertisements for female hygiene products for creating stereotypes and being normative and sexist since the 1970s. Despite this criticism recent studies have shown that (at least in Germany) the topics raised are relevant to women, and female hygiene products are increasingly retailed internationally. The range of feminist analysis and opinions has also become quite broad. Based on empirical research I want to look at ads for o.b. tampons, relating the tension between the regulation of the female (body) and advertising a taboo. I reviewed a sample of 47 ads from o.b. dating from the 1950s onwards that were placed in the popular German (middle-class) women's magazine Brigitte. Each ad was analysed according to recurring themes in text, context and tone, and for content related to the representation of femininity. The body as battleground for gender is an interactive process. On the one hand the body is an important medium and a central resource for performing gender; on the other hand this performance takes place in semiotic and discursive contexts, which configure the intelligibility of the gender difference. I want to consider both aspects by taking the body-here the female body or rather femininity-seriously in the discursive moment of advertisements. I focus mainly on the following three aspects: a. Pictures of women and girls, b. Visibility of menstruation, c. Construction of femininity between regulation and agency Both a historical review and a content analysis should show a.) continuity in content (e.g. security, hygiene, invisibility) and motives (e.g. tampons vs. pads, sport, light colours, young white heterosexual middle-class women as main characters) and b.) contradictions (e.g. women at work vs. women at home, naming blood and smell vs. menstrual taboo). Finally I will give an outlook on the question: Is the way o.b. (re)presents femininity o.k.? And how can we deal with it from an academic and political point of view? + + Ullrich, Charlotte + + + http://homepage.ruhr-uni-bochum.de/Charlotte.Ullrich/vortrag_ob_pdf.pdf + + + 2003-01-24 + + + application/pdf + + 20200 + 1080409 + + Frauenbild + + + Geschlechterforschung + + + Hygiene + + + Inhaltsanalyse + + + Menstruation + + + Werbung + + diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/be884622-f29f-42ba-8903-e5eda73bcf34.xml b/exist-samples/src/main/resources/org/exist/samples/mods/be884622-f29f-42ba-8903-e5eda73bcf34.xml new file mode 100644 index 0000000000..14d7463978 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/be884622-f29f-42ba-8903-e5eda73bcf34.xml @@ -0,0 +1,70 @@ + + + + Self-governance and slowness as prerequisites for + knowledge management + Paper for the 19th EGOS Colloquium in + Copenhagen, Subgroup 33 "New Conditions for Managing + Knowledge", July 2003 + + The aim of this paper is to show that + self-governance is the only way to create knowledge in + organizations. We will show that knowledge can only be + developed and preserved by self-governance. As + self-governance is not a natural process, it needs + structures to support the development of this kind of + action. Management is only able to create these structures + at a second level. Thus a distinction between two different + levels has to be made: the level of performance and the + structural level. + + Wilkesmann, Uwe + + + Rascher, Ingolf + + + http://www.ruhr-uni-bochum.de/sowi/top/sowibibliothek/dkpaper/dp03-1.pdf + + + Fakultät für Sozialwissenschaften, + Ruhr-Universität Bochum + 2003-06-03 + 2003-06-03 + + + application/pdf + + + knowledge management + + + self governance + + 1080502 + 10207 + + Akzeptanzforschung + + + Arbeitspsychologie + + + Informationsmanagement + + + Informationssystem + + + Organisationsstruktur + + + Selbstorganisation + + + Wissenssoziologie + + + Wissenstransfer + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/dae9118e-573a-4230-b781-5007c0579f27.xml b/exist-samples/src/main/resources/org/exist/samples/mods/dae9118e-573a-4230-b781-5007c0579f27.xml new file mode 100644 index 0000000000..4949cbfc65 --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/dae9118e-573a-4230-b781-5007c0579f27.xml @@ -0,0 +1,74 @@ + + + + Emerging production systems in the + transnationalisation of German carmakers: Adaptation, + application or innovation? + + Based on case studies, this article seeks to + determine whether or not German carmakers are exporting a + German production model to overseas plants and to what + extent the overseas operations have a reciprocal effect on + production methods in the originating country. It is argued + that the most adequate analytical concept is one that + emphasizes interest-driven organizational learning processes. + + Pries, Ludger + + + http://www.ruhr-uni-bochum.de/soaps/download/publ-2003_lp_emergingproductionsystems.pdf + + + 2003-01-24 + + + application/pdf + + + + New Technology, Work and Employment 18 (2003), + no. 2 + + + + business models + + + production system + + + automobile industry + + + company internationalization + + + international comparison + + + transplants + + + Germany + + 10204 + 10207 + + Bundesrepublik Deutschland + + + Fallstudie + + + Kraftfahrzeugindustrie + + + Produktion + + + Unternehmenskultur + + + multinationales Unternehmen + + \ No newline at end of file diff --git a/exist-samples/src/main/resources/org/exist/samples/mods/f3ad5614-d1b4-4860-a108-542c42dceebf.xml b/exist-samples/src/main/resources/org/exist/samples/mods/f3ad5614-d1b4-4860-a108-542c42dceebf.xml new file mode 100644 index 0000000000..254c09cd1f --- /dev/null +++ b/exist-samples/src/main/resources/org/exist/samples/mods/f3ad5614-d1b4-4860-a108-542c42dceebf.xml @@ -0,0 +1,46 @@ + + + + U.S. Perspectives on the position and role of Germany and Japan in international and regional structures. The 1950s and the Present + + Rather than focusing on the relative power of Germany and Japan within the international system, my attention is directed towards U.S. perspectives on the position and role of Germany and Japan in regional and international structures as points of reference with a view of analysing the transformation of Germany's and Japan's foreign relations in conjunction with changes in the global economy and regional security concerns. The differences between firstly Germany and Japan, secondly the regional context of German and Japanese policies, and thirdly Germany and Japan as international actors are too important and the German-Japanese relationships too underdeveloped (in spite of the spurts in the early 1980s and since 1993) to allow a direct comparison of Germany's and Japan's positions and roles in International Relations. The comparison between U.S. perspectives on Japan and "Germany integrated into Europe" is more manageable and conducive to an assessment of changes:<br/> - the U.S. is a determining factor in Europe's/Pacific Asia's affairs,<br/> - Germany/Japan regards the U.S. as a pillar of its foreign policy,<br/> - the U.S. considers (for the time being) Germany's/Japan's position and role essential to what the U.S. can accomplish regionally and internationally.<br/> The weight of these "factors" ensures that the comparison of U.S. perspectives on Germany and Japan is a reliable guide to the Interpretation of the foreign policy positions and roles of the Federal Republic of Germany (FRG) and Japan in regional and international structures. + + Schmidt, Gustav + + + http://www.ruhr-uni-bochum.de/lehrstuhl-ip/Ostasien.pdf + + + 1999 + + + application/pdf + + + + Bochumer Jahrbuch zur Ostasienforschung, Bd. 23 (1999), S. 359-372. + + + 10505 + + Außenpolitik + + + Bundesrepublik Deutschland + + + Einfluss + + + Geopolitik + + + Japan + + + USA + + + politische Beziehungen + + \ No newline at end of file diff --git a/extensions/contentextraction/src/test/resources/log4j2.xml b/extensions/contentextraction/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/contentextraction/src/test/resources/log4j2.xml +++ b/extensions/contentextraction/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/debuggee/src/test/resources/log4j2.xml b/extensions/debuggee/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/debuggee/src/test/resources/log4j2.xml +++ b/extensions/debuggee/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/expath/src/test/resources/log4j2.xml b/extensions/expath/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/expath/src/test/resources/log4j2.xml +++ b/extensions/expath/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/exquery/restxq/src/test/resources/log4j2.xml b/extensions/exquery/restxq/src/test/resources/log4j2.xml index 499c33ac4b..1b56572ccd 100644 --- a/extensions/exquery/restxq/src/test/resources/log4j2.xml +++ b/extensions/exquery/restxq/src/test/resources/log4j2.xml @@ -202,15 +202,15 @@ - + - + - + diff --git a/extensions/indexes/lucene/src/test/resources/log4j2.xml b/extensions/indexes/lucene/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/indexes/lucene/src/test/resources/log4j2.xml +++ b/extensions/indexes/lucene/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/indexes/ngram/src/test/resources/log4j2.xml b/extensions/indexes/ngram/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/indexes/ngram/src/test/resources/log4j2.xml +++ b/extensions/indexes/ngram/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/indexes/range/pom.xml b/extensions/indexes/range/pom.xml index 54f0b63d50..27cdb5a3ad 100644 --- a/extensions/indexes/range/pom.xml +++ b/extensions/indexes/range/pom.xml @@ -188,6 +188,7 @@ src/test/resources/log4j2.xml src/test/xquery/range/conditions.xql src/main/java/org/exist/indexing/range/RangeIndexAnalyzer.java + src/main/java/org/exist/indexing/range/RangeIndexConfig.java src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java src/main/java/org/exist/indexing/range/RangeIndexConfigElement.java src/main/java/org/exist/indexing/range/RangeIndexConfigField.java @@ -206,6 +207,7 @@ src/test/resources/log4j2.xml src/test/xquery/range/conditions.xql src/main/java/org/exist/indexing/range/RangeIndexAnalyzer.java + src/main/java/org/exist/indexing/range/RangeIndexConfig.java src/main/java/org/exist/indexing/range/RangeIndexConfigAttributeCondition.java src/main/java/org/exist/indexing/range/RangeIndexConfigElement.java src/main/java/org/exist/indexing/range/RangeIndexConfigField.java diff --git a/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfig.java b/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfig.java index 910f3ea456..428938c33a 100644 --- a/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfig.java +++ b/extensions/indexes/range/src/main/java/org/exist/indexing/range/RangeIndexConfig.java @@ -1,4 +1,28 @@ /* + * Elemental + * Copyright (C) 2024, Evolved Binary Ltd + * + * admin@evolvedbinary.com + * https://www.evolvedbinary.com | https://www.elemental.xyz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * NOTE: Parts of this file contain code from 'The eXist-db Authors'. + * The original license header is included below. + * + * ===================================================================== + * * eXist-db Open Source Native XML Database * Copyright (C) 2001 The eXist-db Authors * @@ -135,9 +159,9 @@ private void parseChildren(NodeList configNodes, Map namespaces) } if(uri != null) { - LOG.error("Invalid range index configuration (" + uri + "): " + e.getMessage()); + getLogger().error("Invalid range index configuration (" + uri + "): " + e.getMessage()); } else { - LOG.error("Invalid range index configuration: " + e.getMessage()); + getLogger().error("Invalid range index configuration: " + e.getMessage()); } } } @@ -266,4 +290,13 @@ public void remove() { } } -} \ No newline at end of file + + /** + * Designed to be overridable so that we can observe logging in tests. + * + * @return the logger. + */ + Logger getLogger() { + return LOG; + } +} diff --git a/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java b/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java index 1b9a818feb..7eefdb9f28 100644 --- a/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java +++ b/extensions/indexes/range/src/test/java/org/exist/indexing/range/RangeIndexConfigTest.java @@ -106,7 +106,6 @@ public void errorsHaveSourceContext() throws NoSuchFieldException, IllegalAccess expect(mockCreateDocument.getDocumentURI()).andReturn(mockCollectionXConfUri); final Capture errorMsgCapture = newCapture(); - mockLogger.error(capture(errorMsgCapture)); replay(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger); @@ -116,26 +115,17 @@ public void errorsHaveSourceContext() throws NoSuchFieldException, IllegalAccess final Map namespaces = new HashMap<>(); namespaces.put("tei", "http://www.tei-c.org/ns/1.0"); - overrideLogger(RangeIndexConfig.class, mockLogger); - final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces); + final RangeIndexConfig config = new RangeIndexConfig(mockConfigNodes, namespaces) { + @Override + Logger getLogger() { + return mockLogger; + } + }; assertTrue(errorMsgCapture.getValue().contains("Illegal QName: '" + badCreateQName + "'.. QName is invalid: INVALID_LOCAL_PART")); assertTrue(errorMsgCapture.getValue().contains("(" + mockCollectionXConfUri + ")")); - verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList, mockLogger); + verify(mockConfigNodes, mockConfigNode, mockCreates, mockCreateDocument, mockCreate, mockEmptyNodeList); } - private void overrideLogger(final Class clazz, final Logger logger) throws NoSuchFieldException, IllegalAccessException { - final Field loggerField = clazz.getDeclaredField("LOG"); - - // allow access to private field - loggerField.setAccessible(true); - - // remove final modifier - final Field modifiersField = JDKCompatibility.getModifiersField(); - modifiersField.setAccessible(true); - modifiersField.setInt(loggerField, loggerField.getModifiers() & ~Modifier.FINAL); - - loggerField.set(null, logger); - } } diff --git a/extensions/indexes/range/src/test/resources/log4j2.xml b/extensions/indexes/range/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/indexes/range/src/test/resources/log4j2.xml +++ b/extensions/indexes/range/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/indexes/sort/src/test/resources/log4j2.xml b/extensions/indexes/sort/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/indexes/sort/src/test/resources/log4j2.xml +++ b/extensions/indexes/sort/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/indexes/spatial/src/test/resources/log4j2.xml b/extensions/indexes/spatial/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/indexes/spatial/src/test/resources/log4j2.xml +++ b/extensions/indexes/spatial/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/cache/src/test/resources/log4j2.xml b/extensions/modules/cache/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/modules/cache/src/test/resources/log4j2.xml +++ b/extensions/modules/cache/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/compression/src/test/resources/log4j2.xml b/extensions/modules/compression/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/modules/compression/src/test/resources/log4j2.xml +++ b/extensions/modules/compression/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/counter/src/test/resources/log4j2.xml b/extensions/modules/counter/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/modules/counter/src/test/resources/log4j2.xml +++ b/extensions/modules/counter/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/expathrepo/src/test/resources/log4j2.xml b/extensions/modules/expathrepo/src/test/resources/log4j2.xml index 37917668ae..45264aba17 100644 --- a/extensions/modules/expathrepo/src/test/resources/log4j2.xml +++ b/extensions/modules/expathrepo/src/test/resources/log4j2.xml @@ -197,15 +197,15 @@ - + - + - + diff --git a/extensions/modules/file/src/test/resources/log4j2.xml b/extensions/modules/file/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/modules/file/src/test/resources/log4j2.xml +++ b/extensions/modules/file/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/mail/pom.xml b/extensions/modules/mail/pom.xml index f004174a68..21a694049d 100644 --- a/extensions/modules/mail/pom.xml +++ b/extensions/modules/mail/pom.xml @@ -266,20 +266,6 @@ - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - diff --git a/extensions/modules/mail/src/test/resources/log4j2.xml b/extensions/modules/mail/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/modules/mail/src/test/resources/log4j2.xml +++ b/extensions/modules/mail/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/persistentlogin/src/test/resources/log4j2.xml b/extensions/modules/persistentlogin/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/modules/persistentlogin/src/test/resources/log4j2.xml +++ b/extensions/modules/persistentlogin/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/sql/pom.xml b/extensions/modules/sql/pom.xml index 4dd9abf989..8038ce69d3 100644 --- a/extensions/modules/sql/pom.xml +++ b/extensions/modules/sql/pom.xml @@ -237,20 +237,6 @@ - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - diff --git a/extensions/modules/sql/src/test/resources/log4j2.xml b/extensions/modules/sql/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/modules/sql/src/test/resources/log4j2.xml +++ b/extensions/modules/sql/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/xmldiff/src/test/resources/log4j2.xml b/extensions/modules/xmldiff/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/modules/xmldiff/src/test/resources/log4j2.xml +++ b/extensions/modules/xmldiff/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/modules/xslfo/src/test/resources/log4j2.xml b/extensions/modules/xslfo/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/modules/xslfo/src/test/resources/log4j2.xml +++ b/extensions/modules/xslfo/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/security/activedirectory/src/test/resources/log4j2.xml b/extensions/security/activedirectory/src/test/resources/log4j2.xml index adb664f72a..2c644e5504 100644 --- a/extensions/security/activedirectory/src/test/resources/log4j2.xml +++ b/extensions/security/activedirectory/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/webdav/src/test/resources/log4j2.xml b/extensions/webdav/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/webdav/src/test/resources/log4j2.xml +++ b/extensions/webdav/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - + diff --git a/extensions/xqdoc/src/test/resources/log4j2.xml b/extensions/xqdoc/src/test/resources/log4j2.xml index b678dc1388..282c0f4266 100644 --- a/extensions/xqdoc/src/test/resources/log4j2.xml +++ b/extensions/xqdoc/src/test/resources/log4j2.xml @@ -221,15 +221,15 @@ - + - + - +