Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove dysfunctional test cases. To be re-added after merge.

  • Loading branch information...
commit 03c7ff6d99cab520838b826cf57d5fba0843bcda 1 parent 3761887
@wolfgangmm wolfgangmm authored
View
235 extensions/indexes/lucene/test/src/org/exist/indexing/lucene/FacetAbstractTest.java
@@ -1,235 +0,0 @@
-/*
- * eXist Open Source Native XML Database
- * Copyright (C) 2013 The eXist Project
- * http://exist-db.org
- *
- * This program 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
- * of the License, or (at your option) any later version.
- *
- * This program 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- */
-package org.exist.indexing.lucene;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.*;
-import java.util.Map.Entry;
-
-import org.exist.Indexer;
-import org.exist.TestUtils;
-import org.exist.collections.Collection;
-import org.exist.collections.CollectionConfigurationManager;
-import org.exist.collections.IndexInfo;
-import org.exist.dom.DefaultDocumentSet;
-import org.exist.dom.DocumentImpl;
-import org.exist.dom.DocumentSet;
-import org.exist.dom.MutableDocumentSet;
-import org.exist.storage.BrokerPool;
-import org.exist.storage.DBBroker;
-import org.exist.storage.md.MetaData;
-import org.exist.storage.md.Metas;
-import org.exist.storage.txn.TransactionManager;
-import org.exist.storage.txn.Txn;
-import org.exist.test.TestConstants;
-import org.exist.util.Configuration;
-import org.exist.util.ConfigurationHelper;
-import org.exist.xmldb.XmldbURI;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-public class FacetAbstractTest {
-
- protected static BrokerPool db;
- protected static Collection root;
- protected Boolean savedConfig;
-
- protected DocumentSet configureAndStore(String configuration, Resource[] resources) {
- DBBroker broker = null;
- TransactionManager transact = null;
- Txn transaction = null;
- MutableDocumentSet docs = new DefaultDocumentSet();
- try {
- broker = db.get(db.getSecurityManager().getSystemSubject());
- assertNotNull(broker);
- transact = db.getTransactionManager();
- assertNotNull(transact);
- transaction = transact.beginTransaction();
- assertNotNull(transaction);
-
- MetaData md = MetaData.get();
- assertNotNull(md);
-
- if (configuration != null) {
- CollectionConfigurationManager mgr = db.getConfigurationManager();
- mgr.addConfiguration(transaction, broker, root, configuration);
- }
-
- for (Resource resource : resources) {
- IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(resource.docName), resource.data);
- assertNotNull(info);
-
- if (docs != null) {
- Metas docMD = md.getMetas(info.getDocument());
- if (docMD == null) {
- docMD = md.addMetas(info.getDocument());
- }
- assertNotNull(docMD);
-
- for (Entry<String, String> entry : resource.metas.entrySet()) {
- docMD.put(entry.getKey(), entry.getValue());
- }
- }
-
- root.store(transaction, broker, info, resource.data, false);
-
- docs.add(info.getDocument());
- }
-
- transact.commit(transaction);
- } catch (Exception e) {
- if (transact != null)
- transact.abort(transaction);
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- db.release(broker);
- }
-
- return docs;
- }
-
- @Before
- public void setup() {
- DBBroker broker = null;
- TransactionManager transact = null;
- Txn transaction = null;
- try {
- broker = db.get(db.getSecurityManager().getSystemSubject());
- assertNotNull(broker);
- transact = db.getTransactionManager();
- assertNotNull(transact);
- transaction = transact.beginTransaction();
- assertNotNull(transaction);
-
- root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
- assertNotNull(root);
- broker.saveCollection(transaction, root);
-
- transact.commit(transaction);
-
- Configuration config = BrokerPool.getInstance().getConfiguration();
- savedConfig = (Boolean) config.getProperty(Indexer.PROPERTY_PRESERVE_WS_MIXED_CONTENT);
- config.setProperty(Indexer.PROPERTY_PRESERVE_WS_MIXED_CONTENT, Boolean.TRUE);
- } catch (Exception e) {
- if (transact != null)
- transact.abort(transaction);
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- if (db != null)
- db.release(broker);
- }
- }
-
- @After
- public void cleanup() {
- BrokerPool pool = null;
- DBBroker broker = null;
- TransactionManager transact = null;
- Txn transaction = null;
- try {
- pool = BrokerPool.getInstance();
- assertNotNull(pool);
- broker = pool.get(pool.getSecurityManager().getSystemSubject());
- assertNotNull(broker);
- transact = pool.getTransactionManager();
- assertNotNull(transact);
- transaction = transact.beginTransaction();
- assertNotNull(transaction);
-
- Collection collConfig = broker.getOrCreateCollection(transaction,
- XmldbURI.create(XmldbURI.CONFIG_COLLECTION + "/db"));
- assertNotNull(collConfig);
- broker.removeCollection(transaction, collConfig);
-
- if (root != null) {
- assertNotNull(root);
- broker.removeCollection(transaction, root);
- }
- transact.commit(transaction);
-
- Configuration config = BrokerPool.getInstance().getConfiguration();
- config.setProperty(Indexer.PROPERTY_PRESERVE_WS_MIXED_CONTENT, savedConfig);
- } catch (Exception e) {
- if (transact != null)
- transact.abort(transaction);
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- if (pool != null) pool.release(broker);
- }
- }
-
- @BeforeClass
- public static void startDB() {
- try {
- File confFile = ConfigurationHelper.lookup("conf.xml");
- Configuration config = new Configuration(confFile.getAbsolutePath());
- config.setProperty(Indexer.PROPERTY_SUPPRESS_WHITESPACE, "none");
- config.setProperty(Indexer.PRESERVE_WS_MIXED_CONTENT_ATTRIBUTE, Boolean.TRUE);
- BrokerPool.configure(1, 5, config);
- db = BrokerPool.getInstance();
- assertNotNull(db);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @AfterClass
- public static void stopDB() {
- TestUtils.cleanupDB();
- BrokerPool.stopAll(false);
- db = null;
- root = null;
- }
-
- protected class Resource {
- final String docName;
- final String data;
- final Map<String, String> metas;
-
- Resource(String docName, String data, Map<String, String> metas) {
- this.docName = docName;
- this.data = data;
- this.metas = metas;
- }
- }
-
- protected class CountDocuments implements SearchCallback<DocumentImpl> {
-
- int count = 0;
-
- @Override
- public void found(DocumentImpl document, float score) {
- count++;
- }
-
- }
-}
-
View
255 extensions/indexes/lucene/test/src/org/exist/indexing/lucene/FacetIndexTest.java
@@ -1,255 +0,0 @@
-/*
- * eXist Open Source Native XML Database
- * Copyright (C) 2013 The eXist Project
- * http://exist-db.org
- *
- * This program 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
- * of the License, or (at your option) any later version.
- *
- * This program 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- */
-package org.exist.indexing.lucene;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.*;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetResultNode;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.apache.lucene.queryparser.classic.QueryParser;
-import org.apache.lucene.search.Query;
-import org.exist.dom.DocumentSet;
-import org.exist.dom.QName;
-import org.exist.storage.DBBroker;
-import org.junit.Test;
-
-public class FacetIndexTest extends FacetAbstractTest {
-
- protected static String XUPDATE_START =
- "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">";
-
- protected static String XUPDATE_END =
- "</xu:modifications>";
-
- private static String XML5 =
- "<article>" +
- " <head>The <b>title</b>of it</head>" +
- " <p>A simple paragraph with <hi>highlighted</hi> text <note>and a note</note> " +
- " in it.</p>" +
- " <p>Paragraphs with <s>mix</s><s>ed</s> content are <s>danger</s>ous.</p>" +
- " <p><note1>ignore</note1> <s2>warn</s2>ings</p>" +
- " <p>Another simple paragraph.</p>" +
- "</article>";
-
- private static String COLLECTION_CONFIG5 =
- "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" +
- " <index xmlns:tei=\"http://www.tei-c.org/ns/1.0\">" +
- " <fulltext default=\"none\" attributes=\"no\">" +
- " </fulltext>" +
- " <lucene>" +
- " <text qname=\"article\">" +
- " <ignore qname=\"note\"/>" +
- " <inline qname=\"s\"/>" +
- " </text>" +
- " <text qname=\"p\">" +
- " <ignore qname=\"note\"/>" +
- " <inline qname=\"s\"/>" +
- " </text>" +
- " <text qname=\"head\"/>" +
- " <ignore qname=\"note1\"/>" +
- " <inline qname=\"s2\"/>" +
- " </lucene>" +
- " </index>" +
- "</collection>";
-
- private static Map<String, String> metas1 = new HashMap<String, String>();
- static {
- metas1.put("status", "draft");
- }
-
- private static Map<String, String> metas2 = new HashMap<String, String>();
- static {
- metas2.put("status", "final");
- }
-
- private void checkFacet(List<FacetResult> facets) {
- assertEquals(1, facets.size());
-
- FacetResult facet = facets.get(0);
- assertEquals(2, facet.getNumValidDescendants());
- FacetResultNode node = facet.getFacetResultNode();
- assertEquals(0.0, node.value, 0.0001);
- assertEquals("status", node.label.toString());
-
- List<FacetResultNode> subResults = node.subResults;
- assertEquals(2, subResults.size());
-
- node = subResults.get(0);
- assertEquals(1.0, node.value, 0.0001);
- assertEquals("status/final", node.label.toString());
-
- node = subResults.get(1);
- assertEquals(1.0, node.value, 0.0001);
- assertEquals("status/draft", node.label.toString());
- }
-
- @Test
- public void inlineAndIgnore() {
- System.out.println("Test simple queries ...");
- DocumentSet docs = configureAndStore(COLLECTION_CONFIG5,
- new Resource[] {
- new Resource("test1.xml", XML5, metas1),
- new Resource("test2.xml", XML5, metas2),
- });
-
- DBBroker broker = null;
- try {
- broker = db.get(db.getSecurityManager().getSystemSubject());
- assertNotNull(broker);
-
-// checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 2);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "simple", 2);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "mixed", 2);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "dangerous", 2);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "note", 0);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "ignore", 0);
-// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "warnings", 2);
-
- final LuceneIndexWorker worker = (LuceneIndexWorker) broker.getIndexController().getWorkerByIndexId(LuceneIndex.ID);
-
- FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("status"), 10)
-// new CountFacetRequest(new CategoryPath("Author"), 10)
- );
-
- CountDocuments cb = new CountDocuments();
-
- List<QName> qnames = new ArrayList<QName>();
- qnames.add(new QName("head", ""));
- List<FacetResult> results = QueryDocuments.query(worker, docs, qnames, "title", fsp, null, cb);
-
- assertEquals(2, cb.count);
-
- checkFacet(results);
-
- cb.count = 0;
-
- //Lucene query
- QName qname = new QName("head", "");
-
- String field = LuceneUtil.encodeQName(new QName("head", ""), db.getSymbols());
-
- Analyzer analyzer = worker.getAnalyzer(null, qname, broker, docs);
-
- QueryParser parser = new QueryParser(LuceneIndex.LUCENE_VERSION_IN_USE, field, analyzer);
-
- //worker.setOptions(options, parser);
-
- Query query = parser.parse("title");
-
-
- results = QueryDocuments.query(worker, docs, query, fsp, cb);
-
- assertEquals(2, cb.count);
-
- checkFacet(results);
-
- cb.count = 0;
-
- //check document filtering
- qnames = new ArrayList<QName>();
- qnames.add(new QName("p", ""));
- results = QueryDocuments.query(worker, docs, qnames, "paragraph", fsp, null, cb);
-
- for (FacetResult result : results) {
- System.out.println(result.toString());
- }
-
- assertEquals(2, cb.count);
-
- checkFacet(results);
-
- cb.count = 0;
-
-
-// seq = xquery.execute("/article[ft:query(p, 'highlighted')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'mixed')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'mix')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'dangerous')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'ous')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'danger')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(p, 'note')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'highlighted')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'mixed')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'dangerous')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'warnings')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'danger')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'note')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
-//
-// seq = xquery.execute("/article[ft:query(., 'ignore')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(0, seq.getItemCount());
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- db.release(broker);
- }
- }
-}
-
View
261 extensions/indexes/lucene/test/src/org/exist/indexing/lucene/FacetMatchListenerTest.java
@@ -1,261 +0,0 @@
-/*
- * eXist Open Source Native XML Database
- * Copyright (C) 2013 The eXist Project
- * http://exist-db.org
- *
- * This program 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
- * of the License, or (at your option) any later version.
- *
- * This program 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- */
-package org.exist.indexing.lucene;
-
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetResultNode;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.exist.dom.DocumentSet;
-import org.exist.dom.NewArrayNodeSet;
-import org.exist.dom.NodeProxy;
-import org.exist.dom.NodeSet;
-import org.exist.dom.QName;
-import org.exist.storage.DBBroker;
-import org.exist.storage.serializers.EXistOutputKeys;
-import org.exist.storage.serializers.Serializer;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.NodeValue;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
-import javax.xml.transform.OutputKeys;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-public class FacetMatchListenerTest extends FacetAbstractTest {
-
- private static String XML =
- "<root>" +
- " <para>some paragraph with <hi>mixed</hi> content.</para>" +
- " <para>another paragraph with <note><hi>nested</hi> inner</note> elements.</para>" +
- " <para>a third paragraph with <term>term</term>.</para>" +
- " <para>double match double match</para>" +
- "</root>";
-
- private static String XML1 =
- "<article>" +
- " <head>The <b>title</b>of it</head>" +
- " <p>A simple<note>sic</note> paragraph with <hi>highlighted</hi> text <note>and a note</note> to be ignored.</p>" +
- " <p>Paragraphs with <s>mix</s><s>ed</s> content are <s>danger</s>ous.</p>" +
- "</article>";
-
- private static String CONF2 =
- "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" +
- " <index>" +
- " <fulltext default=\"none\">" +
- " </fulltext>" +
- " <text qname=\"para\"/>" +
- " <text qname=\"term\"/>" +
- " </index>" +
- "</collection>";
-
- private static String MATCH_START = "<exist:match xmlns:exist=\"http://exist.sourceforge.net/NS/exist\">";
- private static String MATCH_END = "</exist:match>";
-
- private static Map<String, String> metas1 = new HashMap<String, String>();
- static {
- metas1.put("status", "draft");
- }
-
- private static Map<String, String> metas2 = new HashMap<String, String>();
- static {
- metas2.put("status", "final");
- }
-
- private void checkFacet2(List<FacetResult> facets) {
- assertEquals(1, facets.size());
-
- FacetResult facet = facets.get(0);
- assertEquals(1, facet.getNumValidDescendants());
- FacetResultNode node = facet.getFacetResultNode();
- assertEquals(0.0, node.value, 0.0001);
- assertEquals("status", node.label.toString());
-
- List<FacetResultNode> subResults = node.subResults;
- assertEquals(1, subResults.size());
-
- node = subResults.get(0);
- assertEquals(1.0, node.value, 0.0001);
- assertEquals("status/final", node.label.toString());
- }
-
- private void checkFacet(List<FacetResult> facets) {
- assertEquals(1, facets.size());
-
- FacetResult facet = facets.get(0);
- assertEquals(2, facet.getNumValidDescendants());
- FacetResultNode node = facet.getFacetResultNode();
- assertEquals(0.0, node.value, 0.0001);
- assertEquals("status", node.label.toString());
-
- List<FacetResultNode> subResults = node.subResults;
- assertEquals(2, subResults.size());
-
- node = subResults.get(0);
- assertEquals(1.0, node.value, 0.0001);
- assertEquals("status/final", node.label.toString());
-
- node = subResults.get(1);
- assertEquals(1.0, node.value, 0.0001);
- assertEquals("status/draft", node.label.toString());
- }
-
- /**
- * Test match highlighting for index configured by QName, e.g.
- * &lt;create qname="a"/&gt;.
- */
- @Test
- public void indexByQName() {
- DBBroker broker = null;
- try {
- DocumentSet docs = configureAndStore(CONF2,
- new Resource[] {
- new Resource("test1.xml", XML, metas1),
- new Resource("test2.xml", XML, metas2),
- new Resource("test3.xml", XML1, metas2),
- });
-
- broker = db.get(db.getSecurityManager().getSystemSubject());
-
- final LuceneIndexWorker worker = (LuceneIndexWorker) broker.getIndexController().getWorkerByIndexId(LuceneIndex.ID);
-
- List<FacetResult> results;
- String result;
-
- FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("status"), 10)
-// new CountFacetRequest(new CategoryPath("Author"), 10)
- );
-
- CountAndCollect cb = new CountAndCollect();
-
- List<QName> qnames = new ArrayList<QName>();
- qnames.add(new QName("para", ""));
-
- //query without facet filter
- results = QueryNodes.query(worker, docs, qnames, 1, "mixed", fsp, null, cb);
-
- assertEquals(2, cb.count);
-
- for (int i = 0; i < 2; i++) {
- result = queryResult2String(broker, cb.set.get(0));
- System.out.println("RESULT: " + result);
- XMLAssert.assertEquals("<para>some paragraph with <hi>" + MATCH_START + "mixed" +
- MATCH_END + "</hi> content.</para>", result);
- }
-
- checkFacet(results);
-
- cb.count = 0;
-
- //query with facet filter
- results = QueryNodes.query(worker, docs, qnames, 1, "mixed AND status:final", fsp, null, cb);
-
- assertEquals(1, cb.count);
-
- result = queryResult2String(broker, cb.set.get(0));
- System.out.println("RESULT: " + result);
- XMLAssert.assertEquals("<para>some paragraph with <hi>" + MATCH_START + "mixed" +
- MATCH_END + "</hi> content.</para>", result);
-
- checkFacet2(results);
-
- cb.count = 0;
-
-// seq = xquery.execute("//para[ft:query(., '+nested +inner +elements')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-// result = queryResult2String(broker, seq);
-// System.out.println("RESULT: " + result);
-// XMLAssert.assertEquals("<para>another paragraph with <note><hi>" + MATCH_START + "nested" +
-// MATCH_END + "</hi> " + MATCH_START +
-// "inner" + MATCH_END + "</note> " + MATCH_START + "elements" + MATCH_END + ".</para>", result);
-//
-// seq = xquery.execute("//para[ft:query(term, 'term')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-// result = queryResult2String(broker, seq);
-// System.out.println("RESULT: " + result);
-// XMLAssert.assertEquals("<para>a third paragraph with <term>" + MATCH_START + "term" + MATCH_END +
-// "</term>.</para>", result);
-//
-// seq = xquery.execute("//para[ft:query(., '+double +match')]", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-// result = queryResult2String(broker, seq);
-// System.out.println("RESULT: " + result);
-// XMLAssert.assertEquals("<para>" + MATCH_START + "double" + MATCH_END + " " +
-// MATCH_START + "match" + MATCH_END + " " + MATCH_START + "double" + MATCH_END + " " +
-// MATCH_START + "match" + MATCH_END + "</para>", result);
-//
-// seq = xquery.execute(
-// "for $para in //para[ft:query(., '+double +match')] return\n" +
-// " <hit>{$para}</hit>", null, AccessContext.TEST);
-// assertNotNull(seq);
-// assertEquals(1, seq.getItemCount());
-// result = queryResult2String(broker, seq);
-// System.out.println("RESULT: " + result);
-// XMLAssert.assertEquals("<hit><para>" + MATCH_START + "double" + MATCH_END + " " +
-// MATCH_START + "match" + MATCH_END + " " + MATCH_START + "double" + MATCH_END + " " +
-// MATCH_START + "match" + MATCH_END + "</para></hit>", result);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- db.release(broker);
- }
- }
-
- private String queryResult2String(DBBroker broker, NodeValue node) throws SAXException, XPathException {
- Properties props = new Properties();
- props.setProperty(OutputKeys.INDENT, "no");
- props.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, "elements");
- Serializer serializer = broker.getSerializer();
- serializer.reset();
- serializer.setProperties(props);
- return serializer.serialize(node);
- }
-
- protected class CountAndCollect implements SearchCallback<NodeProxy> {
-
- NodeSet set = new NewArrayNodeSet();
-
- int count = 0;
-
- @Override
- public void found(NodeProxy node, float score) {
- count++;
-
- set.add(node);
- }
-
- }
-
-}
Please sign in to comment.
Something went wrong with that request. Please try again.