protected void afterBootstrapMain()

in tooling/hawtio-maven-plugin/src/main/java/io/hawt/maven/TestMojo.java [57:95]


    protected void afterBootstrapMain() throws Exception {
        Class<?> clazz = null;
        Object instance = null;

        if (className != null) {
            // must load class and methods using reflection as otherwise we have class-loader/compiled class issues
            getLog().info("*************************************");
            getLog().info("Testing: " + className);
            getLog().info("*************************************");

            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
            instance = ReflectionHelper.newInstance(clazz);
            getLog().debug("Loaded " + className + " and instantiated " + instance);

            ReflectionHelper.invokeMethod(jUnitService.findBeforeClass(clazz), instance);
            ReflectionHelper.invokeMethod(jUnitService.findBefore(clazz), instance);

            // loop all test methods
            List<Method> testMethods = jUnitService.findTestMethods(clazz);
            testMethods = jUnitService.filterTestMethods(testMethods, testName);
            getLog().info("Found and filtered " + testMethods.size() + " @Test methods to invoke");

            for (Method testMethod : testMethods) {
                getLog().info("Invoking @Test method " + testMethod + " on " + className);
                ReflectionHelper.invokeMethod(testMethod, instance);
            }
        }

        getLog().info("*************************************");
        getLog().info("         Press ENTER to exit         ");
        getLog().info("*************************************");
        Console console = System.console();
        console.readLine();

        if (className != null) {
            ReflectionHelper.invokeMethod(jUnitService.findAfter(clazz), instance);
            ReflectionHelper.invokeMethod(jUnitService.findAfterClass(clazz), instance);
        }
    }