Example usage for junit.framework TestCase getClass

List of usage examples for junit.framework TestCase getClass

Introduction

In this page you can find the example usage for junit.framework TestCase getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.eclipse.gemini.blueprint.test.internal.support.OsgiJUnitTestAdapter.java

public OsgiJUnitTestAdapter(TestCase target) {
    Assert.notNull(target, "the adapter can be used only with a non-null test");

    this.target = target;

    try {//w w  w. j a v  a  2 s .  c  o m

        // determine methods
        injectBundleContext = org.springframework.util.ReflectionUtils.findMethod(target.getClass(),
                "injectBundleContext", new Class<?>[] { BundleContext.class });
        org.springframework.util.ReflectionUtils.makeAccessible(injectBundleContext);

        runTest = org.springframework.util.ReflectionUtils.findMethod(target.getClass(), "osgiRunTest");
        org.springframework.util.ReflectionUtils.makeAccessible(runTest);

        setUp = org.springframework.util.ReflectionUtils.findMethod(target.getClass(), "osgiSetUp");
        org.springframework.util.ReflectionUtils.makeAccessible(setUp);

        tearDown = org.springframework.util.ReflectionUtils.findMethod(target.getClass(), "osgiTearDown");
        org.springframework.util.ReflectionUtils.makeAccessible(tearDown);

    } catch (Exception ex) {
        throw new RuntimeException(
                "cannot determine JUnit hooks; is this test extending Spring-DM test framework?", ex);
    }

}

From source file:net.sourceforge.vulcan.EasyMockTestCase.java

private boolean train(TestCase instance) throws Throwable {
    final Class<? extends TestCase> c = instance.getClass();
    final Method testMethod = c.getMethod(instance.getName(), (Class[]) null);

    final TrainingMethod trainingMethodAnn = testMethod.getAnnotation(TrainingMethod.class);

    if (trainingMethodAnn != null) {
        final String trainingMethodNames[] = trainingMethodAnn.value().split(",");

        try {/*ww w.j av  a  2  s  .c o  m*/
            for (String trainingMethodName : trainingMethodNames) {
                final Method trainingMethod = c.getMethod(trainingMethodName.trim(), (Class[]) null);
                trainingMethod.invoke(instance, (Object[]) null);
            }
            return true;
        } catch (InvocationTargetException e) {
            throw e.getCause();
        } catch (NoSuchMethodException e) {
            fail("TrainingMethod " + trainingMethodAnn.value() + " does not exist or is not accessible.");
        }
    }

    return false;
}

From source file:org.apache.oozie.test.XTestCase.java

/**
 * Return the test working directory.//  www.  j a  v  a 2s .  co m
 * <p/>
 * It returns <code>${oozie.test.dir}/oozietests/TESTCLASSNAME/TESTMETHODNAME</code>.
 *
 * @param testCase testcase instance to obtain the working directory.
 * @return the test working directory.
 */
private String getTestCaseDirInternal(TestCase testCase) {
    ParamChecker.notNull(testCase, "testCase");
    File dir = new File(System.getProperty(OOZIE_TEST_DIR, "target/test-data"));
    dir = new File(dir, "oozietests").getAbsoluteFile();
    dir = new File(dir, testCase.getClass().getName());
    dir = new File(dir, testCase.getName());
    return dir.getAbsolutePath();
}