org.jvnet.hudson.test
Class HudsonTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jvnet.hudson.test.HudsonTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class HudsonTestCase
extends junit.framework.TestCase

Base class for all Hudson test cases.

Author:
Kohsuke Kawaguchi

Nested Class Summary
 class HudsonTestCase.WebClient
          Extends WebClient and provide convenience methods for accessing Hudson.
 
Field Summary
protected  java.lang.String contextPath
          Where in the Server is Hudson deploed?
protected  TestEnvironment env
           
protected  HudsonHomeLoader homeLoader
           
protected  Hudson hudson
           
protected  int localPort
          TCP/IP port that the server is listening on.
protected  org.mortbay.jetty.Server server
           
protected  java.util.List<LenientRunnable> tearDowns
          Runnables to be invoked at tearDown().
 
Constructor Summary
protected HudsonTestCase()
           
protected HudsonTestCase(java.lang.String name)
           
 
Method Summary
protected  org.mortbay.jetty.security.UserRealm configureUserRealm()
          Configures a security realm for a test.
protected  FreeStyleProject createFreeStyleProject()
           
protected  FreeStyleProject createFreeStyleProject(java.lang.String name)
           
protected  javax.servlet.ServletContext createWebServer()
          Prepares a webapp hosting environment to get ServletContext implementation that we need for testing.
protected  Hudson newHudson()
          Creates a new instance of Hudson.
protected  void recipe()
          Called during the setUp() to give a test case an opportunity to control the test environment in which Hudson is run.
protected  void setUp()
           
protected  void tearDown()
           
 HudsonTestCase with(HudsonHomeLoader homeLoader)
           
 HudsonTestCase withExistingHome(java.io.File source)
           
 HudsonTestCase withNewHome()
           
 HudsonTestCase withPresetData(java.lang.String name)
          Declares that this test case expects to start with one of the preset data sets.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hudson

protected Hudson hudson

env

protected final TestEnvironment env

homeLoader

protected HudsonHomeLoader homeLoader

localPort

protected int localPort
TCP/IP port that the server is listening on.


server

protected org.mortbay.jetty.Server server

contextPath

protected java.lang.String contextPath
Where in the Server is Hudson deploed?


tearDowns

protected java.util.List<LenientRunnable> tearDowns
Runnables to be invoked at tearDown().

Constructor Detail

HudsonTestCase

protected HudsonTestCase(java.lang.String name)

HudsonTestCase

protected HudsonTestCase()
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

tearDown

protected void tearDown()
                 throws java.lang.Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception

newHudson

protected Hudson newHudson()
                    throws java.lang.Exception
Creates a new instance of Hudson. If the derived class wants to create it in a different way, you can override it.

Throws:
java.lang.Exception

createWebServer

protected javax.servlet.ServletContext createWebServer()
                                                throws java.lang.Exception
Prepares a webapp hosting environment to get ServletContext implementation that we need for testing.

Throws:
java.lang.Exception

configureUserRealm

protected org.mortbay.jetty.security.UserRealm configureUserRealm()
Configures a security realm for a test.


createFreeStyleProject

protected FreeStyleProject createFreeStyleProject()
                                           throws java.io.IOException
Throws:
java.io.IOException

createFreeStyleProject

protected FreeStyleProject createFreeStyleProject(java.lang.String name)
                                           throws java.io.IOException
Throws:
java.io.IOException

recipe

protected void recipe()
               throws java.lang.Exception
Called during the setUp() to give a test case an opportunity to control the test environment in which Hudson is run.

From here, call a series of withXXX methods.

Throws:
java.lang.Exception

withNewHome

public HudsonTestCase withNewHome()

withExistingHome

public HudsonTestCase withExistingHome(java.io.File source)

withPresetData

public HudsonTestCase withPresetData(java.lang.String name)
Declares that this test case expects to start with one of the preset data sets. See https://svn.dev.java.net/svn/hudson/trunk/hudson/main/test/src/main/preset-data/ for available datasets and what they mean.


with

public HudsonTestCase with(HudsonHomeLoader homeLoader)


Copyright © 2008. All Rights Reserved.