@@ -0,0 +1,2694 @@
+package com.orientechnologies.orient.test.database.auto;%0A%0Aimport java.util.List;%0A%0Aimport org.testng.annotations.Test;%0A%0Aimport com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;%0Aimport com.orientechnologies.orient.core.index.OIndexException;%0Aimport com.orientechnologies.orient.core.metadata.schema.OClass;%0Aimport com.orientechnologies.orient.core.metadata.schema.OType;%0Aimport com.orientechnologies.orient.core.record.impl.ODocument;%0Aimport com.orientechnologies.orient.core.sql.OCommandSQL;%0A%0A/**%0A * @author Andrey Lomakin %3Ca href=%22mailto:lomakin.andrey@gmail.com%22%3EAndrey Lomakin%3C/a%3E%0A * @since 11/18/13%0A */%0A@Test%0Apublic class IndexConcurrentCommitTest %7B%0A  public void testConcurrentUpdate() %7B%0A    ODatabaseDocumentTx db = new ODatabaseDocumentTx(%22plocal:scratchpad%22);%0A    if (db.exists()) %7B%0A      db.open(%22admin%22, %22admin%22);%0A      db.drop();%0A    %7D%0A%0A    db.create();%0A%0A    OClass personClass = db.getMetadata().getSchema().createClass(%22Person%22);%0A    personClass.createProperty(%22ssn%22, OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE);%0A    personClass.createProperty(%22name%22, OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);%0A%0A    try %7B%0A      // Transaction 1%0A      db.begin();%0A%0A      // Insert two people in a transaction%0A      ODocument person1 = new ODocument(%22Person%22);%0A      person1.field(%22name%22, %22John Doe%22);%0A      person1.field(%22ssn%22, %22111-11-1111%22);%0A      person1.save();%0A%0A      ODocument person2 = new ODocument(%22Person%22);%0A      person2.field(%22name%22, %22Jane Doe%22);%0A      person2.field(%22ssn%22, %22222-22-2222%22);%0A      person2.save();%0A%0A      // Commit%0A      db.commit();%0A%0A      // Ensure that the people made it in correctly%0A      final List%3CODocument%3E result1 = db.command(new OCommandSQL(%22select from Person%22)).execute();%0A      System.out.println(%22After transaction 1%22);%0A      for (ODocument d : result1)%0A        System.out.println(d);%0A%0A      // Transaction 2%0A      db.begin();%0A%0A      // Update the ssn for the second person%0A      person2.field(%22ssn%22, %22111-11-1111%22);%0A      person2.save();%0A%0A      // Update the ssn for the first person%0A      person1.field(%22ssn%22, %22222-22-2222%22);%0A      person1.save();%0A%0A      System.out.println(%22To be committed:%22);%0A      System.out.println(person1);%0A      System.out.println(person2);%0A      // Commit - We get a transaction failure!%0A      db.commit();%0A%0A      System.out.println(%22Success!%22);%0A    %7D catch (OIndexException e) %7B%0A      System.out.println(%22Exception: %22 + e.toString());%0A      db.rollback();%0A    %7D%0A%0A    final List%3CODocument%3E result2 = db.command(new OCommandSQL(%22select from Person%22)).execute();%0A    System.out.println(%22After transaction 2%22);%0A    for (ODocument d : result2)%0A      System.out.println(d);%0A%0A    db.close();%0A  %7D%0A%7D%0A

Index commit test was added.