Java 类java.lang.NoClassDefFoundError 实例源码

项目:missinglink    文件:SuperClassMissingTest.java   
@Test
public void shouldThrowError() throws Exception {
  thrown.expect(NoClassDefFoundError.class);
  thrown.expectMessage("WillGoAway");

  SuperClassMissing.main(new String[0]);
}
项目:pluotsorbet    文件:constructor.java   
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    NoClassDefFoundError error1 = new NoClassDefFoundError();
    harness.check(error1 != null);
    harness.check(error1.toString(), "java.lang.NoClassDefFoundError");

    NoClassDefFoundError error2 = new NoClassDefFoundError("nothing happens");
    harness.check(error2 != null);
    harness.check(error2.toString(), "java.lang.NoClassDefFoundError: nothing happens");
}
项目:pluotsorbet    文件:TryCatch.java   
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    // flag that is set when exception is caught
    boolean caught = false;
    try {
        throw new NoClassDefFoundError("NoClassDefFoundError");
    }
    catch (NoClassDefFoundError e) {
        // correct exception was caught
        caught = true;
    }
    harness.check(caught);
}