Skip to content

Commit

Permalink
WINDUPRULE-898 EAP8 RESTEasy rules (#838) (#871)
Browse files Browse the repository at this point in the history
* [WINDUPRULE-903] Migration from Keycloak to Native EAP OpenID Connect Support

* [WINDUPRULE-903] Fix test

* WINDUPRULE-898 EAP8 RESTEasy rules

* WINDUPRULE-898 EAP 8 RESTEasy add mention of resteasy.allowGzip property to interceptors rule

* Update rules/rules-reviewed/eap8/eap6/eap8-resteasy.windup.xml

Co-authored-by: Mark Brophy <36955467+m-brophy@users.noreply.github.com>

* WINDUPRULE-898 eap8 resteasy PR feedback corrections

---------

Co-authored-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
Co-authored-by: Mark Brophy <36955467+m-brophy@users.noreply.github.com>
(cherry picked from commit 14c088c)

Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and PhilipCattanach committed Feb 23, 2023
1 parent cffcfb2 commit 001fd3d
Show file tree
Hide file tree
Showing 12 changed files with 790 additions and 0 deletions.
172 changes: 172 additions & 0 deletions rules/rules-reviewed/eap8/eap6/eap8-resteasy.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="eap8-resteasy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset provides analysis of Resteasy for migration from version 3.15 to 4.x
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" />
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" />
</dependencies>
<sourceTechnology id="eap" versionRange="[6,7]" />
<targetTechnology id="eap" versionRange="[8,)" />
<tag>eap8</tag>
</metadata>
<rules>
<rule id="eap8-resteasy-00001">
<when>
<or>
<filecontent pattern="org.jboss.resteasy.resteasy-jettison-provider" filename="jboss-deployment-structure.xml" />
<filecontent pattern="org.jboss.resteasy.resteasy-jettison-provider" filename="MANIFEST.MF" />
</or>
</when>
<perform>
<hint title="The org.jboss.resteasy.resteasy-jettison-provider module has been removed" effort="13" category-id="mandatory">
<message>The `org.jboss.resteasy.resteasy-jettison-provider` module has been removed. There is no documented solution for this issue.</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00002">
<when>
<project>
<artifact groupId="org.jboss.resteasy" artifactId="resteasy-jettison-provider"/>
</project>
</when>
<perform>
<hint title="The org.jboss.resteasy resteasy-jettison-provider artifact has been removed" effort="13" category-id="mandatory">
<message>The `org.jboss.resteasy:resteasy-jettison-provider` artifact has been removed. There is no documented solution for this issue.</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00003">
<when>
<or>
<filecontent pattern="org.jboss.resteasy.resteasy-yaml-provider" filename="jboss-deployment-structure.xml" />
<filecontent pattern="org.jboss.resteasy.resteasy-yaml-provider" filename="MANIFEST.MF" />
</or>
</when>
<perform>
<hint title="The org.jboss.resteasy.resteasy-yaml-provider module has been removed" effort="13" category-id="mandatory">
<message>The `org.jboss.resteasy.resteasy-yaml-provider` module has been removed. There is no documented solution for this issue.</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00004">
<when>
<project>
<artifact groupId="org.jboss.resteasy" artifactId="resteasy-yaml-provider"/>
</project>
</when>
<perform>
<hint title="The org.jboss.resteasy resteasy-yaml-provider artifact has been removed" effort="13" category-id="mandatory">
<message>The `org.jboss.resteasy:resteasy-yaml-provider` artifact has been removed. There is no documented solution for this issue.</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00005">
<when>
<project>
<artifact groupId="org.jboss.resteasy" artifactId="resteasy-spring"/>
</project>
</when>
<perform>
<hint title="The org.jboss.resteasy resteasy-spring artifact has been renamed" effort="1" category-id="mandatory">
<message>The `org.jboss.resteasy:resteasy-spring` artifact has been renamed to `org.jboss.resteasy.spring:resteasy-spring`</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00006">
<when>
<javaclass references="org.jboss.resteasy.spi.StringConverter">
<location>IMPORT</location>
<location>IMPLEMENTS_TYPE</location>
</javaclass>
</when>
<perform>
<hint title="org.jboss.resteasy.spi.StringConverter has been removed" effort="1" category-id="mandatory">
<message>`org.jboss.resteasy.spi.StringConverter` has been removed. Replace with `jakarta.ws.rs.ext.ParamConverter`</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00007">
<when>
<javaclass references="org.jboss.resteasy.spi.AsynchronousResponse">
<location>IMPORT</location>
<location>IMPLEMENTS_TYPE</location>
<location>METHOD_PARAMETER</location>
</javaclass>
</when>
<perform>
<hint title="org.jboss.resteasy.spi.AsynchronousResponse has been removed" effort="1" category-id="mandatory">
<message>`org.jboss.resteasy.spi.AsynchronousResponse` has been removed. Replace with `jakarta.ws.rs.container.AsyncResponse`</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00008">
<when>
<javaclass references="org.jboss.resteasy.annotations.Suspend">
<location>IMPORT</location>
<location>ANNOTATION</location>
</javaclass>
</when>
<perform>
<hint title="org.jboss.resteasy.annotations.Suspend has been removed" effort="1" category-id="mandatory">
<message>`org.jboss.resteasy.annotations.Suspend` has been removed. Replace with `jakarta.ws.rs.container.Suspended`</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00009">
<when>
<javaclass references="org.jboss.resteasy.core.ResourceInvoker">
</javaclass>
</when>
<perform>
<hint title="org.jboss.resteasy.core.ResourceInvoker interface has been removed" effort="1" category-id="mandatory">
<message>`org.jboss.resteasy.core.ResourceInvoker` interface have been removed. Replace with `org.jboss.resteasy.spi.ResourceInvoker`.</message>
<link title="org.jboss.resteasy.spi.ResourceInvoker"
href="https://docs.jboss.org/resteasy/docs/4.0.0.Final/javadocs/org/jboss/resteasy/spi/ResourceInvoker.html"/>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00010">
<when>
<javaclass references="org.jboss.resteasy.plugins.interceptors.encoding.{*}">
</javaclass>
</when>
<perform>
<hint title="org.jboss.resteasy.plugins.interceptors.encoding classes has been removed" effort="1" category-id="mandatory">
<message>`org.jboss.resteasy.plugins.interceptors.encoding` classes have been removed. Replace with the equivalent `org.jboss.resteasy.plugins.interceptors` classes. Or remove the manual registration of the interceptors and set the system property `resteasy.allowGzip=true`.</message>
<link title="org.jboss.resteasy.plugins.interceptors"
href="https://docs.jboss.org/resteasy/docs/4.0.0.Final/javadocs/org/jboss/resteasy/plugins/interceptors/package-frame.html"/>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-resteasy-00011">
<when>
<or>
<filecontent pattern="org.jboss.resteasy.resteasy-jaxrs" filename="jboss-deployment-structure.xml" />
<filecontent pattern="org.jboss.resteasy.resteasy-jaxrs" filename="MANIFEST.MF" />
</or>
</when>
<perform>
<hint title="The org.jboss.resteasy.resteasy-jaxrs module has been deprecated" effort="1" category-id="optional">
<message>The `org.jboss.resteasy.resteasy-jaxrs` module has been deprecated and split into 4 new modules, specifically `org.jboss.resteasy.resteasy-client`, `org.jboss.resteasy.resteasy-client-spi`,`org.jboss.resteasy.resteasy-core` and `org.jboss.resteasy.resteasy-core-spi`
</message>
<tag>eap8</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>
104 changes: 104 additions & 0 deletions rules/rules-reviewed/eap8/eap6/tests/data/resteasy/JaxRsClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.plugins.interceptors.encoding.*;

/**
* JUnit4 Test class which makes a request to the RESTful helloworld-rs web service.
*
* @author bmincey (Blaine Mincey)
*/
public class JaxRsClient {
/**
* Request URLs pulled from system properties in pom.xml
*/
private static String XML_URL;
private static String JSON_URL;

/**
* Property names used to pull values from system properties in pom.xml
*/
private static final String XML_PROPERTY = "xmlUrl";
private static final String JSON_PROPERTY = "jsonUrl";

/**
* Responses of the RESTful web service
*/
private static final String XML_RESPONSE = "<xml><result>Hello World!</result></xml>";
private static final String JSON_RESPONSE = "{\"result\":\"Hello World!\"}";

/**
* Method executes BEFORE the test method. Values are read from system properties that can be modified in the pom.xml.
*/

public static void main(String[] args) {
JaxRsClient.XML_URL = System.getProperty(JaxRsClient.XML_PROPERTY);
JaxRsClient.JSON_URL = System.getProperty(JaxRsClient.JSON_PROPERTY);
new JaxRsClient().test();
}

/**
* Test method which executes the runRequest method that calls the RESTful helloworld-rs web service.
*/
void test() {
String response = runRequest(JaxRsClient.XML_URL, MediaType.APPLICATION_XML_TYPE);

if (!JaxRsClient.XML_RESPONSE.equals(response)) {
throw new RuntimeException("Response is wrong:\nXML Response:" + response + "\nshould be: " + XML_RESPONSE);
}
response = runRequest(JaxRsClient.JSON_URL, MediaType.APPLICATION_JSON_TYPE);

if (!JaxRsClient.JSON_RESPONSE.equals(response)) {
throw new RuntimeException("Response is wrong:\nJSON Response:" + response + "\nshould be: " + JSON_RESPONSE);
}

}

/**
* The purpose of this method is to run the external REST request.
*
* @param url The url of the RESTful service
* @param mediaType The mediatype of the RESTful service
*/
private String runRequest(String url, MediaType mediaType) {
String result = null;

System.out.println("===============================================");
System.out.println("URL: " + url);
System.out.println("MediaType: " + mediaType.toString());


// Using the RESTEasy libraries, initiate a client request
ResteasyClient client = new ResteasyClientBuilder().build();
final ResteasyClient clientGZIP = new ResteasyClientBuilder().register(new org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor(256)).build();


// Set url as target
ResteasyWebTarget target = client.target(url);

// Be sure to set the mediatype of the request
target.request(mediaType);

// Request has been made, now let's get the response
Response response = target.request().get();
result = response.readEntity(String.class);
response.close();

// Check the HTTP status of the request
// HTTP 200 indicates the request is OK
if (response.getStatus() != 200) {
throw new RuntimeException("Failed request with HTTP status: " + response.getStatus());
}

// We have a good response, let's now read it
System.out.println("\n*** Response from Server ***\n");
System.out.println(result);
System.out.println("\n===============================================");

return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0
Dependencies: org.jboss.resteasy.resteasy-jaxrs,org.jboss.resteasy.resteasy-jettison-provider,org.jboss.resteasy.resteasy-yaml-provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import org.jboss.resteasy.annotations.Suspend;
import org.jboss.resteasy.core.ResourceInvoker;
import org.jboss.resteasy.core.ResourceLocatorInvoker;
import org.jboss.resteasy.core.ResourceMethodInvoker;
import org.jboss.resteasy.spi.AsynchronousResponse;

@Path("/")
public class SimpleResource
{

@GET
@Path("basic")
@Produces("text/plain")
public void getBasic(final @Suspend(10000) AsynchronousResponse response) throws Exception
{
Thread t = new Thread()
{
@Override
public void run()
{
try
{
Response jaxrs = Response.ok("basic").type(MediaType.TEXT_PLAIN).build();
response.setResponse(jaxrs);
}
catch (Exception e)
{
e.printStackTrace();
}
}
};
t.start();
}
Loading

0 comments on commit 001fd3d

Please sign in to comment.