private void serializable(final IsolationLevels level) throws Exception {
  clear(store);
  final ValueFactory vf=store.getValueFactory();
  final IRI subj=vf.createIRI("http://test#s");
  final IRI pred=vf.createIRI("http://test#p");
  SailConnection prep=store.getConnection();
  try {
    prep.begin(level);
    prep.addStatement(subj,pred,vf.createLiteral(1));
    prep.commit();
  }
  finally {
    prep.close();
  }
  final CountDownLatch start=new CountDownLatch(2);
  final CountDownLatch observed=new CountDownLatch(2);
  Thread t1=incrementBy(start,observed,level,vf,subj,pred,3);
  Thread t2=incrementBy(start,observed,level,vf,subj,pred,5);
  t2.start();
  t1.start();
  t2.join();
  t1.join();
  assertNotFailed();
  SailConnection check=store.getConnection();
  try {
    check.begin(level);
    Literal lit=readLiteral(check,subj,pred);
    int val=lit.intValue();
    if (val != 4 && val != 6) {
      Assert.assertEquals(9,val);
    }
    check.commit();
  }
  finally {
    check.close();
  }
}

private void serializable ( final IsolationLevels level ) throws Exception { clear ( store ) ; final ValueFactory vf = store . getValueFactory ( ) ; final IRI subj = vf . createIRI ( "http://test#s" ) ; final IRI pred = vf . createIRI ( "http://test#p" ) ; SailConnection prep = store . getConnection ( ) ; try { prep . begin ( level ) ; prep . addStatement ( subj , pred , vf . createLiteral ( 1 ) ) ; prep . commit ( ) ; } finally { prep . close ( ) ; } final CountDownLatch start = new CountDownLatch ( 2 ) ; final CountDownLatch observed = new CountDownLatch ( 2 ) ; Thread t1 = incrementBy ( start , observed , level , vf , subj , pred , 3 ) ; Thread t2 = incrementBy ( start , observed , level , vf , subj , pred , 5 ) ; t2 . start ( ) ; t1 . start ( ) ; t2 . join ( ) ; t1 . join ( ) ; assertNotFailed ( ) ; SailConnection check = store . getConnection ( ) ; try { check . begin ( level ) ; Literal lit = readLiteral ( check , subj , pred ) ; int val = lit . intValue ( ) ; if ( val != 4 && val != 6 ) { Assert . assertEquals ( 9 , val ) ; } check . commit ( ) ; } finally { check . close ( ) ; } }
two transactions read a value and replace it
