Search in sources :

Example 1 with RDBTableMetaData

use of org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData in project jackrabbit-oak by apache.

the class RDBDocumentStoreJDBCTest method queryIteratorConsumedTest.

@Test
public void queryIteratorConsumedTest() throws SQLException {
    insertTestResource(this.getClass().getName() + "." + name.getMethodName());
    LogCustomizer customLogs = LogCustomizer.forLogger(RDBDocumentStoreJDBC.class.getName()).enable(Level.DEBUG).contains("Query on ").create();
    customLogs.starting();
    MyConnectionHandler ch = new MyConnectionHandler(super.rdbDataSource);
    RDBTableMetaData tmd = ((RDBDocumentStore) super.ds).getTable(Collection.NODES);
    List<QueryCondition> conditions = Collections.emptyList();
    try {
        Iterator<RDBRow> qi = jdbc.queryAsIterator(ch, tmd, null, null, RDBDocumentStore.EMPTY_KEY_PATTERN, conditions, Integer.MAX_VALUE, null);
        assertTrue(qi instanceof Closeable);
        assertEquals(1, ch.cnt.get());
        while (qi.hasNext()) {
            qi.next();
        }
        assertEquals(0, ch.cnt.get());
        assertEquals("should have a DEBUG level log entry", 1, customLogs.getLogs().size());
    } finally {
        customLogs.finished();
        customLogs = null;
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Closeable(java.io.Closeable) QueryCondition(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition) Test(org.junit.Test) AbstractDocumentStoreTest(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest)

Example 2 with RDBTableMetaData

use of org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData in project jackrabbit-oak by apache.

the class RDBDocumentStoreJDBCTest method queryIteratorNotStartedTest.

@Test
public void queryIteratorNotStartedTest() throws SQLException {
    insertTestResource(this.getClass().getName() + "." + name.getMethodName());
    MyConnectionHandler ch = new MyConnectionHandler(super.rdbDataSource);
    RDBTableMetaData tmd = ((RDBDocumentStore) super.ds).getTable(Collection.NODES);
    List<QueryCondition> conditions = Collections.emptyList();
    Iterator<RDBRow> qi = jdbc.queryAsIterator(ch, tmd, null, null, RDBDocumentStore.EMPTY_KEY_PATTERN, conditions, Integer.MAX_VALUE, null);
    assertTrue(qi instanceof Closeable);
    assertEquals(1, ch.cnt.get());
    Utils.closeIfCloseable(qi);
    assertEquals(0, ch.cnt.get());
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) Closeable(java.io.Closeable) QueryCondition(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition) Test(org.junit.Test) AbstractDocumentStoreTest(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest)

Example 3 with RDBTableMetaData

use of org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData in project jackrabbit-oak by apache.

the class RDBDocumentStoreSchemaUpgradeTest method initDefault.

@Test
public void initDefault() {
    RDBOptions op = new RDBOptions().tablePrefix("T00").initialSchema(0).upgradeToSchema(0).dropTablesOnClose(true);
    RDBDocumentStore rdb = null;
    try {
        rdb = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), op);
        RDBTableMetaData meta = rdb.getTable(Collection.NODES);
        assertEquals(op.getTablePrefix() + "_NODES", meta.getName());
        assertFalse(meta.hasVersion());
    } finally {
        if (rdb != null) {
            rdb.dispose();
        }
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) Test(org.junit.Test)

Example 4 with RDBTableMetaData

use of org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData in project jackrabbit-oak by apache.

the class RDBDocumentStoreSchemaUpgradeTest method init01.

@Test
public void init01() {
    LogCustomizer logCustomizer = LogCustomizer.forLogger(RDBDocumentStore.class.getName()).enable(Level.INFO).contains("to DB level 1").create();
    logCustomizer.starting();
    RDBOptions op = new RDBOptions().tablePrefix("T01").initialSchema(0).upgradeToSchema(1).dropTablesOnClose(true);
    RDBDocumentStore rdb = null;
    try {
        rdb = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), op);
        RDBTableMetaData meta = rdb.getTable(Collection.NODES);
        assertEquals(op.getTablePrefix() + "_NODES", meta.getName());
        assertTrue(meta.hasVersion());
        assertEquals("unexpected # of log entries: " + logCustomizer.getLogs(), RDBDocumentStore.getTableNames().size(), logCustomizer.getLogs().size());
    } finally {
        logCustomizer.finished();
        if (rdb != null) {
            rdb.dispose();
        }
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Test(org.junit.Test)

Example 5 with RDBTableMetaData

use of org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData in project jackrabbit-oak by apache.

the class RDBDocumentStoreSchemaUpgradeTest method init11.

@Test
public void init11() {
    LogCustomizer logCustomizer = LogCustomizer.forLogger(RDBDocumentStore.class.getName()).enable(Level.INFO).contains("to DB level 1").create();
    logCustomizer.starting();
    RDBOptions op = new RDBOptions().tablePrefix("T11").initialSchema(1).upgradeToSchema(1).dropTablesOnClose(true);
    RDBDocumentStore rdb = null;
    try {
        rdb = new RDBDocumentStore(this.ds, new DocumentMK.Builder(), op);
        RDBTableMetaData meta = rdb.getTable(Collection.NODES);
        assertEquals(op.getTablePrefix() + "_NODES", meta.getName());
        assertTrue(meta.hasVersion());
        assertEquals("unexpected # of log entries: " + logCustomizer.getLogs(), 0, logCustomizer.getLogs().size());
    } finally {
        logCustomizer.finished();
        if (rdb != null) {
            rdb.dispose();
        }
    }
}
Also used : RDBTableMetaData(org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData) LogCustomizer(org.apache.jackrabbit.oak.commons.junit.LogCustomizer) Test(org.junit.Test)

Aggregations

RDBTableMetaData (org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.RDBTableMetaData)9 Test (org.junit.Test)9 AbstractDocumentStoreTest (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentStoreTest)6 LogCustomizer (org.apache.jackrabbit.oak.commons.junit.LogCustomizer)5 QueryCondition (org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore.QueryCondition)5 Closeable (java.io.Closeable)3 Connection (java.sql.Connection)3 UpdateOp (org.apache.jackrabbit.oak.plugins.document.UpdateOp)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)1