diff --git a/exist-core/src/test/java/org/exist/xquery/functions/transform/TransformFromPkgTest.java b/exist-core/src/test/java/org/exist/xquery/functions/transform/TransformFromPkgTest.java index 922ae7bfa03..dcdc57e4e61 100644 --- a/exist-core/src/test/java/org/exist/xquery/functions/transform/TransformFromPkgTest.java +++ b/exist-core/src/test/java/org/exist/xquery/functions/transform/TransformFromPkgTest.java @@ -39,6 +39,10 @@ */ public class TransformFromPkgTest { + private static final String moduleLocation = "/db/system/repo/functx-1.0.1/functx/functx.xsl"; + private static final String inputXml = "bonjourno"; + private static final String expectedOutput = "hello"; + private static Path getConfigFile() { final ClassLoader loader = TransformFromPkgTest.class.getClassLoader(); final char separator = System.getProperty("file.separator").charAt(0); @@ -52,32 +56,53 @@ private static Path getConfigFile() { } } + private static String getQuery(final String importLocation) { + final String xslt = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " " + + " \n" + + " \n" + + ""; + + return "transform:transform(" + inputXml + ", " + xslt + ", ())"; + } + + private static void assertTransformationResult(ResourceSet result) throws XMLDBException { + assertNotNull(result); + assertEquals(1, result.getSize()); + assertEquals(expectedOutput, result.getResource(0).getContent()); + } + @ClassRule public static ExistXmldbEmbeddedServer existXmldbEmbeddedServer = new ExistXmldbEmbeddedServer(true, false, true, getConfigFile()); @Test - public void transformWithModuleFromPkg() throws XMLDBException { - final String xslt = - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - final String xml = "bonjourno"; + public void testImportNoScheme() throws XMLDBException { + final String xquery = getQuery(moduleLocation); + final ResourceSet result = existXmldbEmbeddedServer.executeQuery(xquery); + assertTransformationResult(result); + } - final String xquery = "transform:transform(" + xml + ", " + xslt + ", ())"; + @Test + public void testImportXmldbScheme() throws XMLDBException { + final String xquery = getQuery("xmldb:" + moduleLocation); + final ResourceSet result = existXmldbEmbeddedServer.executeQuery(xquery); + assertTransformationResult(result); + } + @Test + public void testImportXmldbSchemeDoubleSlash() throws XMLDBException { + final String xquery = getQuery("xmldb://" + moduleLocation); final ResourceSet result = existXmldbEmbeddedServer.executeQuery(xquery); - assertNotNull(result); - assertEquals(1, result.getSize()); + assertTransformationResult(result); } }