Search in sources :

Example 11 with ODatabaseDocumentTx

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

the class OEmbeddedRidBagBasicTest method embeddedRidBagSerializationTest.

@Test
public void embeddedRidBagSerializationTest() {
    ODatabaseDocument db = new ODatabaseDocumentTx("memory:" + OEmbeddedRidBag.class.getSimpleName());
    db.create();
    try {
        OEmbeddedRidBag bag = new OEmbeddedRidBag();
        bag.add(new ORecordId(3, 1000));
        bag.convertLinks2Records();
        bag.convertRecords2Links();
        byte[] bytes = new byte[1024];
        UUID id = UUID.randomUUID();
        bag.serialize(bytes, 0, id);
        OEmbeddedRidBag bag1 = new OEmbeddedRidBag();
        bag1.deserialize(bytes, 0);
        assertEquals(bag.size(), 1);
        assertEquals(null, bag1.iterator().next());
    } finally {
        db.drop();
    }
}
Also used : OEmbeddedRidBag(com.orientechnologies.orient.core.db.record.ridbag.embedded.OEmbeddedRidBag) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) UUID(java.util.UUID) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Example 12 with ODatabaseDocumentTx

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

the class OSchedulerTest method eventLifecycle.

@Test
public void eventLifecycle() throws Exception {
    final ODatabaseDocumentTx db = initDatabase();
    try {
        createLogEvent(db);
        Thread.sleep(2000);
        db.getMetadata().getScheduler().removeEvent("test");
        db.getMetadata().getScheduler().removeEvent("test");
        Thread.sleep(3000);
        db.getMetadata().getScheduler().removeEvent("test");
        Long count = getLogCounter(db);
        Assert.assertTrue(count >= 1 && count <= 3);
    } finally {
        db.drop();
    }
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 13 with ODatabaseDocumentTx

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

the class OSchedulerTest method scheduleSQLFunction.

@Test
public void scheduleSQLFunction() throws Exception {
    final ODatabaseDocumentTx db = initDatabase();
    try {
        createLogEvent(db);
        Thread.sleep(5000);
        Long count = getLogCounter(db);
        Assert.assertTrue(count >= 4 && count <= 5);
    } finally {
        db.drop();
    }
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 14 with ODatabaseDocumentTx

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

the class OSchedulerTest method scheduleWithDbClosed.

@Test
public void scheduleWithDbClosed() throws Exception {
    ODatabaseDocumentTx db = initDatabase();
    createLogEvent(db);
    db.close();
    Thread.sleep(5000);
    db = openDatabase();
    Long count = getLogCounter(db);
    Assert.assertTrue(count >= 4);
    openDatabase().drop();
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 15 with ODatabaseDocumentTx

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

the class OSchedulerTest method initDatabase.

private ODatabaseDocumentTx initDatabase() {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:scheduler");
    db.create();
    return db;
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Aggregations

ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)590 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)257 Test (org.testng.annotations.Test)182 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)120 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)81 Test (org.junit.Test)79 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)61 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)47 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)46 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)41 ORID (com.orientechnologies.orient.core.id.ORID)39 ORecordId (com.orientechnologies.orient.core.id.ORecordId)34 Before (org.junit.Before)34 File (java.io.File)33 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)25 ArrayList (java.util.ArrayList)25 BeforeClass (org.testng.annotations.BeforeClass)23 BeforeMethod (org.testng.annotations.BeforeMethod)23 OStorage (com.orientechnologies.orient.core.storage.OStorage)21 List (java.util.List)20