public void testTransactions() throws Throwable { // we cant use non-ramdir on windows, because this test needs to double-write. MockDirectoryWrapper dir1 = new MockDirectoryWrapper(random(), new RAMDirectory()); MockDirectoryWrapper dir2 = new MockDirectoryWrapper(random(), new RAMDirectory()); dir1.setPreventDoubleWrite(false); dir2.setPreventDoubleWrite(false); dir1.failOn(new RandomFailure()); dir2.failOn(new RandomFailure()); dir1.setFailOnOpenInput(false); dir2.setFailOnOpenInput(false); // We throw exceptions in deleteFile, which creates // leftover files: dir1.setAssertNoUnrefencedFilesOnClose(false); dir2.setAssertNoUnrefencedFilesOnClose(false); initIndex(dir1); initIndex(dir2); TimedThread[] threads = new TimedThread[3]; int numThread = 0; IndexerThread indexerThread = new IndexerThread(this, dir1, dir2, threads); threads[numThread++] = indexerThread; indexerThread.start(); SearcherThread searcherThread1 = new SearcherThread(this, dir1, dir2, threads); threads[numThread++] = searcherThread1; searcherThread1.start(); SearcherThread searcherThread2 = new SearcherThread(this, dir1, dir2, threads); threads[numThread++] = searcherThread2; searcherThread2.start(); for (int i = 0; i < numThread; i++) threads[i].join(); for (int i = 0; i < numThread; i++) assertTrue(!threads[i].failed); dir1.close(); dir2.close(); }
public void start() { producer.start(); consumer.start(); }