Class TestUtil
java.lang.Object
org.jboss.resteasy.utils.TestUtil
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addOtherLibrary
(org.jboss.shrinkwrap.api.spec.WebArchive archive, String dependency) Adds additional dependency needed for the deployment tests.protected org.jboss.shrinkwrap.api.spec.WebArchive
addPackageInfo
(org.jboss.shrinkwrap.api.spec.WebArchive war, Class<?> clazz) Add package info to deployment.static void
countViolations
(ResteasyViolationException e, int totalCount, int propertyCount, int classCount, int parameterCount, int returnValueCount) Check count of violations in ResteasyViolationException.static void
countViolations
(ViolationReport e, int propertyCount, int classCount, int parameterCount, int returnValueCount) static org.jboss.shrinkwrap.api.asset.Asset
Creates abeans.xml
file which uses abean-discovery-mode
of "all".static org.jboss.shrinkwrap.api.asset.Asset
createBeansXml
(String beanDiscoverMode) Creates abeans.xml
file which uses abean-discovery-mode
of "annotated".static org.jboss.shrinkwrap.api.asset.Asset
createWebXml
(Class<? extends jakarta.ws.rs.core.Application> application, String mappingPattern, Map<String, String> contextParams) Creates aweb.xml
file.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 URI
generateUri
(URI base, String path) Generate a URI based on the URL passed appending the path if its value is notnull
.static URI
generateUri
(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 String
static String
getJbossHome
(boolean onServer) static String
Returns the host name defined by thewildfly.management.host
system property,node
system property orlocalhost
by default.static int
Returns the management port defined by thewildfly.management.port
or9990
by default.static int
getManagementPort
(int offset) Returns the management port by thewildfly.management.port
or9990
by default plus the offset.static String
getResourcePath
(Class<?> c, String name) Get resource in test scope for some class.static String
getStandaloneDir
(boolean onServer, String containerQualifier) Get the path to the containers base dir for standalone mode (configuration, logs, etc..).static String
getStandaloneDir
(String containerQualifier) Get the path to the containers base dir for standalone mode (configuration, logs, etc..).static ResteasyConstraintViolation
getViolationByMessage
(List<ResteasyConstraintViolation> list, String message) static ResteasyConstraintViolation
getViolationByMessageAndValue
(List<ResteasyConstraintViolation> list, String message, Object value) static ResteasyConstraintViolation
getViolationByPath
(List<ResteasyConstraintViolation> list, String path) static int
getWarningCount
(String findedString, boolean onServer) Get count of lines with specific string in logstatic int
getWarningCount
(String findedString, boolean onServer, String containerQualifier) Get count of lines with specific string in logstatic int
getWarningCount
(String findedString, boolean onServer, String containerQualifier, boolean useRegexp) Get count of lines with specific string or regexp in logstatic boolean
isIbmJdk()
static boolean
static boolean
static boolean
static org.jboss.shrinkwrap.api.spec.WebArchive
prepareArchive
(String deploymentName) Initialize deployment.static org.jboss.shrinkwrap.api.spec.WebArchive
prepareArchiveWithApplication
(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 String
Convert input stream to String.static File
resolveDependency
(String dependency) Get specified single dependency
-
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.host
system property,node
system property orlocalhost
by default.- Returns:
- the management host name
-
getManagementPort
public static int getManagementPort()Returns the management port defined by thewildfly.management.port
or9990
by default.- Returns:
- the management port
-
getManagementPort
public static int getManagementPort(int offset) Returns the management port by thewildfly.management.port
or9990
by 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
-
readServerLogLines
-
readServerLogLines
-
readServerLogLines
-
getWarningCount
Get count of lines with specific string in log -
getWarningCount
-
getWarningCount
-
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) -
resolveDependency
-
addOtherLibrary
public static void addOtherLibrary(org.jboss.shrinkwrap.api.spec.WebArchive archive, String dependency) Adds additional dependency needed for the deployment tests. Specified by parameter in the format 'groupId:artifactId:version'- Parameters:
archive
-dependency
-
-
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.xml
file which uses abean-discovery-mode
of "all".- Returns:
- a
beans.xml
asset
-
createBeansXml
Creates abeans.xml
file which uses abean-discovery-mode
of "annotated".- Returns:
- a
beans.xml
asset
-
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.xml
file.- Parameters:
application
- the application to add a servlet ornull
to use annotation scanningmappingPattern
- the mapping parameter for cases when the application is not annotated with theApplicationPath
or isnull
, ifnull
no servlet mapping is addedcontextParams
- the optional context parameters to add- Returns:
- a
web.xml
file
-