Package org.jboss.resteasy.utils
Class TestUtil
java.lang.Object
org.jboss.resteasy.utils.TestUtil
Base util class for RESTEasy testing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.jboss.shrinkwrap.api.spec.WebArchiveaddPackageInfo(org.jboss.shrinkwrap.api.spec.WebArchive war, Class<?> clazz) Add package info to deployment.static voidcountViolations(ResteasyViolationException e, int totalCount, int propertyCount, int classCount, int parameterCount, int returnValueCount) Check count of violations in ResteasyViolationException.static voidcountViolations(ViolationReport e, int propertyCount, int classCount, int parameterCount, int returnValueCount) static org.jboss.shrinkwrap.api.asset.AssetCreates abeans.xmlfile which uses abean-discovery-modeof "all".static org.jboss.shrinkwrap.api.asset.AssetcreateBeansXml(String beanDiscoverMode) Creates abeans.xmlfile which uses abean-discovery-modeof "annotated".static org.jboss.shrinkwrap.api.asset.AssetcreateWebXml(Class<? extends jakarta.ws.rs.core.Application> application, String mappingPattern, Map<String, String> contextParams) Creates aweb.xmlfile.static org.jboss.shrinkwrap.api.Archive<?> finishContainerPrepare(org.jboss.shrinkwrap.api.spec.WebArchive war, Map<String, String> contextParams, Class<?>... resources) Finish preparing war deployment and deploy it.static org.jboss.shrinkwrap.api.Archive<?> finishContainerPrepare(org.jboss.shrinkwrap.api.spec.WebArchive war, Map<String, String> contextParams, List<Class<?>> singletons, Class<?>... resources) Finish preparing war deployment and deploy it.static URIgenerateUri(URI base, String path) Generate a URI based on the URL passed appending the path if its value is notnull.static URIgenerateUri(URL base, String path) Generate a URI based on the URL passed appending the path if its value is notnull.getErrorMessageForKnownIssue(String jira, String message) getErrorMessageForKnownIssue(String jira, String message, Throwable throwable) getErrorMessageForKnownIssue(String jira, Throwable throwable) static Stringstatic StringgetJbossHome(boolean onServer) static StringReturns the host name defined by thewildfly.management.hostsystem property,nodesystem property orlocalhostby default.static intReturns the management port defined by thewildfly.management.portor9990by default.static intgetManagementPort(int offset) Returns the management port by thewildfly.management.portor9990by default plus the offset.static StringgetResourcePath(Class<?> c, String name) Get resource in test scope for some class.static StringgetStandaloneDir(boolean onServer, String containerQualifier) Get the path to the containers base dir for standalone mode (configuration, logs, etc..).static StringgetStandaloneDir(String containerQualifier) Get the path to the containers base dir for standalone mode (configuration, logs, etc..).static ResteasyConstraintViolationgetViolationByMessage(List<ResteasyConstraintViolation> list, String message) static ResteasyConstraintViolationgetViolationByMessageAndValue(List<ResteasyConstraintViolation> list, String message, Object value) static ResteasyConstraintViolationgetViolationByPath(List<ResteasyConstraintViolation> list, String path) static intgetWarningCount(String findedString, boolean onServer) Get count of lines with specific string in logstatic intgetWarningCount(String findedString, boolean onServer, String containerQualifier) Get count of lines with specific string in logstatic intgetWarningCount(String findedString, boolean onServer, String containerQualifier, boolean useRegexp) Get count of lines with specific string or regexp in logstatic booleanisIbmJdk()static booleanstatic booleanstatic booleanstatic org.jboss.shrinkwrap.api.spec.WebArchiveprepareArchive(String deploymentName) Initialize deployment.static org.jboss.shrinkwrap.api.spec.WebArchiveprepareArchiveWithApplication(String deploymentName, Class<? extends jakarta.ws.rs.core.Application> clazz) Read server log file from standalone/log/server.logreadServerLogLines(boolean onServer) readServerLogLines(boolean onServer, String containerQualifier) static StringConvert input stream to String.
-
Field Details
-
logger
protected static final org.jboss.logging.Logger logger
-
-
Constructor Details
-
TestUtil
public TestUtil()
-
-
Method Details
-
prepareArchive
Initialize deployment.- Returns:
- Deployment.
-
prepareArchiveWithApplication
-
finishContainerPrepare
public static org.jboss.shrinkwrap.api.Archive<?> finishContainerPrepare(org.jboss.shrinkwrap.api.spec.WebArchive war, Map<String, String> contextParams, Class<?>... resources) Finish preparing war deployment and deploy it. Add classes in @resources to deployment. Also all sub-classes of classes in @resources are added to deployment. But only classes in @resources (not sub-classes of classes in @resources) can be used as resources (getClasses function of TestApplication class return only classes in @resources).- Parameters:
resources- classes used in deployment as resources
-
finishContainerPrepare
public static org.jboss.shrinkwrap.api.Archive<?> finishContainerPrepare(org.jboss.shrinkwrap.api.spec.WebArchive war, Map<String, String> contextParams, List<Class<?>> singletons, Class<?>... resources) Finish preparing war deployment and deploy it. Add classes in @resources to deployment. Also all sub-classes of classes in @resources are added to deployment. But only classes in @resources (not sub-classes of classes in @resources) can be used as resources (getClasses function of TestApplication class return only classes in @resources).- Parameters:
singletons- classes used in deployment as singletonsresources- classes used in deployment as resources
-
getManagementHost
Returns the host name defined by thewildfly.management.hostsystem property,nodesystem property orlocalhostby default.- Returns:
- the management host name
-
getManagementPort
public static int getManagementPort()Returns the management port defined by thewildfly.management.portor9990by default.- Returns:
- the management port
-
getManagementPort
public static int getManagementPort(int offset) Returns the management port by thewildfly.management.portor9990by default plus the offset.- Parameters:
offset- the offset for the default port- Returns:
- the offset management port
-
addPackageInfo
protected org.jboss.shrinkwrap.api.spec.WebArchive addPackageInfo(org.jboss.shrinkwrap.api.spec.WebArchive war, Class<?> clazz) Add package info to deployment.- Parameters:
clazz- Package info is for package of this class.
-
readString
Convert input stream to String.- Parameters:
in- Input stream- Returns:
- Converted string
- Throws:
IOException
-
getErrorMessageForKnownIssue
-
getErrorMessageForKnownIssue
-
getErrorMessageForKnownIssue
-
getErrorMessageForKnownIssue
-
getJbossHome
-
getJbossHome
-
getStandaloneDir
Get the path to the containers base dir for standalone mode (configuration, logs, etc..). When arquillian.xml contains more containers that could be started simultaneously the parameter containerQualifier is used to determine which base dir to get.- Parameters:
containerQualifier- container qualifier or null if the arquillian.xml contains max 1 container available to be running at time- Returns:
- absolute path to base dir
-
getStandaloneDir
Get the path to the containers base dir for standalone mode (configuration, logs, etc..). When arquillian.xml contains more containers that could be started simultaneously the parameter containerQualifier is used to determine which base dir to get.- Parameters:
onServer- whether the check is made from client side (the path is constructed) or from deployment (the path is read from actual runtime value)containerQualifier- container qualifier or null if the arquillian.xml contains max 1 container available to be running at time; this has no effect when onServer is true- Returns:
- absolute path to base dir
-
isOpenJDK
public static boolean isOpenJDK() -
isOracleJDK
public static boolean isOracleJDK() -
isIbmJdk
public static boolean isIbmJdk() -
getResourcePath
Get resource in test scope for some class. Example: class org.test.MyTest and name "my_resource.txt" returns "src/test/resource/org/test/my_resource.txt" -
readServerLogLines
Read server log file from standalone/log/server.log -
readServerLogLines
-
readServerLogLines
-
getWarningCount
Get count of lines with specific string in log -
getWarningCount
Get count of lines with specific string in log -
getWarningCount
public static int getWarningCount(String findedString, boolean onServer, String containerQualifier, boolean useRegexp) Get count of lines with specific string or regexp in log -
countViolations
public static void countViolations(ResteasyViolationException e, int totalCount, int propertyCount, int classCount, int parameterCount, int returnValueCount) Check count of violations in ResteasyViolationException. -
countViolations
public static void countViolations(ViolationReport e, int propertyCount, int classCount, int parameterCount, int returnValueCount) -
getViolationByMessage
public static ResteasyConstraintViolation getViolationByMessage(List<ResteasyConstraintViolation> list, String message) -
getViolationByMessageAndValue
public static ResteasyConstraintViolation getViolationByMessageAndValue(List<ResteasyConstraintViolation> list, String message, Object value) -
getViolationByPath
public static ResteasyConstraintViolation getViolationByPath(List<ResteasyConstraintViolation> list, String path) -
isWindows
public static boolean isWindows() -
generateUri
Generate a URI based on the URL passed appending the path if its value is notnull.- Parameters:
base- the base URLpath- the path to append- Returns:
- the newly create URI
- Throws:
URISyntaxException- If the given string violates RFC 2396, as augmented by the above deviations- See Also:
-
generateUri
Generate a URI based on the URL passed appending the path if its value is notnull.- Parameters:
base- the base URLpath- the path to append- Returns:
- the newly create URI
- Throws:
URISyntaxException- If the given string violates RFC 2396, as augmented by the above deviations- See Also:
-
createBeansXml
public static org.jboss.shrinkwrap.api.asset.Asset createBeansXml()Creates abeans.xmlfile which uses abean-discovery-modeof "all".- Returns:
- a
beans.xmlasset
-
createBeansXml
Creates abeans.xmlfile which uses abean-discovery-modeof "annotated".- Returns:
- a
beans.xmlasset
-
createWebXml
public static org.jboss.shrinkwrap.api.asset.Asset createWebXml(Class<? extends jakarta.ws.rs.core.Application> application, String mappingPattern, Map<String, String> contextParams) Creates aweb.xmlfile.- Parameters:
application- the application to add a servlet ornullto use annotation scanningmappingPattern- the mapping parameter for cases when the application is not annotated with theApplicationPathor isnull, ifnullno servlet mapping is addedcontextParams- the optional context parameters to add- Returns:
- a
web.xmlfile
-