Skip to content

Commit

Permalink
Merge pull request #2870 from marekkopecky/main-RESTEASY-2837
Browse files Browse the repository at this point in the history
Backport #2691 to main branch
  • Loading branch information
jamezp committed Jul 23, 2021
2 parents 1498585 + 7091e90 commit f1b9c5a
Show file tree
Hide file tree
Showing 18 changed files with 602 additions and 513 deletions.
45 changes: 38 additions & 7 deletions testsuite/integration-tests/pom.xml
Expand Up @@ -123,6 +123,44 @@
<jboss.home>${project.build.directory}/test-server/wildfly-${server.version}</jboss.home>
</properties>
</profile>
<!--
By default, ${version.resteasy.testsuite} version for RESTEasy restclient is used.
But use.mp.from.project.profile allows to use ${project.version} version for RESTEasy restclient.
This is useful for test runs where we test resteasy version without RESTEasy restclient available.
In this case, tests with RESTEasy restclient are used for compatibility testing only.
-->
<profile>
<id>not.use.mp.from.project.profile</id>
<activation>
<property>
<name>!ts.use.mp.from.project</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client-microprofile</artifactId>
<version>${version.resteasy.testsuite}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>use.mp.from.project.profile</id>
<activation>
<property>
<name>ts.use.mp.from.project</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client-microprofile</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>

<dependencies>
Expand Down Expand Up @@ -183,13 +221,6 @@
<artifactId>smallrye-config</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client-microprofile</artifactId>
<version>${version.resteasy.testsuite}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-validator-provider</artifactId>
Expand Down
Expand Up @@ -45,7 +45,7 @@ private String generateURL(String path) {
return PortProviderUtil.generateURL(path, AsynchronousCdiTest.class.getSimpleName());
}

