public void startup() { startupIfEnginesAreMissing(); OPartitionedDatabasePool pool = new OPartitionedDatabasePoolFactory().get(type + ":" + name, "admin", "admin"); pool.setAutoCreate(true); db = pool.acquire(); ODatabaseRecordThreadLocal.instance().set(db); updateSchema(); }
public void startup() { startupIfEnginesAreMissing(); OPartitionedDatabasePool pool = new OPartitionedDatabasePoolFactory().get(type + ":" + name, "admin", "admin"); pool.setAutoCreate(true); db = pool.acquire(); ODatabaseRecordThreadLocal.instance().set(db); updateSchema(); }
connectionPool = new OPartitionedDatabasePoolFactory(connPoolSize) .get(ROOT_DATABASE_URL, orientDbStoreParams.getUserName(), orientDbStoreParams.getUserPassword()); } else { connectionPool = new OPartitionedDatabasePoolFactory().get(ROOT_DATABASE_URL, orientDbStoreParams.getUserName(), orientDbStoreParams.getUserPassword());
@Test public void testFilters() throws Exception { FiltersOrientDbRepository repository = new FiltersOrientDbRepository(config, new OPartitionedDatabasePoolFactory()); repository.init(); Assert.assertEquals(0, repository.getAllFiltered("type1").size()); repository.filter("type1", "value1"); repository.filter("type1", "value2"); Assert.assertEquals(2, repository.getAllFiltered("type1").size()); Assert.assertArrayEquals(new String[] { "value1", "value2" }, repository.getAllFiltered("type1").toArray()); repository.notFilter("type1", "value2"); Assert.assertEquals(1, repository.getAllFiltered("type1").size()); repository.destroy(); }
@Test public void testConfigs() throws Exception { OrientDbConfigurationManager cm = new OrientDbConfigurationManager(config, new OPartitionedDatabasePoolFactory()); cm.setHostGroup("dev"); cm.init(); cm.putProperty(ConfigProperty.TEST1_CONFIG, "value"); cm.putProperty(ConfigProperty.POLL_INTERVAL, 16); Assert.assertEquals("value", cm.readString(ConfigProperty.TEST1_CONFIG)); Assert.assertEquals(16, cm.readInt(ConfigProperty.POLL_INTERVAL)); cm.destroy(); cm = new OrientDbConfigurationManager(config, new OPartitionedDatabasePoolFactory()); cm.setHostGroup("dev"); cm.init(); Assert.assertEquals("value", cm.readString(ConfigProperty.TEST1_CONFIG)); Assert.assertEquals(16, cm.readInt(ConfigProperty.POLL_INTERVAL)); cm.destroy(); }
@Test public void testRoles() throws Exception { OPartitionedDatabasePoolFactory poolFactory = new OPartitionedDatabasePoolFactory(); AccountOrientDbRepository accRep = new AccountOrientDbRepository(config, poolFactory); accRep.init();
@Test public void test() throws Exception { AccountOrientDbRepository repository = new AccountOrientDbRepository(config, new OPartitionedDatabasePoolFactory()); repository.init(); Assert.assertFalse(repository.account("token").isPresent()); AccountImpl account = AccountImpl.createNew("abc", "Artem", "Dmitriev", "artem@reveno.org", "token", "pass", "salt", new ArrayList<>(), DateTime.now(DateTimeZone.UTC), Collections.emptySet()); account = (AccountImpl) repository.insert(account); Assert.assertNotNull(account.getOId()); Assert.assertTrue(repository.account("token").isPresent()); Assert.assertFalse(repository.account("token").get().isConfirmed()); Assert.assertTrue(repository.confirm("token", "salt")); Account account1 = repository.account("token").get(); Assert.assertTrue(account1.isConfirmed()); Assert.assertFalse(account1.isBlocked()); Assert.assertEquals(repository.accounts().size(), 1); Assert.assertNotNull(repository.account(account1.id()).get()); Assert.assertTrue(repository.account("abc", "pass", AccountRepository.LoginType.USERNAME).isPresent()); repository.block("abc"); account1 = repository.account("token").get(); Assert.assertTrue(account1.isBlocked()); account.setEmail("another@mail.ru"); repository.updateInfo(account); account1 = repository.account("token").get(); Assert.assertEquals(account.email(), account1.email()); Assert.assertTrue(account1.isBlocked()); repository.delete(account1); Assert.assertEquals(repository.accounts().size(), 0); repository.destroy(); }
@Test public void testTriggers() throws Exception { TriggerOrientDbRepository r = new TriggerOrientDbRepository(config, new OPartitionedDatabasePoolFactory()); r.init(); Identifier accId = Identifier.fromStr("123");
public void testOrientDbLifeCycle(String dbURL, boolean createDb, boolean dropDb) throws Exception { Orient.instance().startup(); assertNotNull(ODatabaseRecordThreadLocal.instance()); Orient.instance().removeShutdownHook(); OServer server = OServerMain.create(); server.startup(OrientDbTestWebApplication.class.getResource("db.config.xml").openStream()); server.activate(); if(createDb) { ODatabaseDocument dbToCreate = new ODatabaseDocumentTx(dbURL); if(!dbToCreate.exists()) dbToCreate.create(); dbToCreate.close(); } assertNotNull(ODatabaseRecordThreadLocal.instance()); ODatabaseDocument db = new OPartitionedDatabasePoolFactory().get(dbURL, "admin", "admin").acquire(); db.close(); assertNotNull(ODatabaseRecordThreadLocal.instance()); if(dropDb) { ODatabaseDocument dbToDrop = new ODatabaseDocumentTx(dbURL); dbToDrop.open("admin", "admin"); dbToDrop.drop(); } server.shutdown(); Orient.instance().shutdown(); // Thread.sleep(50); }