Search in sources :

Example 96 with Collection

use of org.exist.collections.Collection in project exist by eXist-db.

the class DefaultDocumentSetTest method contains_leftRight.

@Test
public void contains_leftRight() {
    final Collection col = mockCollection(1);
    final DocumentImpl doc1 = mockDoc(col, 1);
    final DocumentImpl doc6 = mockDoc(col, 6);
    final DocumentImpl doc9 = mockDoc(col, 9);
    final DocumentImpl doc15 = mockDoc(col, 15);
    final DocumentImpl doc34 = mockDoc(col, 34);
    replay(col, doc1, doc6, doc9, doc15, doc34);
    final DefaultDocumentSet set1 = new DefaultDocumentSet();
    set1.add(doc1);
    set1.add(doc6);
    set1.add(doc9);
    final DefaultDocumentSet set2 = new DefaultDocumentSet();
    set2.add(doc1);
    set2.add(doc6);
    set2.add(doc9);
    set2.add(doc15);
    set2.add(doc34);
    // functions under test
    assertTrue(set2.contains(set1));
    assertFalse(set1.contains(set2));
    verify(col, doc1, doc6, doc9, doc15, doc34);
}
Also used : Collection(org.exist.collections.Collection) Test(org.junit.Test)

Example 97 with Collection

use of org.exist.collections.Collection in project exist by eXist-db.

the class DefaultDocumentSetTest method equalDocs_noMatch.

@Test
public void equalDocs_noMatch() {
    final Collection col = mockCollection(1);
    final DocumentImpl doc1 = mockDoc(col, 1);
    final DocumentImpl doc6 = mockDoc(col, 6);
    final DocumentImpl doc9 = mockDoc(col, 9);
    final DocumentImpl doc15 = mockDoc(col, 15);
    final DocumentImpl doc34 = mockDoc(col, 34);
    replay(col, doc1, doc6, doc9, doc15, doc34);
    final DefaultDocumentSet set1 = new DefaultDocumentSet();
    set1.add(doc1);
    set1.add(doc6);
    set1.add(doc9);
    set1.add(doc15);
    set1.add(doc34);
    final DefaultDocumentSet set2 = new DefaultDocumentSet();
    set2.add(doc1);
    set2.add(doc6);
    set2.add(doc9);
    // functions under test
    assertFalse(set1.equalDocs(set2));
    assertFalse(set2.equalDocs(set1));
    verify(col, doc1, doc6, doc9, doc15, doc34);
}
Also used : Collection(org.exist.collections.Collection) Test(org.junit.Test)

Example 98 with Collection

use of org.exist.collections.Collection in project exist by eXist-db.

the class DefaultDocumentSetTest method contains_noMatch.

@Test
public void contains_noMatch() {
    final Collection col = mockCollection(1);
    final DocumentImpl doc1 = mockDoc(col, 1);
    final DocumentImpl doc6 = mockDoc(col, 6);
    final DocumentImpl doc9 = mockDoc(col, 9);
    final DocumentImpl doc15 = mockDoc(col, 15);
    final DocumentImpl doc34 = mockDoc(col, 34);
    replay(col, doc1, doc6, doc9, doc15, doc34);
    final DefaultDocumentSet set1 = new DefaultDocumentSet();
    set1.add(doc1);
    set1.add(doc6);
    set1.add(doc9);
    final DefaultDocumentSet set2 = new DefaultDocumentSet();
    set2.add(doc15);
    set2.add(doc34);
    // functions under test
    assertFalse(set2.contains(set1));
    assertFalse(set1.contains(set2));
    verify(col, doc1, doc6, doc9, doc15, doc34);
}
Also used : Collection(org.exist.collections.Collection) Test(org.junit.Test)

Example 99 with Collection

use of org.exist.collections.Collection in project exist by eXist-db.

the class DefaultDocumentSetTest method contains_nonOptimized_rightLeft.

@Test
public void contains_nonOptimized_rightLeft() {
    final Collection col = mockCollection(1);
    final DocumentImpl doc1 = mockDoc(col, 1);
    final DocumentImpl doc6 = mockDoc(col, 6);
    final DocumentImpl doc9 = mockDoc(col, 9);
    final DocumentImpl doc15 = mockDoc(col, 15);
    final DocumentImpl doc34 = mockDoc(col, 34);
    final DefaultDocumentSet set1 = new DefaultDocumentSet();
    final DocumentSet set2 = testableDocumentSet(doc1, doc6, doc9);
    replay(col, set2, doc1, doc6, doc9, doc15, doc34);
    set1.add(doc1);
    set1.add(doc6);
    set1.add(doc9);
    set1.add(doc15);
    set1.add(doc34);
    // functions under test
    assertTrue(set1.contains(set2));
    verify(col, set2, doc1, doc6, doc9, doc15, doc34);
}
Also used : Collection(org.exist.collections.Collection) Test(org.junit.Test)

Example 100 with Collection

use of org.exist.collections.Collection in project exist by eXist-db.

the class TwoDatabasesTest method setUp.

@Before
public void setUp() throws Exception {
    final BrokerPool pool1 = existEmbeddedServer1.getBrokerPool();
    user1 = pool1.getSecurityManager().getSystemSubject();
    try (final DBBroker broker1 = pool1.get(Optional.of(user1))) {
        final Collection top1 = broker1.getCollection(XmldbURI.create("xmldb:exist:///"));
        assertTrue(top1 != null);
    }
    final BrokerPool pool2 = existEmbeddedServer2.getBrokerPool();
    user2 = pool2.getSecurityManager().getSystemSubject();
    try (final DBBroker broker2 = pool2.get(Optional.of(user2))) {
        final Collection top2 = broker2.getCollection(XmldbURI.create("xmldb:exist:///"));
        assertTrue(top2 != null);
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) Collection(org.exist.collections.Collection) BrokerPool(org.exist.storage.BrokerPool)

Aggregations

Collection (org.exist.collections.Collection)297 Txn (org.exist.storage.txn.Txn)160 XmldbURI (org.exist.xmldb.XmldbURI)99 DBBroker (org.exist.storage.DBBroker)89 TransactionManager (org.exist.storage.txn.TransactionManager)86 BrokerPool (org.exist.storage.BrokerPool)69 StringInputSource (org.exist.util.StringInputSource)57 Test (org.junit.Test)57 EXistException (org.exist.EXistException)43 PermissionDeniedException (org.exist.security.PermissionDeniedException)43 DocumentImpl (org.exist.dom.persistent.DocumentImpl)42 IOException (java.io.IOException)33 LockedDocument (org.exist.dom.persistent.LockedDocument)31 SAXException (org.xml.sax.SAXException)26 InputStream (java.io.InputStream)19 Path (java.nio.file.Path)19 Permission (org.exist.security.Permission)19 LockException (org.exist.util.LockException)16 TriggerException (org.exist.collections.triggers.TriggerException)15 BinaryDocument (org.exist.dom.persistent.BinaryDocument)15