InterleavedRunner: Class not instrumented

27 views
Skip to first unread message

burny

unread,
Sep 19, 2011, 1:20:24 PM9/19/11
to Thread Weaver
Hi,
I tried to create an interleaved test thingy for a class with at
least(!) one race condition/multithreadin issue in it, which I
already
was able to reproduce using stuff from the very bottom of the thread-
weaver wiki entry.
As the InterleavedRunner does a kind of n*n test (if I understood the
wiki the right way), it should be really perfect for uncovering more
issues in methods when it comes to multithreading.
For a start, I modified the example in the wiki(needs correction!) to
my needs and tried to run the tests, but it says that the class under
test is not instrumented. I posted some distinct example piece on my
blog at http://burnysblog.blogspot.com/2011/09/race-conditions-are-result-of-lazy.html
My JUnit test routine looks as follows:
//The test method that uses the two runnable classes
@Test
public void testPutIfAbsent() throws Throwable {
MainTest main = new MainTest();
SecondaryTest secondary = new SecondaryTest();
// Use an InterleavedRunner to run the two tests
// FAILS HERE!!!!
RunResult result = InterleavedRunner.interleave(main, secondary);
// Throws any exceptions produced by the two threads. Can also
// query for individual exceptions.
result.throwExceptionsIfAny();
}
Stack trace:
java.lang.IllegalArgumentException: Class DateTime is not
instrumented
at
com.google.testing.threadtester.CallLoggerFactory.getClassInstrumentation(CallLoggerFactory.java:
108)
at
com.google.testing.threadtester.InterleavedRunner.doInterleave(InterleavedRunner.java:
130)
at
com.google.testing.threadtester.InterleavedRunner.interleave(InterleavedRunner.java:
80)
at
com.example.DateTimeMultithreadingTest.testPutIfAbsent(DateTimeMultithreadingTest.java:
72)
....

Test classes:
static class MainTest extends MainRunnableImpl<DateTime> {
private DateTime datetime;
@Override
public Class<DateTime> getClassUnderTest() {
return DateTime.class;
}
@Override
public String getMethodName() {
return "getColonTime";
}
@Override
public DateTime getMainObject() {
return datetime;
}
public void initialize() {
// 0 seconds unix timestamp
datetime = DateTime.newInstance(0);
}
@Override
public void run() throws Exception {
assertNotNull(datetime.getColonTime());
}
}
/************* SecondaryTest class*********************/
static class SecondaryTest extends SecondaryRunnableImpl<DateTime,
MainTest> {
private DateTime datetime;
@Override
public void initialize(MainTest main) throws Exception {
datetime = main.datetime;
super.initialize(main);
}
@Override
public void run() throws Exception {
assertNotNull(datetime.getColonTime());
}
}
Thanks in advance for any help :)
Reply all
Reply to author
Forward
0 new messages