|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase org.apache.sling.commons.testing.integration.HttpTestBase
public class HttpTestBase
Base class for HTTP-based Sling Launchpad integration tests
Nested Class Summary | |
---|---|
protected class |
HttpTestBase.TestNode
Class that creates a test node under the given parentPath, and stores useful values for testing. |
Field Summary | |
---|---|
static java.lang.String |
CONTENT_TYPE_CSS
|
static java.lang.String |
CONTENT_TYPE_DONTCARE
Means "don't care about Content-Type" in getContent(...) methods |
static java.lang.String |
CONTENT_TYPE_HTML
|
static java.lang.String |
CONTENT_TYPE_JS
|
static java.lang.String |
CONTENT_TYPE_JSON
|
static java.lang.String |
CONTENT_TYPE_PLAIN
|
static java.lang.String |
CONTENT_TYPE_XML
|
static java.lang.String |
DEFAULT_EXT
|
static java.lang.String |
HTTP_BASE_URL
|
protected org.apache.commons.httpclient.HttpClient |
httpClient
|
static java.lang.String |
SLING_POST_SERVLET_CREATE_SUFFIX
|
static java.lang.String |
SLING_RESOURCE_TYPE
|
static java.lang.String |
TEST_PATH
base path for test files |
protected SlingIntegrationTestClient |
testClient
|
protected java.util.List<java.lang.String> |
urlsToDelete
URLs stored here are deleted in tearDown |
static java.lang.String |
WEBDAV_BASE_URL
|
Constructor Summary | |
---|---|
HttpTestBase()
|
Method Summary | |
---|---|
protected void |
assertHttpStatus(java.lang.String urlString,
int expectedStatusCode)
Verify that given URL returns expectedStatusCode |
protected void |
assertHttpStatus(java.lang.String urlString,
int expectedStatusCode,
java.lang.String assertMessage)
Verify that given URL returns expectedStatusCode |
protected void |
assertJavascript(java.lang.String expectedOutput,
java.lang.String jsonData,
java.lang.String code)
|
protected void |
assertJavascript(java.lang.String expectedOutput,
java.lang.String jsonData,
java.lang.String code,
java.lang.String testInfo)
Evaluate given code using given jsonData as the "data" object |
protected void |
assertPostStatus(java.lang.String url,
int expectedStatusCode,
java.util.List<org.apache.commons.httpclient.NameValuePair> postParams,
java.lang.String assertMessage)
Execute a POST request and check status |
protected java.lang.String |
getContent(java.lang.String url,
java.lang.String expectedContentType)
retrieve the contents of given URL and assert its content type |
protected java.lang.String |
getContent(java.lang.String url,
java.lang.String expectedContentType,
java.util.List<org.apache.commons.httpclient.NameValuePair> params)
|
protected java.lang.String |
getContent(java.lang.String url,
java.lang.String expectedContentType,
java.util.List<org.apache.commons.httpclient.NameValuePair> params,
int expectedStatusCode)
retrieve the contents of given URL and assert its content type |
protected static java.lang.String |
removeEndingSlash(java.lang.String str)
|
protected void |
setUp()
|
protected boolean |
slingServerReady()
Return true if able to create and retrieve a node on server |
protected void |
tearDown()
|
protected java.lang.String |
uploadTestScript(java.lang.String scriptPath,
java.lang.String localFilename,
java.lang.String filenameOnServer)
upload rendering test script, and return its URL for future deletion |
protected void |
waitForSlingStartup()
On the server side, initialization of Sling bundles is done asynchronously once the webapp is started. |
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, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String HTTP_BASE_URL
public static final java.lang.String WEBDAV_BASE_URL
public static final java.lang.String TEST_PATH
public static final java.lang.String CONTENT_TYPE_HTML
public static final java.lang.String CONTENT_TYPE_XML
public static final java.lang.String CONTENT_TYPE_PLAIN
public static final java.lang.String CONTENT_TYPE_JSON
public static final java.lang.String CONTENT_TYPE_JS
public static final java.lang.String CONTENT_TYPE_CSS
public static final java.lang.String SLING_RESOURCE_TYPE
public static final java.lang.String SLING_POST_SERVLET_CREATE_SUFFIX
public static final java.lang.String DEFAULT_EXT
protected SlingIntegrationTestClient testClient
protected org.apache.commons.httpclient.HttpClient httpClient
public static final java.lang.String CONTENT_TYPE_DONTCARE
protected final java.util.List<java.lang.String> urlsToDelete
Constructor Detail |
---|
public HttpTestBase()
Method Detail |
---|
protected static java.lang.String removeEndingSlash(java.lang.String str)
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void tearDown() throws java.lang.Exception
tearDown
in class junit.framework.TestCase
java.lang.Exception
protected void waitForSlingStartup() throws java.lang.Exception
java.lang.Exception
protected boolean slingServerReady() throws java.lang.Exception
java.lang.Exception
protected void assertHttpStatus(java.lang.String urlString, int expectedStatusCode, java.lang.String assertMessage) throws java.io.IOException
java.io.IOException
protected void assertHttpStatus(java.lang.String urlString, int expectedStatusCode) throws java.io.IOException
java.io.IOException
protected void assertPostStatus(java.lang.String url, int expectedStatusCode, java.util.List<org.apache.commons.httpclient.NameValuePair> postParams, java.lang.String assertMessage) throws java.io.IOException
java.io.IOException
protected java.lang.String getContent(java.lang.String url, java.lang.String expectedContentType) throws java.io.IOException
java.io.IOException
protected java.lang.String getContent(java.lang.String url, java.lang.String expectedContentType, java.util.List<org.apache.commons.httpclient.NameValuePair> params) throws java.io.IOException
java.io.IOException
protected java.lang.String getContent(java.lang.String url, java.lang.String expectedContentType, java.util.List<org.apache.commons.httpclient.NameValuePair> params, int expectedStatusCode) throws java.io.IOException
expectedContentType
- use CONTENT_TYPE_DONTCARE if must not be checked
java.io.IOException
org.apache.commons.httpclient.HttpException
protected java.lang.String uploadTestScript(java.lang.String scriptPath, java.lang.String localFilename, java.lang.String filenameOnServer) throws java.io.IOException
java.io.IOException
protected void assertJavascript(java.lang.String expectedOutput, java.lang.String jsonData, java.lang.String code) throws java.io.IOException
java.io.IOException
protected void assertJavascript(java.lang.String expectedOutput, java.lang.String jsonData, java.lang.String code, java.lang.String testInfo) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |