Package ee.jakarta.tck.ws.rs.common
Class JAXRSCommonClient
java.lang.Object
ee.jakarta.tck.ws.rs.common.JAXRSCommonClient
- Direct Known Subclasses:
DefaultExceptionMapperIT,JAXRSClient,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JAXRSClientIT,JaxrsCommonClient,JAXRSDelegateClient,JaxrsParamClient,JAXRSProvidersClientIT,UriInfo40ClientIT
- Author:
- dianne jiao, jan supol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis exception must be thrown to signify a test failure.protected static enumthe list of properties to be put into a property tableprotected static enumList of possible requests -
Field Summary
FieldsModifier and TypeFieldDescriptionContext root of target testsprotected StringGeneral file/request URI for both gfiles and testsprotected StringTarget webserver hostnameprotected intTarget webserver portprotected booleanprotected booleanSave state.protected Stringprotected org.apache.commons.httpclient.HttpStateHttpState that may be used for multiple invocations requiring state.protected WebTestCaseTest case.protected StringCurrent test nameprotected Stringlocation of _tsHomeprotected booleanUse saved state.protected static final StringDefault request methodprotected static final StringGoldenfile suffixprotected static final StringGoldenfile propertyprotected StringGoldenfile directoryprotected static final StringHTTP 1.0protected static final StringHTTP 1.1static final Stringstatic final Stringprotected static final StringRequest propertyprotected static final StringRequest headers propertyprotected static final StringSearch string propertystatic final Stringprotected static final StringTS Webserver host propertyprotected static final StringTS Webserver port propertyprotected static final StringForward slashprotected static final StringStatusCode propertyprotected static final Hashtable<JAXRSCommonClient.Property,String> Test propertiesprotected StringSearch string case insensitive propertyprotected static final StringTS home property -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T extends Throwable>
TassertCause(Throwable parent, Class<T> wrapped, Object... msg) Searches an encapsulated exception cause in parent exceptionstatic voidassertContains(String string, String substring, Object... message) Assert that given substring is a substring of given stringstatic <T> voidassertContains(T text, T subtext, Object... message) Assert that given subtext.toString() subject is a substring of given textstatic voidassertContainsIgnoreCase(String string, String substring, Object... message) Assert that given substring is a substring of given string, case insensitivestatic <T> voidassertContainsIgnoreCase(T text, T subtext, Object... message) Assert that given subtext.toString() subject is a substring of given text, case insensitivestatic <T> voidassertEquals(T first, T second, Object... message) Asserts that two objects are equal.static <T> voidassertEqualsBool(boolean first, boolean second, Object... message) static <T> voidassertEqualsInt(int first, int second, Object... message) static <T> voidassertEqualsLong(long first, long second, Object... message) static voidassertNotNull(Object object, Object... message) Asserts that an object is not null.static voidassertNull(Object object, Object... message) Asserts that an object is null.protected voidprotected voidprotected static StringbuildAccept(jakarta.ws.rs.core.MediaType type) Create counterpart to @Producesprotected static StringbuildContentType(jakarta.ws.rs.core.MediaType type) Create counterpart to @Consumesprotected static StringbuildHeaderMediaType(String header, jakarta.ws.rs.core.MediaType type) protected StringbuildRequest(JAXRSCommonClient.Request type, String... path) protected StringbuildRequest(String type, String... path) Create request/ / HTTP/1.1. protected StringbuildRequest10(JAXRSCommonClient.Request type, String... path) voidcleanup()cleanupis called by the test harness to cleanup after text executionprotected voidprotected voidClears the contents of TEST_PROPSprotected HttpRequestcreateHttpRequest(String requestLine, String host, int port) static StringeditWebXmlString(InputStream inStream) static voidThrows Fault with space separated objects[1],object[2],...,object[n] messageprotected Stringprotected StringgetAbsoluteUrl(String method) protected StringgetLocalInterfaceInfo(boolean returnAddresses) protected Stringprotected String[]protected jakarta.ws.rs.core.Response.Statusget HttpResponse#statusCodeprotected Stringstatic StringgetStatusCode(jakarta.ws.rs.core.Response.Status status) protected voidinvoke()Invokes a test based on the properties stored in TEST_PROPS.protected booleanisNullOrEmpty(String val) static voidstatic voidprotected static StringobjectsToString(Object... objects) Use rather this method thanJaxrsUtil.iterableToString(String, Iterable)since not all wars (for servlet vehicle, api) do contain JaxrsUtilprotected static StringobjectsToString(String delimiter, Object... objects) voidsetContextRoot(String root) protected voidsetProperty(JAXRSCommonClient.Property key, String value) protected voidsetProperty(JAXRSCommonClient.Property key, String... value) protected voidsetProperty(String key, String value) Set TEST_PROPS property value.protected voidsetServletName(String servlet) Sets the name of the servlet to use when building a request for a single servlet API test.voidsetTestDir(String testDir) setTestDirsets the current test directory.protected voidsetTestProperties(WebTestCase testCase) Sets the appropriate test properties based on the values stored in TEST_PROPSvoidsetup()setupis by the test harness to initialize the tests.protected voidsetWebTestCaseProperties(WebTestCase testCase, HttpRequest req) protected HttpRequestsetWebTestCaseRequest(WebTestCase testCase, HttpRequest req) static StringtoString(InputStream inStream)
-
Field Details
-
SERVLETHOSTPROP
TS Webserver host property- See Also:
-
SERVLETPORTPROP
TS Webserver port property- See Also:
-
TSHOME
TS home property- See Also:
-
TEST_PROPS
Test properties -
STATUS_CODE
StatusCode property- See Also:
-
REQUEST
Request property- See Also:
-
REQUEST_HEADERS
Request headers property- See Also:
-
GOLDENFILE
Goldenfile property- See Also:
-
SEARCH_STRING
Search string property- See Also:
-
TESTDIR
Search string case insensitive property -
GOLDENFILEDIR
Goldenfile directory -
GET
Default request method- See Also:
-
HTTP10
HTTP 1.0- See Also:
-
HTTP11
HTTP 1.1- See Also:
-
SL
Forward slash- See Also:
-
GF_SUFFIX
Goldenfile suffix- See Also:
-
_testName
Current test name -
_tsHome
location of _tsHome -
_contextRoot
Context root of target tests -
_generalURI
General file/request URI for both gfiles and tests -
_hostname
Target webserver hostname -
_port
protected int _portTarget webserver port -
_state
protected org.apache.commons.httpclient.HttpState _stateHttpState that may be used for multiple invocations requiring state. -
_testCase
Test case. -
_useSavedState
protected boolean _useSavedStateUse saved state. -
_saveState
protected boolean _saveStateSave state. -
_redirect
protected boolean _redirect -
newline
-
servletAdaptor
-
indent
- See Also:
-
_servlet
-
-
Constructor Details
-
JAXRSCommonClient
public JAXRSCommonClient()
-
-
Method Details
-
setTestDir
setTestDirsets the current test directory.- Parameters:
testDir- aStringvalue
-
setContextRoot
-
getContextRoot
-
setup
public void setup()setupis by the test harness to initialize the tests.- Parameters:
args- aString[]valuep- aPropertiesvalue- Throws:
JAXRSCommonClient.Fault- if an error occurs
-
cleanup
cleanupis called by the test harness to cleanup after text execution- Throws:
JAXRSCommonClient.Fault- if an error occurs
-
invoke
Invokes a test based on the properties stored in TEST_PROPS. Once the test has completed, the properties in TEST_PROPS will be cleared.
- Throws:
JAXRSCommonClient.Fault- If an error occurs during the test run
-
setTestProperties
Sets the appropriate test properties based on the values stored in TEST_PROPS
-
setWebTestCaseRequest
-
setWebTestCaseProperties
-
buildRequest
Create request/ / HTTP/1.1. ContextRoot is defined in every client. - Parameters:
type- PUT, GET, POST, ...path- path defined in a servlet- Returns:
- String representing HTTP request
-
buildRequest
-
buildRequest10
-
buildAccept
Create counterpart to @Produces- Parameters:
type-- Returns:
- Accept:
type.Object.toString()
-
buildContentType
Create counterpart to @Consumes- Parameters:
type-- Returns:
-
buildHeaderMediaType
-
toString
- Throws:
IOException
-
editWebXmlString
- Throws:
IOException
-
getResponseBody
- Returns:
- http response body as string
- Throws:
JAXRSCommonClient.Fault- when an error occur
-
getResponseHeaders
- Returns:
- http response body as string
- Throws:
JAXRSCommonClient.Fault- when an error occur
-
assertResponseHeadersContain
- Parameters:
s- the header to search- Throws:
JAXRSCommonClient.Fault- when header not found
-
assertResponseBodyContain
- Parameters:
s- the entity to search- Throws:
JAXRSCommonClient.Fault- when entity not found
-
getResponseStatusCode
protected jakarta.ws.rs.core.Response.Status getResponseStatusCode()get HttpResponse#statusCode- Returns:
- JAXRS Response.Status equivalent of HttpResponse#statusCode
-
setProperty
Set TEST_PROPS property value. If it already exists, the value is appended -
setProperty
-
setProperty
-
clearProperty
-
assertEquals
Asserts that two objects are equal. When instances of Comparable, such as String, compareTo is used.- Parameters:
first- first objectsecond- second objectmessage- a space separated message[i].toString() compilation for i=<0,message.length)
-
assertEqualsInt
-
assertEqualsLong
-
assertEqualsBool
-
assertNull
Asserts that an object is null.- Parameters:
object- Assert that object is not nullmessage- a space separated message[i].toString() compilation for i=<0,message.length)
-
assertNotNull
Asserts that an object is not null.- Parameters:
object- Assert that object is not nullmessage- a space separated message[i].toString() compilation for i=<0,message.length)
-
fault
Throws Fault with space separated objects[1],object[2],...,object[n] message- Parameters:
objects- objects whose toString() results will be added to Fault message- Throws:
JAXRSCommonClient.Fault- fault with space separated objects.toString values
-
assertContains
Assert that given substring is a substring of given string- Parameters:
string- the string to search substring insubstring- the substring to be searched in a given stringmessage- space separated message values to be thrown
-
assertContainsIgnoreCase
Assert that given substring is a substring of given string, case insensitive- Parameters:
string- the string to search substring insubstring- the substring to be searched in a given stringmessage- space separated message values to be thrown
-
assertContains
Assert that given subtext.toString() subject is a substring of given text- Parameters:
text- the text.toString() object to search subtext.toString() insubtext- the subtext.toString() to be searched in a given text.toString()message- space separated message values to be thrown
-
assertContainsIgnoreCase
Assert that given subtext.toString() subject is a substring of given text, case insensitive- Parameters:
text- the text.toString() object to search subtext.toString() insubtext- the subtext.toString() to be searched in a given text.toString()message- space separated message values to be thrown
-
assertCause
protected static <T extends Throwable> T assertCause(Throwable parent, Class<T> wrapped, Object... msg) Searches an encapsulated exception cause in parent exception -
getStatusCode
-
logMsg
-
logTrace
-
objectsToString
Use rather this method thanJaxrsUtil.iterableToString(String, Iterable)since not all wars (for servlet vehicle, api) do contain JaxrsUtil- Parameters:
objects-- Returns:
- objects in a single string , each object separated by " "
-
objectsToString
- Since:
- 2.0.1
-
clearTestProperties
protected void clearTestProperties()Clears the contents of TEST_PROPS -
isNullOrEmpty
-
createHttpRequest
-
setServletName
Sets the name of the servlet to use when building a request for a single servlet API test.- Parameters:
servlet- - the name of the servlet
-
getServletName
-
getLocalInterfaceInfo
-
getAbsoluteUrl
-
getAbsoluteUrl
-