'How to write integration test of rest api with two threads

what should I use to test a rest api? I want to write integration test with two threads. I am using Controller->Service->Repository model and want to check if there is any race condition.

I tried with Thread Weaver and something like this but it does not work.

public class MyCounterTests {
private MyCounter counter;

@ThreadedBefore
public void before() {
    counter = new MyCounter();
}
@ThreadedMain
public void mainThread() {
    counter.increment();
}
@ThreadedSecondary
public void secondThread() {
    counter.increment();
}
@ThreadedAfter
public void after() {
    assertEquals(2, counter.getCount());
}

@Test
public void testCounter() {
    new AnnotatedTestRunner().runTests(this.getClass(), MyCounter.class);
}

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source