Re: Re: Multithreaded code
- View SourceHi Johannes,
Thanks for taking the time to share some classes to help me. I downloaded
your jar and I had a look. The class utmj.tests.AllTests doesn't compile, so
I removed it. Unfortunately not all the other tests pass. Although all the
utmj.threaded.AllTests tests pass, the utmj.threaded.example.AllTests don't
Time: 20.229 There were 39 failures:
oundedBufferTest)junit.framework.AssertionFailedError: Buffer is empty
expected:<0> but was:<1>
<snipped for brevity>
FAILURES!!! Tests run: 72, Failures: 39, Errors: 0
(run with JUnit 3.7 on Windows NT, java 1.3)
I'm hesitant to look more closely into your code when the tests bundled with
it don't run.
> Sorry for not answering your particular questions on the topic and not
> referring to your example.
> What I want to provide is some code I have had in my drawer for some
> time. It basically consists of a few utility classes for testing in a
> multithreaded environment:
> - ThreadedTest: A decorator for running a test in a thread of its own.
> (More or less stolen from JUnitPerf)
> - MultiThreadedTest: A decorator which catches exceptions and test
> failures in spawned threads and makes the testcase fail.
> - ExceptionAssert: A helper class to test for expected exceptions in
> spawned threads.
> - RetriedAssert: A helper class to test for an assert
> condition up to a
> given time limit. (also stolen)
> - ConcurrentTestCase: A subclass of TestCase which provides
> some help in
> doing the kind of semi-deterministic testing which you want to do in
> your example. An example for using this class is also provided in a
> subpackage *.example. Therein you find a test suite for the
> BoundedBuffer example discussed in
> I just uploaded the code to the group's files area:
> Comments appreciated.
- View SourceEmily,
Thanks for looking at the code.
> The class utmj.tests.AllTests doesn't compile, soThis class shouldn't be there in the first place. It's completely out of
> I removed it.
context. My mistake.
> Unfortunately not all the other tests pass. Although all theThis is the main thing, so you should be able to use the package.
> utmj.threaded.AllTests tests pass,
> the utmj.threaded.example.AllTests don't[...]
> all pass:
> I'm hesitant to look more closely into your code when the tests bundled withThis is expected behaviour, since the example test suite is there to
> it don't run.
show two little synchronisation errors in the BoundedBuffer class. Look
at the class' source and change the two lines which are marked as
containing the errors (notifyAll() should replace notify()). THEN, all
tests should run succesfully.