/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

package test;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DummyAnnotatedTest
{
    public String name;
    public int two = 1; //very wrong.
    
    public DummyAnnotatedTest() {
        name="NOT SET";
    }
    public DummyAnnotatedTest(String name) {
        this.name = name;
    }

    @Test(expected=RuntimeException.class)
    public void fail() {
        throw new RuntimeException();
    }
    
    @Before
    public void verifyTwo() {
        two = 2;
    }
    
    @After
    public void printDone() {
        System.out.println("done with an annotated test.");
    }
    
    @Test
    public void add() {
        int four = two+2;
        if(4!=four) {
            throw new RuntimeException("4 did not equal four.");
        }
        //or if you have assertions enabled
        assert 4 == four;
    }
    
    //should always fail
    @Test(timeout=1000)
    public void timeOut() {
        try{
            Thread.sleep(2000);
        }catch (InterruptedException e) { }
    }
}

@@ -811,16 +811,53 @@
  test;%0A%0A
+import static org.junit.Assert.fail;%0A
 import o
@@ -921,16 +921,83 @@
 .Test;%0A%0A
+/**%0A * Sample test cases for demonstrating JUnit4 sampler.%0A * %0A */%0A
 public c
@@ -1149,24 +1149,25 @@
 SET%22;%0A    %7D%0A
+%0A
     public D
@@ -1228,24 +1228,60 @@
 ame;%0A    %7D%0A%0A
+    // Generates expected Exception%0A
     @Test(ex
@@ -1327,20 +1327,37 @@
 ic void 
-fail
+expectedExceptionPass
 () %7B%0A   
@@ -1410,45 +1410,247 @@
     
-@Before%0A    public void verifyTwo() %7B
+// Fails to generate expected Exception%0A    @Test(expected=RuntimeException.class)%0A    public void expectedExceptionFail() %7B%0A    %7D%0A    %0A    @Before%0A    public void verifyTwo() %7B%0A        System.out.println(%22DummyAnnotatedTest#verifyTwo()%22);
 %0A   
@@ -1747,30 +1747,22 @@
 ln(%22
-done with an a
+DummyA
 nnotated
  tes
@@ -1761,14 +1761,24 @@
 ated
- test.
+Test#printDone()
 %22);%0A
@@ -1798,16 +1798,78 @@
   @Test%0A
+    // Succeeds only if Before method - verifyTwo() - is run.%0A
     publ
@@ -2160,16 +2160,20 @@
  timeOut
+Fail
 () %7B%0A   
@@ -2263,11 +2263,451 @@
  %7D%0A    %7D
+%0A%0A    //should not fail%0A    @Test(timeout=1000)%0A    public void timeOutPass() %7B%0A        try%7B%0A            Thread.sleep(500);%0A        %7Dcatch (InterruptedException e) %7B %7D%0A    %7D%0A   %0A    @Test%0A    public void alwaysFail() %7B%0A        fail(%22This always fails%22);%0A    %7D%0A    %0A    @Test%0A    // Generate a test error%0A    public void divideByZero() %7B%0A        @SuppressWarnings(%22unused%22)%0A        int i = 27 / 0; // will generate Divide by zero error%0A    %7D
 %0A%7D%0A

Enhance JUnit4 sample tests