public void test() { UnitOfWork uow = getSession().acquireUnitOfWork(); employee = (Employee) uow.readObject(Employee.class); originalReadTime = ((AbstractSession) getSession()) .getIdentityMapAccessorInstance() .getCacheKeyForObject(employee) .getReadTime(); employee.setFirstName(employee.getFirstName() + "-mutated"); try { Thread.sleep(100); } catch (InterruptedException exc) { } uow.commit(); secondReadTime = getAbstractSession() .getIdentityMapAccessorInstance() .getCacheKeyForObject(employee) .getReadTime(); }
public void watchOtherThreads() { long startTime = System.currentTimeMillis(); while (((System.currentTimeMillis() - startTime) < (runTime + 30000)) && ConcurrentTestRefreshWithOptimisticLocking.execute) { for (int localIdex = 0; localIdex < numThreads; ++localIdex) { if ((System.currentTimeMillis() - ConcurrentTestRefreshWithOptimisticLocking.timeList[localIdex]) > 30000) { // System.out.println(" Number: " + localIdex + " time: " + (System.currentTimeMillis() - // this.timeList[localIdex])); execute = false; break; } } try { Thread.sleep(30000); } catch (InterruptedException ex) { throw new TestProblemException("Test thread was interrupted. Test failed to run properly"); } } }