Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions elemental-api/elemental-expath-pkg-mgmt-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (C) 2014, Evolved Binary Ltd

This file was originally ported from FusionDB to Elemental by
Evolved Binary, for the benefit of the Elemental Open Source community.
Only the ported code as it appears in this file, at the time that
it was contributed to Elemental, was re-licensed under The GNU
Lesser General Public License v2.1 only for use in Elemental.

This license grant applies only to a snapshot of the code as it
appeared when ported, it does not offer or infer any rights to either
updates of this source code or access to the original source code.

The GNU Lesser General Public License v2.1 only license follows.

=====================================================================

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

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>xyz.elemental</groupId>
<artifactId>elemental-api</artifactId>
<version>7.7.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>elemental-expath-pkg-mgmt-api</artifactId>

<name>Elemental EXPath Package Management API</name>
<description>HTTP API for managing EXPath Packages in Elemental</description>

<scm>
<connection>scm:git:https://github.com/evolvedbinary/elemental.git</connection>
<developerConnection>scm:git:https://github.com/evolvedbinary/elemental.git</developerConnection>
<url>scm:git:https://github.com/evolvedbinary/elemental.git</url>
<tag>HEAD</tag>
</scm>

<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>

<dependency>
<groupId>xyz.elemental.fork.org.exist-db</groupId>
<artifactId>exist-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<scope>test</scope>
</dependency>

<!-- needed for starting up a jetty server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
<testResource>
<directory>src/test/resources-filtered</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<licenseSets>
<licenseSet>
<header>${project.parent.relativePath}/../elemental-parent/FDB-backport-to-EDB-LGPL-21-ONLY-license.template.txt</header>
</licenseSet>
</licenseSets>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jetty.home>${project.basedir}/../../exist-jetty-config/target/classes/org/exist/jetty</jetty.home>
<elemental.configurationFile>${project.build.testOutputDirectory}/conf.xml</elemental.configurationFile>
<elemental.jetty.standalone.webapp.dir>${project.build.testOutputDirectory}/standalone-webapp</elemental.jetty.standalone.webapp.dir>
<log4j.configurationFile>${project.build.testOutputDirectory}/log4j2.xml</log4j.configurationFile>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xyz.elemental.api.expath.pkg.mgmt;

