Search in sources :

Example 1 with Recipe

use of org.jvnet.hudson.test.recipes.Recipe in project hudson-2.x by hudson.

the class HudsonTestCase method recipe.

//
// recipe methods. Control the test environments.
//
/**
     * Called during the {@link #setUp()} to give a test case an opportunity to
     * control the test environment in which Hudson is run.
     *
     * <p>
     * One could override this method and call a series of {@code withXXX} methods,
     * or you can use the annotations with {@link Recipe} meta-annotation.
     */
protected void recipe() throws Exception {
    recipeLoadCurrentPlugin();
    // look for recipe meta-annotation
    try {
        Method runMethod = getClass().getMethod(getName());
        for (final Annotation a : runMethod.getAnnotations()) {
            Recipe r = a.annotationType().getAnnotation(Recipe.class);
            if (r == null)
                continue;
            final Runner runner = r.value().newInstance();
            recipes.add(runner);
            tearDowns.add(new LenientRunnable() {

                public void run() throws Exception {
                    runner.tearDown(HudsonTestCase.this, a);
                }
            });
            runner.setup(this, a);
        }
    } catch (NoSuchMethodException e) {
    // not a plain JUnit test.
    }
}
Also used : Runner(org.jvnet.hudson.test.recipes.Recipe.Runner) Recipe(org.jvnet.hudson.test.recipes.Recipe) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) FailingHttpStatusCodeException(com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException) BadCredentialsException(org.acegisecurity.BadCredentialsException) UsernameNotFoundException(org.acegisecurity.userdetails.UsernameNotFoundException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) CSSParseException(org.w3c.css.sac.CSSParseException) AbstractArtifactResolutionException(org.apache.maven.artifact.resolver.AbstractArtifactResolutionException) AuthenticationException(org.acegisecurity.AuthenticationException) SAXException(org.xml.sax.SAXException) DataAccessException(org.springframework.dao.DataAccessException) CSSException(org.w3c.css.sac.CSSException) MalformedURLException(java.net.MalformedURLException)

Aggregations

FailingHttpStatusCodeException (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException)1 IOException (java.io.IOException)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 AuthenticationException (org.acegisecurity.AuthenticationException)1 BadCredentialsException (org.acegisecurity.BadCredentialsException)1 UsernameNotFoundException (org.acegisecurity.userdetails.UsernameNotFoundException)1 AbstractArtifactResolutionException (org.apache.maven.artifact.resolver.AbstractArtifactResolutionException)1 Recipe (org.jvnet.hudson.test.recipes.Recipe)1 Runner (org.jvnet.hudson.test.recipes.Recipe.Runner)1 DataAccessException (org.springframework.dao.DataAccessException)1 CSSException (org.w3c.css.sac.CSSException)1 CSSParseException (org.w3c.css.sac.CSSParseException)1 SAXException (org.xml.sax.SAXException)1