|
21 | 21 | */
|
22 | 22 | package org.exist.xquery.functions.fn;
|
23 | 23 |
|
| 24 | +import com.evolvedbinary.j8fu.Either; |
24 | 25 | import com.googlecode.junittoolbox.ParallelRunner;
|
25 |
| -import org.exist.test.ExistXmldbEmbeddedServer; |
| 26 | +import org.exist.EXistException; |
| 27 | +import org.exist.security.PermissionDeniedException; |
| 28 | +import org.exist.test.XQueryCompilationTest; |
| 29 | +import org.exist.xquery.ErrorCodes; |
26 | 30 | import org.exist.xquery.XPathException;
|
27 |
| -import org.junit.ClassRule; |
| 31 | +import org.exist.xquery.value.Sequence; |
28 | 32 | import org.junit.Test;
|
29 | 33 | import org.junit.runner.RunWith;
|
30 |
| -import org.xmldb.api.base.ResourceSet; |
31 |
| -import org.xmldb.api.base.XMLDBException; |
32 | 34 |
|
33 |
| -import static org.junit.Assert.assertEquals; |
| 35 | +import static org.exist.test.XQueryAssertions.assertXQErrorCode; |
34 | 36 |
|
35 | 37 | /**
|
36 | 38 | * @author Dannes Wessels
|
37 | 39 | */
|
38 | 40 | @RunWith(ParallelRunner.class)
|
39 |
| -public class FunDocumentUriTest { |
40 |
| - |
41 |
| - @ClassRule |
42 |
| - public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(true, true, true); |
43 |
| - |
| 41 | +public class FunDocumentUriTest extends XQueryCompilationTest { |
| 42 | + |
44 | 43 | @Test
|
45 |
| - public void testFnFunDocumentUri() { |
46 |
| - |
47 |
| - try { |
48 |
| - final ResourceSet resourceSet = existEmbeddedServer.executeQuery( |
49 |
| - "declare context item := 'a'; document-uri()"); |
50 |
| - |
51 |
| - } catch (XMLDBException ex) { |
52 |
| - XPathException cause = (XPathException) ex.getCause(); |
53 |
| - assertEquals("XPTY0004", cause.getErrorCode().getErrorQName().getLocalPart()); |
54 |
| - } |
| 44 | + public void testFnFunDocumentUri() throws EXistException, PermissionDeniedException { |
| 45 | + final String query = "declare context item := 'a'; document-uri()"; |
| 46 | + final Either<XPathException, Sequence> result = executeQuery(query); |
| 47 | + assertXQErrorCode(ErrorCodes.XPTY0004, result.left().get()); |
55 | 48 | }
|
56 | 49 | }
|
0 commit comments