title: Java: Exception testing with Junit 3
body: <p>I would like to write a test for <code>IndexOutOfBoundsException</code>. Keep in mind that we are supposed to use JUnit 3.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>public boolean ajouter(int indice, T element) {
      if (indice &lt; 0 || indice &gt; (maListe.size() - 1)) {
          throw new IndexOutOfBoundsException();
      } else if (element != null &amp;&amp; !maListe.contains(element)) {
          maListe.set(indice, element);
          return true;
      }
  }
  </code></pre>
  
  <p>After some research, I found that you can do this with JUnit 4 using <code>@Test(expected = IndexOutOfBoundsException.class)</code> but no where did I find how to do this in JUnit 3. </p>
  
  <p>How can I test this using JUnit 3?</p>