public class HttpTestBase
extends junit.framework.TestCase
Modifier and Type | Class and Description |
---|---|
protected class |
HttpTestBase.TestNode
Class that creates a test node under the given parentPath, and
stores useful values for testing.
|
Constructor and Description |
---|
HttpTestBase() |
Modifier and Type | Method and Description |
---|---|
org.apache.commons.httpclient.HttpMethod |
assertHttpStatus(String urlString,
int expectedStatusCode)
Verify that given URL returns expectedStatusCode
|
org.apache.commons.httpclient.HttpMethod |
assertHttpStatus(String urlString,
int expectedStatusCode,
String assertMessage)
Verify that given URL returns expectedStatusCode
|
void |
assertJavascript(String expectedOutput,
String jsonData,
String code) |
void |
assertJavascript(String expectedOutput,
String jsonData,
String code,
String testInfo)
Evaluate given code using given jsonData as the "data" object
|
org.apache.commons.httpclient.HttpMethod |
assertPostStatus(String url,
int expectedStatusCode,
List<org.apache.commons.httpclient.NameValuePair> postParams,
String assertMessage)
Execute a POST request and check status
|
String |
executeScript(String localFilename)
Upload script, execute with no parameters and return content
|
String |
executeScript(String localFilename,
List<org.apache.commons.httpclient.NameValuePair> params)
Upload script, execute with given parameters (optional) and return content
|
String |
getContent(String url,
String expectedContentType)
retrieve the contents of given URL and assert its content type (default to HTTP GET method)
|
String |
getContent(String url,
String expectedContentType,
List<org.apache.commons.httpclient.NameValuePair> params)
retrieve the contents of given URL and assert its content type (default to HTTP GET method)
|
String |
getContent(String url,
String expectedContentType,
List<org.apache.commons.httpclient.NameValuePair> params,
int expectedStatusCode)
retrieve the contents of given URL and assert its content type (default to HTTP GET method)
|
String |
getContent(String url,
String expectedContentType,
List<org.apache.commons.httpclient.NameValuePair> params,
int expectedStatusCode,
String httpMethod)
retrieve the contents of given URL and assert its content type
|
org.apache.commons.httpclient.Credentials |
getDefaultCredentials()
Generate default credentials used for HTTP requests.
|
static String |
getResponseBodyAsStream(org.apache.commons.httpclient.HttpMethodBase m,
int maxLength)
Return m's response body as a string, optionally limiting the length that we read
|
static String |
removeEndingSlash(String str) |
void |
setReadinessContentType(String extension,
String contentTypePrefix)
Set the extension and content-type prefix to use for GET requests that check Sling readiness
|
protected void |
setUp() |
protected boolean |
slingServerReady()
Return true if able to create and retrieve a node on server
|
protected void |
tearDown() |
String |
uploadTestScript(String scriptPath,
String localFilename,
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.
|
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
public static final String PROPERTY_SKIP_STARTUP_CHECK
public static final String HTTP_URL
public static final String HTTP_BASE_URL
public static final String WEBDAV_BASE_URL
public static final String SERVLET_CONTEXT
public static final String READINESS_MEDIA_TYPE_PROP
public static final String DEFAULT_READINESS_MEDIA_TYPE
public static final String READY_URL_PROP_PREFIX
public static final int MAX_READY_URL_INDEX
public static final String TEST_PATH
public static final String HTTP_METHOD_GET
public static final String HTTP_METHOD_POST
public static final String CONTENT_TYPE_HTML
public static final String CONTENT_TYPE_XML
public static final String CONTENT_TYPE_PLAIN
public static final String CONTENT_TYPE_JSON
public static final String CONTENT_TYPE_JS
public static final String CONTENT_TYPE_CSS
public static final String SLING_RESOURCE_TYPE
public static final String SLING_POST_SERVLET_CREATE_SUFFIX
public static final String DEFAULT_EXT
public static final String EXECUTE_RESOURCE_TYPE
public static final int READY_TIMEOUT_SECONDS
protected SlingIntegrationTestClient testClient
protected org.apache.commons.httpclient.HttpClient httpClient
public static final String CONTENT_TYPE_DONTCARE
protected void setUp() throws Exception
setUp
in class junit.framework.TestCase
Exception
public org.apache.commons.httpclient.Credentials getDefaultCredentials()
protected void tearDown() throws Exception
tearDown
in class junit.framework.TestCase
Exception
protected void waitForSlingStartup() throws Exception
Exception
protected boolean slingServerReady() throws Exception
Exception
public org.apache.commons.httpclient.HttpMethod assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException
IOException
public org.apache.commons.httpclient.HttpMethod assertHttpStatus(String urlString, int expectedStatusCode) throws IOException
IOException
public org.apache.commons.httpclient.HttpMethod assertPostStatus(String url, int expectedStatusCode, List<org.apache.commons.httpclient.NameValuePair> postParams, String assertMessage) throws IOException
IOException
public String getContent(String url, String expectedContentType) throws IOException
IOException
public String getContent(String url, String expectedContentType, List<org.apache.commons.httpclient.NameValuePair> params) throws IOException
IOException
public String getContent(String url, String expectedContentType, List<org.apache.commons.httpclient.NameValuePair> params, int expectedStatusCode) throws IOException
expectedContentType
- use CONTENT_TYPE_DONTCARE if must not be checkedIOException
org.apache.commons.httpclient.HttpException
public String getContent(String url, String expectedContentType, List<org.apache.commons.httpclient.NameValuePair> params, int expectedStatusCode, String httpMethod) throws IOException
expectedContentType
- use CONTENT_TYPE_DONTCARE if must not be checkedhttpMethod
- supports just GET and POST methodsIOException
org.apache.commons.httpclient.HttpException
public String uploadTestScript(String scriptPath, String localFilename, String filenameOnServer) throws IOException
IOException
public String executeScript(String localFilename) throws Exception
Exception
public String executeScript(String localFilename, List<org.apache.commons.httpclient.NameValuePair> params) throws Exception
Exception
public void assertJavascript(String expectedOutput, String jsonData, String code) throws IOException
IOException
public void assertJavascript(String expectedOutput, String jsonData, String code, String testInfo) throws IOException
IOException
public static String getResponseBodyAsStream(org.apache.commons.httpclient.HttpMethodBase m, int maxLength) throws IOException
maxLength
- if 0, no limitIOException
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.