Skip to content

Commit

Permalink
ISPN-5562 AsyncStoreTest: test that stop() works correctly with concu…
Browse files Browse the repository at this point in the history
…rrent clear()

Signed-off-by: Karsten Blees <blees@dcon.de>
  • Loading branch information
kblees authored and danberindei committed Jun 23, 2015
1 parent 1c9b660 commit 0511613
Showing 1 changed file with 27 additions and 0 deletions.
Expand Up @@ -234,6 +234,33 @@ public void run() {
assertEquals(me.getValue(), key + lastValue[0]);
}

@Test(timeOut=30000)
public void testConcurrentClearAndStop() throws Exception {
TestResourceTracker.backgroundTestStarted(this);
createStore(true);

// start a thread that keeps clearing the store until its stopped
Thread t = new Thread() {
@Override
public void run() {
try {
for (;;)
writer.clear();
} catch (CacheException expected) {
}
}
};
t.start();

// wait until thread has started
Thread.sleep(500);
writer.stop();

// background thread should exit with CacheException
t.join(1000);
assertFalse(t.isAlive());
}

private void doTestPut(int number, String key, String value) throws Exception {

log.tracef("before write");
Expand Down

0 comments on commit 0511613

Please sign in to comment.