use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class NestedTxTest method testNestedTx.
@Test
public void testNestedTx() throws InterruptedException, ExecutionException {
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final OrientGraphFactory factory = new OrientGraphFactory("memory:NestedTxTest.testNestedTx", "admin", "admin").setupPool(2, 10);
factory.setAutoStartTx(false);
final OrientGraph graph = factory.getTx();
graph.createVertexType("A");
graph.createVertexType("B");
executorService.submit(new Runnable() {
@Override
public void run() {
final OrientGraph graph = getGraph(factory);
graph.begin();
graph.addVertex("class:A");
}
}).get();
Assert.assertTrue("vertex A should not exist before top-level commit", !vertexExists(graph, "A"));
executorService.submit(new Runnable() {
@Override
public void run() {
final OrientGraph graph = getGraph(factory);
graph.begin();
graph.addVertex("class:B");
}
}).get();
Assert.assertTrue("vertex B should not exist before top-level commit", !vertexExists(graph, "B"));
executorService.submit(new Runnable() {
@Override
public void run() {
final OrientGraph graph = getGraph(factory);
graph.commit();
}
}).get();
Assert.assertTrue("vertex A should not exist before top-level commit", !vertexExists(graph, "A"));
Assert.assertTrue("vertex B should not exist before top-level commit", !vertexExists(graph, "B"));
executorService.submit(new Runnable() {
@Override
public void run() {
final OrientGraph graph = getGraph(factory);
graph.commit();
}
}).get();
Assert.assertTrue("vertex A should exist after top-level commit", vertexExists(graph, "A"));
Assert.assertTrue("vertex B should exist after top-level commit", vertexExists(graph, "B"));
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class LocalCreateVertexSpeedTest method init.
@Override
@Test(enabled = false)
public void init() {
final OrientGraphFactory factory = new OrientGraphFactory(System.getProperty("url"));
factory.setStandardElementConstraints(false);
if (factory.exists())
factory.drop();
database = factory.getNoTx();
database.createVertexType("Account");
database.getRawGraph().declareIntent(new OIntentMassiveInsert());
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class DistributedHookTest method executeTest.
@Override
protected void executeTest() throws Exception {
for (int s = 1; s <= SERVERS; ++s) {
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
OrientGraphNoTx g = factory.getNoTx();
g.getRawGraph().registerHook(new TestHookSourceNode(), ORecordHook.HOOK_POSITION.REGULAR);
try {
// CREATE (VIA COMMAND)
OIdentifiable inserted = g.command(new OCommandSQL("insert into OUser (name, password, status) values ('novo" + s + "','teste','ACTIVE') RETURN @rid")).execute();
Assert.assertNotNull(inserted);
Assert.assertEquals(beforeCreate.get(), s);
Assert.assertEquals(afterCreate.get(), s);
ODocument loadedDoc = inserted.getIdentity().copy().getRecord();
// UPDATE
loadedDoc.field("additionalProperty", "test");
loadedDoc.save();
Assert.assertEquals(beforeUpdate.get(), s);
Assert.assertEquals(afterUpdate.get(), s);
// DELETE
loadedDoc.delete();
Assert.assertEquals(beforeDelete.get(), s);
Assert.assertEquals(afterDelete.get(), s);
} finally {
g.shutdown();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class DistributedSecurityTest method executeTest.
@Override
protected void executeTest() throws Exception {
for (int s = 0; s < SERVERS; ++s) {
OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName(), "reader", "reader");
OrientGraphNoTx g = factory.getNoTx();
try {
try {
// TRY DELETING ALL OUSER VIA COMMAND
Long deleted = g.command(new OCommandSQL("delete from OUser")).execute();
Assert.assertEquals(deleted.longValue(), 0l);
} catch (Exception e) {
Assert.assertTrue(true);
}
try {
// TRY DELETING CURRENT OUSER VIA API
g.getRawGraph().getUser().getIdentity().getRecord().delete();
Assert.assertTrue(false);
} catch (Exception e) {
Assert.assertTrue(true);
}
} finally {
g.shutdown();
}
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class OrientdbEdgeTest method getGraphFactory.
protected static OrientGraphFactory getGraphFactory() throws Exception {
Map<String, Object> conf = new HashMap<String, Object>();
conf.put("storage.url", "remote:localhost/test");
conf.put("storage.pool-min", 1);
conf.put("storage.pool-max", 10);
conf.put("storage.user", "root");
conf.put("storage.password", "root");
OGlobalConfiguration.CLIENT_CONNECT_POOL_WAIT_TIMEOUT.setValue(15000);
verifyDatabaseExists(conf);
return new OrientGraphFactory((String) conf.get("storage.url"), (String) conf.get("storage.user"), (String) conf.get("storage.password")).setupPool((Integer) conf.get("storage.pool-min"), (Integer) conf.get("storage.pool-max"));
}
Aggregations