Created
March 9, 2012 15:44
-
-
Save mikeycmccarthy/2007156 to your computer and use it in GitHub Desktop.
Uniqueness test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testUniquenessInMultiThreadedScenario() throws Exception { | |
final Long firstMember = 100L; | |
final List<Exception> exceptionList = new ArrayList<Exception>(); | |
ExecutorService exec = Executors.newFixedThreadPool(16); | |
for (int i = 101; i < 1000; i++) { | |
final Long buddyId = new Long(i); | |
exec.execute(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
memberService.refer(firstMember, buddyId); | |
} catch (NoSuchElementException noSuchElementException) { | |
exceptionList.add(noSuchElementException); | |
} | |
} | |
} | |
); | |
} | |
exec.shutdown(); | |
exec.awaitTermination(50, TimeUnit.SECONDS); | |
assertTrue("Exceptions found when creating nodes", exceptionList.isEmpty()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment