Search in sources :

Example 41 with Database

use of org.exist.Database in project exist by eXist-db.

the class BlobStoreImplTest method newBlobStore.

private static BlobStore newBlobStore(final Path blobDbx, final Path blobDir) {
    final Database database = createNiceMock(Database.class);
    expect(database.getThreadGroup()).andReturn(Thread.currentThread().getThreadGroup());
    expect(database.getId()).andReturn("BlobStoreTest").times(2);
    expect(database.getJournalManager()).andReturn(Optional.empty()).anyTimes();
    replay(database);
    return new BlobStoreImpl(database, blobDbx, blobDir, DIGEST_TYPE);
}
Also used : Database(org.exist.Database)

Example 42 with Database

use of org.exist.Database in project exist by eXist-db.

the class DebuggerTest method store.

private static void store(final String name, final String data) throws EXistException, PermissionDeniedException, IOException, TriggerException, LockException {
    final Database pool = BrokerPool.getInstance();
    final TransactionManager transact = pool.getTransactionManager();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
        final Txn transaction = transact.beginTransaction()) {
        Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
        broker.saveCollection(transaction, root);
        assertNotNull(root);
        broker.storeDocument(transaction, XmldbURI.create(name), new StringInputSource(data), MimeType.XML_TYPE, root);
        transact.commit(transaction);
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) TransactionManager(org.exist.storage.txn.TransactionManager) Database(org.exist.Database) Collection(org.exist.collections.Collection) Txn(org.exist.storage.txn.Txn)

Aggregations

Database (org.exist.Database)42 DBBroker (org.exist.storage.DBBroker)34 Test (org.junit.Test)29 EXistException (org.exist.EXistException)6 SecurityManager (org.exist.security.SecurityManager)5 BrokerPool (org.exist.storage.BrokerPool)4 XmldbURI (org.exist.xmldb.XmldbURI)4 XQuery (org.exist.xquery.XQuery)4 IOException (java.io.IOException)3 Random (java.util.Random)3 PermissionDeniedException (org.exist.security.PermissionDeniedException)3 CompiledXQuery (org.exist.xquery.CompiledXQuery)3 Ignore (org.junit.Ignore)3 StringWriter (java.io.StringWriter)2 Collection (org.exist.collections.Collection)2 Configuration (org.exist.config.Configuration)2 StreamListener (org.exist.indexing.StreamListener)2 SecurityManagerImpl (org.exist.security.internal.SecurityManagerImpl)2 Serializer (org.exist.storage.serializers.Serializer)2 Configuration (org.exist.util.Configuration)2