@After public void tearDown() { testDocumentTx.activateOnCurrentThread(); testDocumentTx.drop(); baseDocumentTx.activateOnCurrentThread(); baseDocumentTx.drop(); OFileUtils.deleteRecursively(buildDir); Assert.assertFalse(buildDir.exists()); }
@Test public void testLiveInsert() { OLiveCommandExecutorSQLFactory.init(); ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OLiveQueryTest"); db.activateOnCurrentThread(); db.create(); db.registerHook(new OLiveQueryHook(db)); try { db.getMetadata().getSchema().createClass("test"); db.getMetadata().getSchema().createClass("test2"); MyLiveQueryListener listener = new MyLiveQueryListener(); db.query(new OLiveQuery<ODocument>("live select from test", listener)); db.command(new OCommandSQL("insert into test set name = 'foo', surname = 'bar'")).execute(); db.command(new OCommandSQL("insert into test set name = 'foo', surname = 'baz'")).execute(); db.command(new OCommandSQL("insert into test2 set name = 'foo'")); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } Assert.assertEquals(listener.ops.size(), 2); for (ORecordOperation doc : listener.ops) { Assert.assertEquals(doc.type, ORecordOperation.CREATED); Assert.assertEquals(((ODocument) doc.record).field("name"), "foo"); } } finally { db.drop(); } }
@Before public void prepareDatabase() throws Exception { String dbUrl = "memory:test"; ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl); String username = "******"; String password = "******"; if (db.exists()) { db.activateOnCurrentThread(); db.open(username, password); db.drop(); } db.create(); createSchemaDB(db); if (!new File("./src/test/resources/file.pdf").exists()) OLogManager.instance() .warn( this, "TEST IS NOT RUNNING UNDER distributed folder, attachment will be not loaded!"); loadDB(db, 20); Properties info = new Properties(); info.put("user", username); info.put("password", password); conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:" + dbUrl, info); }
@AfterClass public void afterClass() throws Exception { sbTree.clear(); sbTree.delete(); databaseDocumentTx.drop(); }
@Before public void setuUp() throws Exception { spwanServer(); baseDocumentTx = new ODatabaseDocumentTx( "plocal:" + buildDir.getAbsolutePath() + "/baseUniqueIndexCrashRestore"); if (baseDocumentTx.exists()) { baseDocumentTx.open("admin", "admin"); baseDocumentTx.drop(); } baseDocumentTx.create(); testDocumentTx = new ODatabaseDocumentTx("remote:localhost:3500/testUniqueIndexCrashRestore"); testDocumentTx.open("admin", "admin"); }
@BeforeClass public void beforeClass() { buildDirectory = System.getProperty("buildDirectory"); if (buildDirectory == null) buildDirectory = "."; databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/localSBTreeBigValuesTest"); if (databaseDocumentTx.exists()) { databaseDocumentTx.open("admin", "admin"); databaseDocumentTx.drop(); } databaseDocumentTx.create(); sbTree = new OSBTree<Integer, byte[]>( "sbTree", ".sbt", false, ".nbt", (OAbstractPaginatedStorage) databaseDocumentTx.getStorage()); sbTree.create(OIntegerSerializer.INSTANCE, OBinaryTypeSerializer.INSTANCE, null, 1, false); }
@Override @Test(enabled = false) public void init() throws Exception { String buildDirectory = System.getProperty("buildDirectory", "."); if (buildDirectory == null) buildDirectory = "."; databaseDocumentTx = new ODatabaseDocumentTx("local:" + buildDirectory + "/uniqueHashIndexTest"); if (databaseDocumentTx.exists()) { databaseDocumentTx.open("admin", "admin"); databaseDocumentTx.drop(); } databaseDocumentTx.create(); long maxMemory = 2L * 1024 * 1024 * 1024; System.out.println("Max memory :" + maxMemory); buffer = new O2QCache( maxMemory, 15000, ODirectMemoryFactory.INSTANCE.directMemory(), null, OHashIndexBucket.MAX_BUCKET_SIZE_BYTES, (OStorageLocal) databaseDocumentTx.getStorage(), false); hashIndex = new OUniqueHashIndex(); hashIndex.create( "uhashIndexTest", new OSimpleKeyIndexDefinition(OType.STRING), databaseDocumentTx, OMetadata.CLUSTER_INDEX_NAME, new int[0], null); }
@Override @Test(enabled = false) public void deinit() throws Exception { hashIndex.delete(); databaseDocumentTx.drop(); }