@Deployment
@Deployment(testable = false)
public static Archive<?> createTestArchive() {
WebArchive war = TestUtil.prepareArchive(AsynchronousCdiTest.class.getSimpleName());
war.addClasses(UtilityProducer.class)
Expand Down
Expand Up @@ -110,7 +110,7 @@ public Type getOwnerType() {
private static int invocationCounter;

@SuppressWarnings(value = "unchecked")
@Deployment
@Deployment(testable = false)
public static Archive<?> createTestArchive() throws Exception {
initQueue();
WebArchive war = TestUtil.prepareArchive(InjectionTest.class.getSimpleName());
Expand Down
Expand Up @@ -66,7 +66,7 @@ public class MDBInjectionTest extends AbstractInjectionTestBase {
static Client client;

@SuppressWarnings(value = "unchecked")
@Deployment
@Deployment(testable = false)
public static Archive<?> createTestArchive() throws Exception {
initQueue();
WebArchive war = TestUtil.prepareArchive(MDBInjectionTest.class.getSimpleName());
Expand Down
Expand Up @@ -34,7 +34,7 @@
public class TimerInterceptorTest {
protected static final Logger log = LogManager.getLogger(TimerInterceptorTest.class.getName());

@Deployment
@Deployment(testable = false)
public static Archive<?> createTestArchive() {
WebArchive war = TestUtil.prepareArchive(TimerInterceptorTest.class.getSimpleName())
.addClasses(UtilityProducer.class, PortProviderUtil.class)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -10,7 +10,6 @@
import org.jboss.resteasy.client.exception.WebApplicationExceptionWrapper;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
import org.jboss.resteasy.test.client.exception.ClientWebApplicationExceptionMicroProfileProxyTest;
import org.jboss.resteasy.test.client.exception.ClientWebApplicationExceptionTest;
import org.jboss.resteasy.utils.PortProviderUtil;
Expand All @@ -19,27 +18,21 @@
@Path("test")
public class ClientWebApplicationExceptionMicroProfileProxyResource {

private static ClientWebApplicationExceptionProxyResourceInterface proxy;
private static ClientWebApplicationExceptionProxyResourceInterface oldBehaviorProxy;
private static ClientWebApplicationExceptionProxyResourceInterface newBehaviorProxy;

static {
ResteasyClient client = (ResteasyClient) ResteasyClientBuilder.newClient();
proxy = client.target(generateURL("/app/test/")).proxy(ClientWebApplicationExceptionProxyResourceInterface.class);
oldBehaviorProxy = client.target(PortProviderUtil.generateURL("/app/test/", ClientWebApplicationExceptionMicroProfileProxyTest.oldBehaviorDeploymentName))
.proxy(ClientWebApplicationExceptionProxyResourceInterface.class);
newBehaviorProxy = client.target(PortProviderUtil.generateURL("/app/test/", ClientWebApplicationExceptionMicroProfileProxyTest.newBehaviorDeploymentName))
.proxy(ClientWebApplicationExceptionProxyResourceInterface.class);
}

private static String generateURL(String path) {
return PortProviderUtil.generateURL(path, ClientWebApplicationExceptionMicroProfileProxyTest.class.getSimpleName());
}

/**
* Sets the System property ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR
* @param value value property is set to
*/
@GET
@Path("behavior/{value}")
public void setBehavior(@PathParam("value") String value) {
System.setProperty(ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR, value);
}

/**
* Throws an instance of WebApplicationException from oldExceptions table. The Response returned by
* WebApplicationException.getResponse() will be used by the container to create an HTTP response.
Expand Down Expand Up @@ -68,30 +61,58 @@ public String newException(@PathParam("i") int i) throws Exception {

/**
* Uses a proxy to call oldException() to get an HTTP response derived from a WebApplicationException.
* Based on that response, the proxy will throw either a WebApplicationException or WebApplicationExceptionWrapper,
* depending on the value of ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR.
* The proxy will throw a WebApplicationException because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is true.
*
* @param i determines element of oldExceptions to be thrown by oldException()
* @throws Exception
*/
@GET
@Path("nocatch/old/{i}")
public String noCatchOld(@PathParam("i") int i) throws Exception {
return proxy.oldException(i);
@Path("nocatch/old/old/{i}")
public String noCatchOldOld(@PathParam("i") int i) throws Exception {
return oldBehaviorProxy.oldException(i);
}

/**
* Uses a proxy to call oldException() to get an HTTP response derived from a WebApplicationException.
* The proxy will throw a WebApplicationExceptionWrapper because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is false.
*
* @param i determines element of oldExceptions to be thrown by oldException()
* @throws Exception
*/
@GET
@Path("nocatch/new/old/{i}")
public String noCatchNewOld(@PathParam("i") int i) throws Exception {
return newBehaviorProxy.oldException(i);
}

/**
* Uses a proxy to call newException() to get an HTTP response derived from a WebApplicationExceptionWrapper.
* The proxy will throw a WebApplicationException because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is true.
*
* @param i determines element of newExceptions to be thrown by newException()
* @throws Exception
*/
@GET
@Path("nocatch/old/new/{i}")
public String noCatchOldNew(@PathParam("i") int i) throws Exception {
return oldBehaviorProxy.newException(i);
}

/**
* Uses a proxy to call newException() to get an HTTP response derived from a WebApplicationExceptionWrapper.
* Based on that response, the proxy will throw either a WebApplicationException or WebApplicationExceptionWrapper,
* depending on the value of ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR.
* The proxy will throw a WebApplicationExceptionWrapper because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is false.
*
* @param i determines element of newExceptions to be thrown by newException()
* @throws Exception
*/
@GET
@Path("nocatch/new/{i}")
public String noCatchNew(@PathParam("i") int i) throws Exception {
return proxy.newException(i);
@Path("nocatch/new/new/{i}")
public String noCatchNewNew(@PathParam("i") int i) throws Exception {
return newBehaviorProxy.newException(i);
}

/**
Expand All @@ -109,7 +130,7 @@ public String noCatchNew(@PathParam("i") int i) throws Exception {
@Path("catch/old/old/{i}")
public String catchOldOld(@PathParam("i") int i) throws Exception {
try {
proxy.oldException(i);
newBehaviorProxy.oldException(i);
throw new Exception("expected exception");
} catch (ResteasyWebApplicationException e) {
throw new Exception("didn't expect ResteasyWebApplicationException");
Expand Down Expand Up @@ -138,7 +159,7 @@ public String catchOldOld(@PathParam("i") int i) throws Exception {
@Path("catch/old/new/{i}")
public String catchOldNew(@PathParam("i") int i) throws Exception {
try {
return proxy.newException(i);
return newBehaviorProxy.newException(i);
} catch (ResteasyWebApplicationException e) {
throw new Exception("didn't expect ResteasyWebApplicationException");
} catch (WebApplicationException e) {
Expand Down Expand Up @@ -169,7 +190,7 @@ public String catchOldNew(@PathParam("i") int i) throws Exception {
@Path("catch/new/old/{i}")
public String catchNewOld(@PathParam("i") int i) throws Exception {
try {
return proxy.oldException(i);
return newBehaviorProxy.oldException(i);
} catch (ResteasyWebApplicationException e) {
throw new Exception("didn't expect ResteasyWebApplicationException");
} catch (WebApplicationException e) {
Expand Down Expand Up @@ -205,7 +226,7 @@ public String catchNewOld(@PathParam("i") int i) throws Exception {
@Path("catch/new/new/{i}")
public String catchNewNew(@PathParam("i") int i) throws Exception {
try {
return proxy.newException(i);
return newBehaviorProxy.newException(i);
} catch (ResteasyWebApplicationException e) {
throw new Exception("didn't expect ResteasyWebApplicationException");
} catch (WebApplicationException e) {
Expand Down
Expand Up @@ -6,14 +6,6 @@

public interface ClientWebApplicationExceptionProxyResourceInterface {

/**
* Sets the System property ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR
* @param value value property is set to
*/
@GET
@Path("behavior/{value}")
void setBehavior(@PathParam("value") String value);

/**
* Throws an instance of WebApplicationException from oldExceptions table. The Response returned by
* WebApplicationException.getResponse() will be used by the container to create an HTTP response.
Expand All @@ -39,27 +31,51 @@ public interface ClientWebApplicationExceptionProxyResourceInterface {

/**
* Uses a Client or proxy to call oldException() to get an HTTP response derived from a WebApplicationException.
* Based on that response, the Client or proxy will throw either a WebApplicationException or ResteasyWebApplicationException,
* depending on the value of ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR.
* The Client or proxy will throw a WebApplicationException because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is true.
*
* @param i determines element of oldExceptions to be thrown by oldException()
* @throws Exception
*/
@GET
@Path("nocatch/old/old/{i}")
String noCatchOldOld(@PathParam("i") int i) throws Exception;

/**
* Uses a Client or proxy to call oldException() to get an HTTP response derived from a WebApplicationException.
* The Client or proxy will throw a ResteasyWebApplicationException or WebApplicationExceptionWrapper because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is false.
*
* @param i determines element of oldExceptions to be thrown by oldException()
* @throws Exception
*/
@GET
@Path("nocatch/old/{i}")
String noCatchOld(@PathParam("i") int i) throws Exception;
@Path("nocatch/new/old/{i}")
String noCatchNewOld(@PathParam("i") int i) throws Exception;

/**
* Uses a Client or proxy to call newException() to get an HTTP response derived from a ResteasyWebApplicationException.
* The Client or proxy will throw a WebApplicationException because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is true.
*
* @param i determines element of newExceptions to be thrown by newException()
* @throws Exception
*/
@GET
@Path("nocatch/old/new/{i}")
String noCatchOldNew(@PathParam("i") int i) throws Exception;

/**
* Uses a Client or proxy to call newException() to get an HTTP response derived from a ResteasyWebApplicationException.
* Based on that response, the Client or proxy will throw either a WebApplicationException or ResteasyWebApplicationException,
* depending on the value of ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR.
* The Client or proxy will throw a ResteasyWebApplicationException or WebApplicationExceptionWrapper because
* ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is false.
*
* @param i determines element of newExceptions to be thrown by newException()
* @throws Exception
*/
@GET
@Path("nocatch/new/{i}")
String noCatchNew(@PathParam("i") int i) throws Exception;
@Path("nocatch/new/new/{i}")
String noCatchNewNew(@PathParam("i") int i) throws Exception;

/**
* It is assumed that ResteasyContextParameters.RESTEASY_ORIGINAL_WEBAPPLICATIONEXCEPTION_BEHAVIOR is
Expand Down

0 comments on commit f1b9c5a

Please sign in to comment.