|
22 | 22 |
|
23 | 23 | import com.googlecode.junittoolbox.ParallelRunner;
|
24 | 24 | import org.exist.test.ExistXmldbEmbeddedServer;
|
| 25 | +import org.exist.test.TestConstants; |
| 26 | +import org.junit.AfterClass; |
| 27 | +import org.junit.BeforeClass; |
25 | 28 | import org.junit.ClassRule;
|
26 | 29 | import org.junit.Test;
|
27 | 30 | import org.junit.runner.RunWith;
|
| 31 | +import org.xmldb.api.base.Collection; |
| 32 | +import org.xmldb.api.base.Resource; |
28 | 33 | import org.xmldb.api.base.ResourceSet;
|
29 | 34 | import org.xmldb.api.base.XMLDBException;
|
| 35 | +import org.xmldb.api.modules.CollectionManagementService; |
| 36 | +import org.xmldb.api.modules.XMLResource; |
30 | 37 |
|
31 | 38 | import static org.junit.Assert.assertEquals;
|
32 | 39 |
|
33 | 40 | @RunWith(ParallelRunner.class)
|
34 | 41 | public class FunSubSequenceTest {
|
35 | 42 |
|
36 | 43 | @ClassRule
|
37 |
| - public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(true, true); |
| 44 | + public static final ExistXmldbEmbeddedServer existEmbeddedServer = new ExistXmldbEmbeddedServer(false, true, true); |
| 45 | + |
| 46 | + private static Collection test = null; |
| 47 | + private static final String SIMPLE_XML_FILENAME = "simple.xml"; |
| 48 | + private static final String SIMPLE_XML = "<nums><i>1</i><i>2</i><i>3</i><i>4</i></nums>"; |
38 | 49 |
|
39 | 50 | @Test
|
40 | 51 | public void all_arity2() throws XMLDBException {
|
@@ -168,6 +179,26 @@ public void largeRange_arity3() throws XMLDBException {
|
168 | 179 | assertEquals("(3000000000)", asSequenceStr(result));
|
169 | 180 | }
|
170 | 181 |
|
| 182 | + @Test |
| 183 | + public void persistentSupsequence_toInMemory() throws XMLDBException { |
| 184 | + final ResourceSet result = existEmbeddedServer.executeQuery("fn:subsequence(doc('" + TestConstants.TEST_COLLECTION_URI.getCollectionPath() + "/" + SIMPLE_XML_FILENAME + "')/nums/i, 2, 2)//text()"); |
| 185 | + assertEquals("(2,3)", asSequenceStr(result)); |
| 186 | + } |
| 187 | + |
| 188 | + @BeforeClass |
| 189 | + public static void setup() throws XMLDBException { |
| 190 | + test = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), TestConstants.TEST_COLLECTION_URI.lastSegment().toString()); |
| 191 | + final Resource resource = test.createResource(SIMPLE_XML_FILENAME, XMLResource.RESOURCE_TYPE); |
| 192 | + resource.setContent(SIMPLE_XML); |
| 193 | + test.storeResource(resource); |
| 194 | + } |
| 195 | + |
| 196 | + @AfterClass |
| 197 | + public static void cleanup() throws XMLDBException { |
| 198 | + final CollectionManagementService collectionManagementService = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0"); |
| 199 | + collectionManagementService.removeCollection(test.getName()); |
| 200 | + } |
| 201 | + |
171 | 202 | private static String asSequenceStr(final ResourceSet result) throws XMLDBException {
|
172 | 203 | final StringBuilder builder = new StringBuilder();
|
173 | 204 | builder.append('(');
|
|
0 commit comments