Skip to content

Commit 6891d35

Browse files
committed
[bugfix] Fix failing PackageTriggerTest.java due to classpath issues
1 parent 7cbfe6b commit 6891d35

File tree

4 files changed

+39
-136
lines changed

4 files changed

+39
-136
lines changed
Lines changed: 10 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,14 @@
1-
--------
2-
Overview
3-
--------
1+
# EXPath Repo for Elemental
42

5-
eXist db now uses expath repository to resolve external dependencies located in repository to be used by xquery
6-
and other XML technologies.
3+
This module uses a .xar file as part of the resources for its tests.
74

8-
-----
9-
Build
10-
-----
5+
The .xar source code is in a separate Maven module and can be found in the `expathrepo-trigger-test` sub-folder.
6+
To build the .xar file and copy it for use in the tests for this module:
117

12-
This module relies on the presence of the following jar files in the EXIST_HOME/lib/core folder:
8+
```bash
9+
cd expathrepo-trigger-test
10+
mvn clean package
11+
cp target/exist-expathrepo-trigger-test-6.4.0-SNAPSHOT.xar ../src/test/resources/exist-expathrepo-trigger-test.xar
12+
```
1313

14-
pkg-repo.jar
15-
16-
(which Florent Georges maintains as part of expath package repo)
17-
18-
If you are building from source then the module build process will try and download
19-
these files for you.
20-
21-
This module is enabled by default as eXist now depends on expath package manager.
22-
23-
To configure build set in local.build.properties (or build.properties):
24-
25-
include.module.expathrepo = true
26-
27-
To enable or disable expathrepo look in conf.xml for
28-
29-
<module class="org.exist.xquery.modules.expathrepo.ExpathPackageModule"
30-
uri="http://exist-db.org/xquery/repo" />
31-
32-
------------
33-
XQuery Usage
34-
------------
35-
36-
List packages
37-
38-
import module namespace repo="http://exist-db.org/xquery/repo";
39-
repo:list()
40-
41-
Install packages
42-
43-
import module namespace repo="http://exist-db.org/xquery/repo";
44-
repo:install('functx-1.0.xar')
45-
46-
Replace packages
47-
48-
import module namespace repo="http://exist-db.org/xquery/repo";
49-
repo:remove('functx-1.0.xar')
50-
51-
52-
---------------
53-
Developer Notes
54-
---------------
55-
56-
* This module is default built and enabled with eXist
57-
58-
* It downloads expath repo pck-repo.jar and places under lib/core
59-
60-
* start.config now has an entry for this jar
61-
62-
* Main.java/XQueryContext.java will create repository under webapp/WEB-INF/expathrepo if exist.home is present
63-
64-
* Main.java/XQueryContext.java will create repository under /expathrepo if exist.home is not present
65-
66-
* Repository will be placed relative to exist.home or top level directory
67-
68-
* XQueryContext.java will resolve modules in expath repository
69-
70-
* org.exist.xquery.modules.expathrepo exposes repo functionality as XQuery extension functions under
71-
http://exist-db.org/xquery/repo namespace
72-
73-
74-
------
75-
Future
76-
------
77-
78-
* refactor code, remove any hard codings, add more exception checking
79-
80-
* enhance documentation
81-
82-
* add LocateFunction.java once it works properly inside repo-pkg.jar
83-
84-
* convert existing xquery libs into .xar
85-
86-
* store repository inside eXist ?
87-
88-
* add CreateFunction.java to create new repositories
89-
90-
* load .xar into eXist ?
91-
92-
93-
-------------------------
94-
Issues/Status/Limitations
95-
-------------------------
96-
97-
* currently test/src/xquery/expathrepo unit tests disabled
98-
99-
* repo.removePackage seems to throw PackageException on success (will follow up with Florent Georges)
100-
101-
* eXist-db requires a restart to recognize changes to packages loaded or removed from repository
102-
103-
* expath repository directory needs to be initiated by eXist (in XQueryContext on startup
14+
Each time you modify the source code of the `expathrepo-trigger-test` module, you should rebuild it and copy the .xar file to the `src/test/resources` folder of this module and re-commit it to Git.

extensions/modules/expathrepo/pom.xml

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<connection>scm:git:https://github.com/evolvedbinary/elemental.git</connection>
6767
<developerConnection>scm:git:https://github.com/evolvedbinary/elemental.git</developerConnection>
6868
<url>scm:git:https://github.com/evolvedbinary/elemental.git</url>
69-
<tag>HEAD</tag>
69+
<tag>HEAD</tag>
7070
</scm>
7171

7272
<dependencies>
@@ -106,14 +106,6 @@
106106
<scope>test</scope>
107107
</dependency>
108108

109-
<dependency>
110-
<!-- needed for resolving the XAR for PackageTriggerTest -->
111-
<groupId>xyz.elemental.fork.org.exist-db</groupId>
112-
<artifactId>exist-expathrepo-trigger-test</artifactId>
113-
<version>${project.version}</version>
114-
<scope>test</scope>
115-
</dependency>
116-
117109
</dependencies>
118110

119111
<build>
@@ -170,6 +162,7 @@
170162
<include>src/main/java/org/exist/xquery/modules/expathrepo/InstallFunction.java</include>
171163
<include>src/main/java/org/exist/xquery/modules/expathrepo/RemoveFunction.java</include>
172164
<include>src/main/resources/org/exist/xquery/modules/expathrepo/repair.xql</include>
165+
<include>src/test/java/org/exist/repo/PackageTriggerTest.java</include>
173166
</includes>
174167
</licenseSet>
175168

@@ -185,6 +178,8 @@
185178
<exclude>src/main/java/org/exist/xquery/modules/expathrepo/InstallFunction.java</exclude>
186179
<exclude>src/main/java/org/exist/xquery/modules/expathrepo/RemoveFunction.java</exclude>
187180
<exclude>src/main/resources/org/exist/xquery/modules/expathrepo/repair.xql</exclude>
181+
<exclude>src/test/java/org/exist/repo/PackageTriggerTest.java</exclude>
182+
<exclude>src/test/resources/exist-expathrepo-trigger-test.xar</exclude>
188183
<exclude>expathrepo-trigger-test/**</exclude>
189184
</excludes>
190185
</licenseSet>
@@ -198,31 +193,6 @@
198193
</configuration>
199194
</plugin>
200195

201-
<plugin>
202-
<groupId>org.apache.maven.plugins</groupId>
203-
<artifactId>maven-resources-plugin</artifactId>
204-
<executions>
205-
<execution>
206-
<id>copy-expathrepo-trigger-test-xar</id>
207-
<phase>generate-test-resources</phase>
208-
<goals>
209-
<goal>copy-resources</goal>
210-
</goals>
211-
<configuration>
212-
<outputDirectory>${basedir}/target/generated-test-resources</outputDirectory>
213-
<resources>
214-
<resource>
215-
<directory>expathrepo-trigger-test/target/</directory>
216-
<includes>
217-
<include>*.xar</include>
218-
</includes>
219-
<filtering>false</filtering>
220-
</resource>
221-
</resources>
222-
</configuration>
223-
</execution>
224-
</executions>
225-
</plugin>
226196
<plugin>
227197
<groupId>org.apache.maven.plugins</groupId>
228198
<artifactId>maven-dependency-plugin</artifactId>
@@ -236,7 +206,6 @@
236206
<failOnWarning>true</failOnWarning>
237207
<ignoredUnusedDeclaredDependencies>
238208
<ignoredUnusedDeclaredDependency>${project.groupId}:exist-compression:jar:${project.version}</ignoredUnusedDeclaredDependency> <!-- needed for XQSuite tests that depend on Compression Module -->
239-
<ignoredUnusedDeclaredDependency>${project.groupId}:exist-expathrepo-trigger-test:jar:${project.version}</ignoredUnusedDeclaredDependency> <!-- needed for resolving the XAR for PackageTriggerTest -->
240209
</ignoredUnusedDeclaredDependencies>
241210
</configuration>
242211
</execution>

extensions/modules/expathrepo/src/test/java/org/exist/repo/PackageTriggerTest.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -22,7 +46,6 @@
2246
package org.exist.repo;
2347

2448
import org.exist.EXistException;
25-
import org.exist.Version;
2649
import org.exist.collections.Collection;
2750
import org.exist.security.PermissionDeniedException;
2851
import org.exist.storage.BrokerPool;
@@ -50,7 +73,7 @@
5073

5174
public class PackageTriggerTest {
5275

53-
static final String xarFile = "exist-expathrepo-trigger-test-" + Version.getVersion() + ".xar";
76+
static final String xarFile = "exist-expathrepo-trigger-test.xar"; // NOTE(AR) a copy of this should be present in `src/test/resources`.
5477
static final XmldbURI triggerTestCollection = XmldbURI.create("/db");
5578
static final XmldbURI xarUri = triggerTestCollection.append(xarFile);
5679

37.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)