Search in sources :

Example 76 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class OLiveQueryShotdownTest method testShutDown.

@Test
public void testShutDown() throws Exception {
    bootServer();
    ODatabaseDocument db = new ODatabaseDocumentTx("remote:localhost/" + OLiveQueryShotdownTest.class.getSimpleName());
    db.open("admin", "admin");
    db.getMetadata().getSchema().createClass("Test");
    final CountDownLatch error = new CountDownLatch(1);
    try {
        db.command(new OLiveQuery("live select from Test", new OLiveResultListener() {

            @Override
            public void onUnsubscribe(int iLiveToken) {
            }

            @Override
            public void onLiveResult(int iLiveToken, ORecordOperation iOp) throws OException {
            }

            @Override
            public void onError(int iLiveToken) {
                error.countDown();
            }
        })).execute();
        shutdownServer();
        assertTrue("onError method never called on shutdow", error.await(2, TimeUnit.SECONDS));
    } finally {
    //      db.close();
    }
}
Also used : ORecordOperation(com.orientechnologies.orient.core.db.record.ORecordOperation) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OLiveQuery(com.orientechnologies.orient.core.sql.query.OLiveQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OException(com.orientechnologies.common.exception.OException) CountDownLatch(java.util.concurrent.CountDownLatch) OLiveResultListener(com.orientechnologies.orient.core.sql.query.OLiveResultListener) Test(org.junit.Test)

Example 77 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class HookInstallServerTest method test.

@Test
public void test() {
    OPartitionedDatabasePool pool = new OPartitionedDatabasePool("remote:localhost/test", "admin", "admin");
    for (int i = 0; i < 10; i++) {
        ODatabaseDocument some = pool.acquire();
        try {
            some.save(new ODocument("Test").field("entry", i));
        } finally {
            some.close();
        }
    }
    pool.close();
    Assert.assertEquals(10, count);
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OPartitionedDatabasePool(com.orientechnologies.orient.core.db.OPartitionedDatabasePool) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 78 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class DbDeleteTest method testDbDeleteNoCredential.

public void testDbDeleteNoCredential() throws IOException {
    ODatabaseDocument db = new ODatabaseDocumentTx(url);
    try {
        db.drop();
        Assert.fail("Should have thrown ODatabaseException because trying to delete a not opened");
    } catch (ODatabaseException e) {
        Assert.assertTrue(e.getMessage().contains("Database '" + url + "' is closed"));
    } catch (OStorageException e) {
        Assert.assertTrue(e.getMessage().startsWith("Cannot delete the remote storage:"));
    }
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OStorageException(com.orientechnologies.orient.core.exception.OStorageException) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException)

Example 79 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class DbDeleteTest method testDbDeleteWithIndex.

public void testDbDeleteWithIndex() {
    String prefix = url.substring(0, url.indexOf(':') + 1);
    if (prefix.equals("remote:"))
        return;
    ODatabaseDocument db = new ODatabaseDocumentTx(prefix + testPath + "/" + DbImportExportTest.NEW_DB_URL);
    if (!db.exists())
        db.create();
    if (db.exists()) {
        if (db.isClosed())
            db.open("admin", "admin");
        db.drop();
        db.create();
    }
    final OClass indexedClass = db.getMetadata().getSchema().createClass("IndexedClass");
    indexedClass.createProperty("value", OType.STRING);
    indexedClass.createIndex("indexValue", OClass.INDEX_TYPE.UNIQUE, "value");
    final ODocument document = new ODocument("IndexedClass");
    document.field("value", "value");
    document.save();
    db.drop();
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 80 with ODatabaseDocument

use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.

the class DbCreationTest method testDbCreationNoSecurity.

public void testDbCreationNoSecurity() throws IOException {
    if (!url.startsWith(OEngineRemote.NAME)) {
        ODatabaseDocument db = new ODatabaseDocumentTx(url);
        db.setProperty("security", OSecurityNull.class);
        ODatabaseHelper.dropDatabase(db, "server", getStorageType());
        ODatabaseHelper.createDatabase(db, url, getStorageType());
        ODatabaseHelper.dropDatabase(db, "server", getStorageType());
        database = new OObjectDatabaseTx(url);
        database.setProperty("security", OSecurityNull.class);
        ODatabaseHelper.dropDatabase(database, "server", getStorageType());
        ODatabaseHelper.createDatabase(database, url, getStorageType());
        ODatabaseHelper.dropDatabase(database, "server", getStorageType());
    }
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OObjectDatabaseTx(com.orientechnologies.orient.object.db.OObjectDatabaseTx) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Aggregations

ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)187 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)81 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)68 Test (org.testng.annotations.Test)53 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)47 ORecordId (com.orientechnologies.orient.core.id.ORecordId)23 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)17 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)16 ORecord (com.orientechnologies.orient.core.record.ORecord)14 Test (org.junit.Test)14 OCommandRequestText (com.orientechnologies.orient.core.command.OCommandRequestText)12 ORID (com.orientechnologies.orient.core.id.ORID)11 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)10 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)9 OValidationException (com.orientechnologies.orient.core.exception.OValidationException)9 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)9 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)9 ArrayList (java.util.ArrayList)9 OMetadataInternal (com.orientechnologies.orient.core.metadata.OMetadataInternal)8 HashSet (java.util.HashSet)8