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 class
This exception must be thrown to signify a test failure.protected static enum
the list of properties to be put into a property tableprotected static enum
List of possible requests -
Field Summary
FieldsModifier and TypeFieldDescriptionContext root of target testsprotected String
General file/request URI for both gfiles and testsprotected String
Target webserver hostnameprotected int
Target webserver portprotected boolean
protected boolean
Save state.protected String
protected org.apache.commons.httpclient.HttpState
HttpState that may be used for multiple invocations requiring state.protected WebTestCase
Test case.protected String
Current test nameprotected String
location of _tsHomeprotected boolean
Use saved state.protected static final String
Default request methodprotected static final String
Goldenfile suffixprotected static final String
Goldenfile propertyprotected String
Goldenfile directoryprotected static final String
HTTP 1.0protected static final String
HTTP 1.1static final String
static final String
protected static final String
Request propertyprotected static final String
Request headers propertyprotected static final String
Search string propertystatic final String
protected static final String
TS Webserver host propertyprotected static final String
TS Webserver port propertyprotected static final String
Forward slashprotected static final String
StatusCode propertyprotected static final Hashtable<JAXRSCommonClient.Property,
String> Test propertiesprotected String
Search string case insensitive propertyprotected static final String
TS 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 void
assertContains
(String string, String substring, Object... message) Assert that given substring is a substring of given stringstatic <T> void
assertContains
(T text, T subtext, Object... message) Assert that given subtext.toString() subject is a substring of given textstatic void
assertContainsIgnoreCase
(String string, String substring, Object... message) Assert that given substring is a substring of given string, case insensitivestatic <T> void
assertContainsIgnoreCase
(T text, T subtext, Object... message) Assert that given subtext.toString() subject is a substring of given text, case insensitivestatic <T> void
assertEquals
(T first, T second, Object... message) Asserts that two objects are equal.static <T> void
assertEqualsBool
(boolean first, boolean second, Object... message) static <T> void
assertEqualsInt
(int first, int second, Object... message) static <T> void
assertEqualsLong
(long first, long second, Object... message) static void
assertNotNull
(Object object, Object... message) Asserts that an object is not null.static void
assertNull
(Object object, Object... message) Asserts that an object is null.protected void
protected void
protected static String
buildAccept
(jakarta.ws.rs.core.MediaType type) Create counterpart to @Producesprotected static String
buildContentType
(jakarta.ws.rs.core.MediaType type) Create counterpart to @Consumesprotected static String
buildHeaderMediaType
(String header, jakarta.ws.rs.core.MediaType type) protected String
buildRequest
(JAXRSCommonClient.Request type, String... path) protected String
buildRequest
(String type, String... path) Create request/ / HTTP/1.1. protected String
buildRequest10
(JAXRSCommonClient.Request type, String... path) void
cleanup()
cleanup
is called by the test harness to cleanup after text executionprotected void
protected void
Clears the contents of TEST_PROPSprotected HttpRequest
createHttpRequest
(String requestLine, String host, int port) static String
editWebXmlString
(InputStream inStream) static void
Throws Fault with space separated objects[1],object[2],...,object[n] messageprotected String
protected String
getAbsoluteUrl
(String method) protected String
getLocalInterfaceInfo
(boolean returnAddresses) protected String
protected String[]
protected jakarta.ws.rs.core.Response.Status
get HttpResponse#statusCodeprotected String
static String
getStatusCode
(jakarta.ws.rs.core.Response.Status status) protected void
invoke()
Invokes a test based on the properties stored in TEST_PROPS.protected boolean
isNullOrEmpty
(String val) static void
static void
protected static String
objectsToString
(Object... objects) Use rather this method thanJaxrsUtil.iterableToString(String, Iterable)
since not all wars (for servlet vehicle, api) do contain JaxrsUtilprotected static String
objectsToString
(String delimiter, Object... objects) void
setContextRoot
(String root) protected void
setProperty
(JAXRSCommonClient.Property key, String value) protected void
setProperty
(JAXRSCommonClient.Property key, String... value) protected void
setProperty
(String key, String value) Set TEST_PROPS property value.protected void
setServletName
(String servlet) Sets the name of the servlet to use when building a request for a single servlet API test.void
setTestDir
(String testDir) setTestDir
sets the current test directory.protected void
setTestProperties
(WebTestCase testCase) Sets the appropriate test properties based on the values stored in TEST_PROPSvoid
setup()
setup
is by the test harness to initialize the tests.protected void
setWebTestCaseProperties
(WebTestCase testCase, HttpRequest req) protected HttpRequest
setWebTestCaseRequest
(WebTestCase testCase, HttpRequest req) static String
toString
(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
setTestDir
sets the current test directory.- Parameters:
testDir
- aString
value
-
setContextRoot
-
getContextRoot
-
setup
public void setup()setup
is by the test harness to initialize the tests.- Parameters:
args
- aString[]
valuep
- aProperties
value- Throws:
JAXRSCommonClient.Fault
- if an error occurs
-
cleanup
cleanup
is 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
-