public void testSimpleTxAdd() throws Exception {
  BigdataSailRepositoryConnection cxn=null;
  final Properties properties=getTriplesNoInference();
  properties.setProperty(BigdataSail.Options.ISOLATABLE_INDICES,"true");
  final BigdataSail sail=getSail(properties);
  try {
    sail.initialize();
    final BigdataSailRepository repo=new BigdataSailRepository(sail);
    cxn=(BigdataSailRepositoryConnection)repo.getConnection();
    cxn.setAutoCommit(false);
    final AbstractTripleStore tripleStore=cxn.getTripleStore();
    final InMemChangeLog changeLog=new InMemChangeLog();
    cxn.addChangeLog(changeLog);
    final BigdataValueFactory vf=(BigdataValueFactory)sail.getValueFactory();
    final String ns=BD.NAMESPACE;
    final URI a=vf.createURI(ns + "A");
    final URI b=vf.createURI(ns + "B");
    final URI c=vf.createURI(ns + "C");
    final BigdataStatement[] stmts=new BigdataStatement[]{vf.createStatement(a,RDFS.SUBCLASSOF,b),vf.createStatement(b,RDFS.SUBCLASSOF,c)};
    final BigdataStatement[] stmts2=new BigdataStatement[]{vf.createStatement(a,RDFS.SUBCLASSOF,c)};
    cxn.setNamespace("ns",ns);
    for (    BigdataStatement stmt : stmts) {
      cxn.add(stmt);
    }
    cxn.commit();
{
      final Collection<IChangeRecord> expected=new LinkedList<IChangeRecord>();
      for (      BigdataStatement stmt : stmts) {
        expected.add(new ChangeRecord(stmt,ChangeAction.INSERTED));
      }
      compare(expected,changeLog.getLastCommit(tripleStore));
    }
    for (    BigdataStatement stmt : stmts) {
      cxn.add(stmt);
    }
    cxn.commit();
{
      compare(new LinkedList<IChangeRecord>(),changeLog.getLastCommit(tripleStore));
    }
    for (    BigdataStatement stmt : stmts2) {
      cxn.add(stmt);
    }
    cxn.commit();
{
      final Collection<IChangeRecord> expected=new LinkedList<IChangeRecord>();
      for (      BigdataStatement stmt : stmts2) {
        expected.add(new ChangeRecord(stmt,ChangeAction.INSERTED));
      }
      compare(expected,changeLog.getLastCommit(tripleStore));
    }
    if (log.isDebugEnabled()) {
      log.debug("\n" + tripleStore.dumpStore(true,true,false));
    }
  }
  finally {
    if (cxn != null)     cxn.close();
    sail.__tearDownUnitTest();
  }
}

public void testSimpleTxAdd ( ) throws Exception { BigdataSailRepositoryConnection cxn = null ; final Properties properties = getTriplesNoInference ( ) ; properties . setProperty ( BigdataSail . Options . ISOLATABLE_INDICES , "true" ) ; final BigdataSail sail = getSail ( properties ) ; try { sail . initialize ( ) ; final BigdataSailRepository repo = new BigdataSailRepository ( sail ) ; cxn = ( BigdataSailRepositoryConnection ) repo . getConnection ( ) ; cxn . setAutoCommit ( false ) ; final AbstractTripleStore tripleStore = cxn . getTripleStore ( ) ; final InMemChangeLog changeLog = new InMemChangeLog ( ) ; cxn . addChangeLog ( changeLog ) ; final BigdataValueFactory vf = ( BigdataValueFactory ) sail . getValueFactory ( ) ; final String ns = BD . NAMESPACE ; final URI a = vf . createURI ( ns + "A" ) ; final URI b = vf . createURI ( ns + "B" ) ; final URI c = vf . createURI ( ns + "C" ) ; final BigdataStatement [ ] stmts = new BigdataStatement [ ] { vf . createStatement ( a , RDFS . SUBCLASSOF , b ) , vf . createStatement ( b , RDFS . SUBCLASSOF , c ) } ; final BigdataStatement [ ] stmts2 = new BigdataStatement [ ] { vf . createStatement ( a , RDFS . SUBCLASSOF , c ) } ; cxn . setNamespace ( "ns" , ns ) ; for ( BigdataStatement stmt : stmts ) { cxn . add ( stmt ) ; } cxn . commit ( ) ; { final Collection < IChangeRecord > expected = new LinkedList < IChangeRecord > ( ) ; for ( BigdataStatement stmt : stmts ) { expected . add ( new ChangeRecord ( stmt , ChangeAction . INSERTED ) ) ; } compare ( expected , changeLog . getLastCommit ( tripleStore ) ) ; } for ( BigdataStatement stmt : stmts ) { cxn . add ( stmt ) ; } cxn . commit ( ) ; { compare ( new LinkedList < IChangeRecord > ( ) , changeLog . getLastCommit ( tripleStore ) ) ; } for ( BigdataStatement stmt : stmts2 ) { cxn . add ( stmt ) ; } cxn . commit ( ) ; { final Collection < IChangeRecord > expected = new LinkedList < IChangeRecord > ( ) ; for ( BigdataStatement stmt : stmts2 ) { expected . add ( new ChangeRecord ( stmt , ChangeAction . INSERTED ) ) ; } compare ( expected , changeLog . getLastCommit ( tripleStore ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "\n" + tripleStore . dumpStore ( true , true , false ) ) ; } } finally { if ( cxn != null ) cxn . close ( ) ; sail . __tearDownUnitTest ( ) ; } }
unit test with a full read / write transaction .
