Loading ...
Sorry, an error occurred while loading the content.

Re: Re: Multithreaded code

Expand Messages
  • Emily Bache
    Hi 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
    Message 1 of 10 , Oct 1, 2001
    View Source
    • 0 Attachment
      Hi 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
      all pass:

      .............F.F..F.F..F.F..F.F..F.F..F.F..F.F..F.F..F.F..F.
      F..F.F..F.F...F..F.F..F.F..F.F..F.F..F.F..F.F..F.F.

      Time: 20.229 There were 39 failures:

      1)
      testTenPutThreadsVersusOneTakeThread(utmj.threaded.example.NonDeterministicB
      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.

      Regards,

      Emily

      >
      > 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
      > http://c2.com/cgi/wiki?JavaUnitTestChallangeSolved.
      >
      > I just uploaded the code to the group's files area:
      > threadedtesting.jar
      >
      > Comments appreciated.
      >
      > Johannes
      >
      >
    • Johannes Link
      Emily, Thanks for looking at the code. ... This class shouldn t be there in the first place. It s completely out of context. My mistake. ... This is the main
      Message 2 of 10 , Oct 1, 2001
      View Source
      • 0 Attachment
        Emily,

        Thanks for looking at the code.

        > The class utmj.tests.AllTests doesn't compile, so
        > I removed it.

        This class shouldn't be there in the first place. It's completely out of
        context. My mistake.

        > Unfortunately not all the other tests pass. Although all the
        > utmj.threaded.AllTests tests pass,

        This is the main thing, so you should be able to use the package.

        > the utmj.threaded.example.AllTests don't
        > all pass:
        [...]
        > I'm hesitant to look more closely into your code when the tests bundled with
        > it don't run.

        This is expected behaviour, since the example test suite is there to
        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.

        regards, Johannes
      Your message has been successfully submitted and would be delivered to recipients shortly.