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();
}
}
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);
}
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:"));
}
}
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();
}
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());
}
}
Aggregations