1 18 package org.apache.activemq.systest; 19 20 import junit.framework.AssertionFailedError; 21 import junit.framework.Test; 22 import junit.framework.TestResult; 23 24 29 public class ScenarioTestCase implements Test { 30 31 private Scenario scenario; 32 private String description; 33 34 public ScenarioTestCase(Scenario scenario, String description) { 35 this.scenario = scenario; 36 this.description = description; 37 } 38 39 public int countTestCases() { 40 return 1; 41 } 42 43 public void run(TestResult result) { 44 result.startTest(this); 45 try { 46 scenario.start(); 47 scenario.run(); 48 scenario.stop(); 49 result.endTest(this); 50 } 51 catch (AssertionFailedError e) { 52 result.addFailure(this, e); 53 } 54 catch (Throwable e) { 55 System.out.println("Failed to run test: " + e); 56 e.printStackTrace(); 57 result.addError(this, e); 58 } 59 finally { 60 try { 61 scenario.stop(); 62 scenario = null; 63 } 64 catch (Exception e) { 65 System.out.println("Failed to close down test: " + e); 66 e.printStackTrace(); 67 } 68 } 69 } 70 71 public String toString() { 72 return description; 73 } 74 } 75 | Popular Tags |