use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class CreateIndexCommandTest method before.
@BeforeMethod
public void before() {
database = new ODatabaseDocumentTx("memory:" + CreateIndexCommandTest.class.getSimpleName());
database.create();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class ConcurrencySBTreeBonsaiLocalTest method testName.
@Test
public void testName() throws Exception {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:" + ConcurrencySBTreeBonsaiLocalTest.class.getName());
db.create();
ExecutorService exec = Executors.newCachedThreadPool();
try {
OSBTreeCollectionManager coll = db.getSbTreeCollectionManager();
OBonsaiCollectionPointer treePointer = coll.createSBTree(3, null);
OSBTreeBonsaiLocal<OIdentifiable, Integer> tree = (OSBTreeBonsaiLocal<OIdentifiable, Integer>) coll.loadSBTree(treePointer);
OBonsaiCollectionPointer treePointer1 = coll.createSBTree(3, null);
final OSBTreeBonsaiLocal<OIdentifiable, Integer> tree1 = (OSBTreeBonsaiLocal<OIdentifiable, Integer>) coll.loadSBTree(treePointer1);
final OAtomicOperationsManager atomManager = ((OAbstractPaginatedStorage) db.getStorage()).getAtomicOperationsManager();
atomManager.startAtomicOperation(tree, false);
for (int i = 1000; i < 2000; i++) tree.put(new ORecordId(10, i), 1);
Future<?> ex = null;
try {
ex = exec.submit(new Runnable() {
@Override
public void run() {
try {
atomManager.startAtomicOperation(tree1, false);
for (int i = 2000; i < 3000; i++) tree1.put(new ORecordId(10, i), 1);
atomManager.endAtomicOperation(false, null, tree1);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
ex.get(10, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
// Is supposed to go in deadlock correct that goes in timeout
}
atomManager.endAtomicOperation(false, null, tree);
ex.get();
OSBTreeRidBag bag = new OSBTreeRidBag();
bag.setCollectionPointer(tree.getCollectionPointer());
bag.setAutoConvertToRecord(false);
Assert.assertEquals(tree.size(), 1000);
for (OIdentifiable id : bag) {
if (id.getIdentity().getClusterPosition() > 2000)
Assert.fail("found a wrong rid in the ridbag");
}
OSBTreeRidBag secondBag = new OSBTreeRidBag();
secondBag.setAutoConvertToRecord(false);
secondBag.setCollectionPointer(tree1.getCollectionPointer());
Assert.assertEquals(tree1.size(), 1000);
for (OIdentifiable id : secondBag) {
if (id.getIdentity().getClusterPosition() < 2000)
Assert.fail("found a wrong rid in the ridbag");
}
} finally {
exec.shutdown();
db.drop();
}
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreatePropertyWithLinkedClass.
@Test
public void testCreatePropertyWithLinkedClass() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class division")).execute();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.division LINK division")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_DIVISION);
assertEquals(property.getName(), PROP_DIVISION);
assertEquals(property.getFullName(), PROP_FULL_DIVISION);
assertEquals(property.getType(), OType.LINK);
assertEquals(property.getLinkedClass().getName(), "division");
assertFalse(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreateMandatoryProperty.
@Test
public void testCreateMandatoryProperty() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.name STRING (MANDATORY)")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_NAME);
assertEquals(property.getName(), PROP_NAME);
assertEquals(property.getFullName(), PROP_FULL_NAME);
assertTrue(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testInvalidAttributeName.
@Test(expectedExceptions = OCommandSQLParsingException.class)
public void testInvalidAttributeName() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE CLASS company")).execute();
try {
db.command(new OCommandSQL("CREATE PROPERTY company.id INTEGER (MANDATORY, INVALID, NOTNULL) UNSAFE")).execute();
} finally {
db.close();
}
}
Aggregations