junit.framework.Protectable Java Examples

The following examples show how to use junit.framework.Protectable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NbModuleSuite.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void run(final TestResult result) {
    result.runProtected(this, new Protectable() {
        public @Override void protect() throws Throwable {
            ClassLoader before = Thread.currentThread().getContextClassLoader();
            try {
                runInRuntimeContainer(result);
            } finally {
                Thread.currentThread().setContextClassLoader(before);
            }
        }
    });
}
 
Example #2
Source File: TestImplementorTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void run(TestResult result) {
	result.startTest(this);
	Protectable p= new Protectable() {
		public void protect() throws Throwable {
			fTestCase.runBare();
			fTestCase.runBare();
		}
	};
	result.runProtected(this, p);
	result.endTest(this);
}
 
Example #3
Source File: TestRequestBuilderTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void run(TestResult testResult) {
  testResult.startTest(this);
  testResult.runProtected(
      this,
      new Protectable() {
        @Override
        public void protect() throws Throwable {
          fail("broken");
        }
      });
  testResult.endTest(this);
}
 
Example #4
Source File: NumberedTestCase.java    From tomee with Apache License 2.0 5 votes vote down vote up
protected void run(final TestResult result, final Method testMethod) {
    final Test test = createTest(testMethod);
    result.startTest(test);
    final Protectable p = new Protectable() {
        public void protect() throws Throwable {
            runTestMethod(testMethod);
        }
    };
    //System.out.println(">>" + NumberedTestCase.class.getName() + "> started: " + testMethod.toGenericString());
    result.runProtected(test, p);
    result.endTest(test);
    //System.out.println(">>" + NumberedTestCase.class.getName() + "> done: " + testMethod.toGenericString());
}
 
Example #5
Source File: AbstractTestSuite.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
@Override
public void run(final TestResult result) {
    final Protectable p = () -> {
        setUp();
        basicRun(result);
        tearDown();
        validateThreadSnapshot();
    };
    result.runProtected(this, p);
}
 
Example #6
Source File: DelegatingTestResult.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
public void runProtected(final Test test, Protectable p) {
  wrappedResult.runProtected(test, p);
}
 
Example #7
Source File: NonExecutingTestResult.java    From android-test with Apache License 2.0 4 votes vote down vote up
/** Override to prevent the {@link Protectable} from being run. */
@Override
public void runProtected(Test test, Protectable p) {}