import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class ExpathPkgMgmtServlet extends HttpServlet {

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("application/xml");
response.getWriter().write("<hello>world</hello>");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package xyz.elemental.api.expath.pkg.mgmt;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.fluent.Request;
import org.exist.test.ExistWebServer;
import org.junit.ClassRule;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.builder.Input;
import org.xmlunit.diff.Diff;

import javax.xml.transform.Source;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

public class ExpathPkgMgmtServletTest {

@ClassRule
public static final ExistWebServer existWebServer = new ExistWebServer(true, false, true, true);

private static String getPackageUri() {
return "http://localhost:" + existWebServer.getPort() + "/expath/package/";
}

@Test
public void packageQuery() throws IOException {
final HttpResponse response = Request.Get(getPackageUri())
.execute()
.returnResponse();
final int resultStatusCode = response.getStatusLine().getStatusCode();
assertEquals("Server returned response code: " + resultStatusCode, HttpStatus.SC_OK, resultStatusCode);
final String responseBody = readResponse(response.getEntity());

final Source expectedSource = Input.from("<package-list xmlns=\"http://expath.org/ns/pkg-api\" spec=\"1.0.0\"/>").build();
final Source actualSource = Input.from(responseBody).build();
final Diff diff = DiffBuilder.compare(expectedSource)
.withTest(actualSource)
.checkForSimilar()
.build();

assertFalse(diff.toString(), diff.hasDifferences());
}

private String readResponse(final HttpEntity response) throws IOException {
try (final InputStream is = response.getContent();
final BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8))) {
String line;
final StringBuilder out = new StringBuilder();
while ((line = reader.readLine()) != null) {
out.append(line);
out.append("\r\n");
}
return out.toString();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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

-->
<exist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="${project.basedir}/../schema/conf.xsd">

<db-connection cacheSize="256M" checkMaxCacheSize="true" collectionCache="64M" database="native"
files="${basedir}/target/test-data" pageSize="4096" nodesBuffer="1000" cacheShrinkThreshold="10000"
minDiskSpace="1024M" posix-chown-restricted="true" preserve-on-copy="false">

<startup>
<triggers>
<trigger class="org.exist.security.BouncyCastleJceProviderStartupTrigger"/>
<trigger class="org.exist.protocolhandler.URLStreamHandlerStartupTrigger">
<parameter name="mode" value="disk"/>
<parameter name="mode" value="memory"/>
</trigger>
</triggers>
</startup>

<pool max="20" min="1" sync-period="120000" wait-before-shutdown="120000"/>

<query-pool max-stack-size="64" size="128"/>

<recovery enabled="yes" group-commit="no" journal-dir="${basedir}/target/test-data"
size="100M" sync-on-commit="no" force-restart="no" consistency-check="yes"/>

<watchdog output-size-limit="1000000" query-timeout="-1"/>

</db-connection>

<lock-manager upgrade-check="false" warn-wait-on-read-for-write="false" paths-multi-writer="false">

<lock-table disabled="false" trace-stack-depth="0"/>

<document use-path-locks="false"/>

</lock-manager>

<repository root="/db/apps"/>

<binary-manager>
<cache class="org.exist.util.io.FileFilterInputStreamCache"/>
</binary-manager>

<indexer caseSensitive="yes" index-depth="5" preserve-whitespace-mixed-content="no"
suppress-whitespace="none"/>

<parser>
<html-to-xml class="org.codelibs.nekohtml.parsers.SAXParser">
<properties>
<property name="http://cyberneko.org/html/properties/names/elems" value="match"/>
<property name="http://cyberneko.org/html/properties/names/attrs" value="no-change"/>
</properties>
</html-to-xml>
</parser>

<serializer add-exist-id="none" compress-output="no" output-doctype="yes" enable-xinclude="yes"
enable-xsl="no" indent="yes" match-tagging-attributes="no"
match-tagging-elements="no"/>

<transformer class="net.sf.saxon.TransformerFactoryImpl" caching="yes">
<attribute name="http://saxon.sf.net/feature/version-warning" value="false" type="boolean"/>
</transformer>

<validation mode="no">
<entity-resolver>
<catalog uri="${project.build.testOutputDirectory}/org/exist/validation/catalog.xml"/>
</entity-resolver>
</validation>

<xquery enable-java-binding="no" disable-deprecated-functions="no"
enable-query-rewriting="yes" backwardCompatible="no"
enforce-index-use="strict"
raise-error-on-failed-retrieval="no">

<builtin-modules>

<!-- XQSuite Test Framework for XQuery testing -->
<module uri="http://exist-db.org/xquery/xqsuite" src="resource:org/exist/xquery/lib/xqsuite/xqsuite.xql" />

<module uri="http://www.w3.org/2005/xpath-functions/map" class="org.exist.xquery.functions.map.MapModule" />
<module uri="http://www.w3.org/2005/xpath-functions/math" class="org.exist.xquery.functions.math.MathModule" />
<module uri="http://www.w3.org/2005/xpath-functions/array" class="org.exist.xquery.functions.array.ArrayModule" />

<module uri="http://exist-db.org/xquery/inspection" class="org.exist.xquery.functions.inspect.InspectionModule"/>
<module uri="http://exist-db.org/xquery/request" class="org.exist.xquery.functions.request.RequestModule" />
<module uri="http://exist-db.org/xquery/response" class="org.exist.xquery.functions.response.ResponseModule" />
<module uri="http://exist-db.org/xquery/securitymanager" class="org.exist.xquery.functions.securitymanager.SecurityManagerModule"/>
<module uri="http://exist-db.org/xquery/session" class="org.exist.xquery.functions.session.SessionModule" />
<module uri="http://exist-db.org/xquery/system" class="org.exist.xquery.functions.system.SystemModule" />
<module uri="http://exist-db.org/xquery/transform" class="org.exist.xquery.functions.transform.TransformModule" />
<module uri="http://exist-db.org/xquery/util" class="org.exist.xquery.functions.util.UtilModule">
<!-- set to true to disable the util:eval functions -->
<parameter name="evalDisabled" value="false"/>
</module>
<module uri="http://exist-db.org/xquery/validation" class="org.exist.xquery.functions.validation.ValidationModule" />
<module uri="http://exist-db.org/xquery/xmldb" class="org.exist.xquery.functions.xmldb.XMLDBModule" />

</builtin-modules>

</xquery>

<xupdate allowed-fragmentation="50000" enable-consistency-checks="no"/>

<saxon configuration-file="saxon-config.xml"/>

<rpc-server>

<content-file in-memory-size="4194304"/>

<content-file-pool size="-1" max-idle="5"/>

</rpc-server>

</exist>
Loading
Loading