Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RESTEASY-2266] Fix storage of ServletConfig when useGlobal applies.
- Loading branch information
Showing
7 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...est/java/org/jboss/resteasy/test/microprofile/config/MicroProfileConfigUseGlobalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.jboss.resteasy.test.microprofile.config; | ||
|
||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.resteasy.client.jaxrs.ResteasyClient; | ||
import org.jboss.resteasy.test.microprofile.config.resource.MicroProfileConfigUseGlobalApplication1; | ||
import org.jboss.resteasy.test.microprofile.config.resource.MicroProfileConfigUseGlobalApplication2; | ||
import org.jboss.resteasy.test.microprofile.config.resource.MicroProfileConfigUseGlobalResource; | ||
import org.jboss.resteasy.utils.PortProviderUtil; | ||
import org.jboss.resteasy.utils.TestUtil; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @tpSubChapter MicroProfile Config: ServletConfig with useGlobal and multiple servlets | ||
* @tpChapter Integration tests | ||
* @tpTestCaseDetails Regression tests for RESTEASY-2266 | ||
* @tpSince RESTEasy 4.1.0 | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class MicroProfileConfigUseGlobalTest { | ||
|
||
static ResteasyClient client; | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
WebArchive war = TestUtil.prepareArchive(MicroProfileConfigUseGlobalTest.class.getSimpleName()) | ||
.addClass(MicroProfileConfigUseGlobalApplication1.class) | ||
.addClass(MicroProfileConfigUseGlobalApplication2.class) | ||
.setWebXML(MicroProfileConfigUseGlobalTest.class.getPackage(), "web_use_global.xml") | ||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
return TestUtil.finishContainerPrepare(war, null, MicroProfileConfigUseGlobalResource.class); | ||
} | ||
|
||
@BeforeClass | ||
public static void before() throws Exception { | ||
client = (ResteasyClient)ClientBuilder.newClient(); | ||
} | ||
|
||
@AfterClass | ||
public static void after() throws Exception { | ||
client.close(); | ||
} | ||
|
||
private String generateURL(String path) { | ||
return PortProviderUtil.generateURL(path, MicroProfileConfigUseGlobalTest.class.getSimpleName()); | ||
} | ||
|
||
/** | ||
* @tpTestDetails | ||
* @tpSince RESTEasy 4.1.0 | ||
*/ | ||
@Test | ||
public void testMultipleAppsUseGlobal() throws Exception { | ||
Response response = client.target(generateURL("/app1/prefix")).request().get(); | ||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertEquals("/app1", response.readEntity(String.class)); | ||
response = client.target(generateURL("/app2/prefix")).request().get(); | ||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertEquals("/app2", response.readEntity(String.class)); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...s/resteasy/test/microprofile/config/resource/MicroProfileConfigUseGlobalApplication1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.resteasy.test.microprofile.config.resource; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@ApplicationPath("app1") | ||
public class MicroProfileConfigUseGlobalApplication1 extends Application { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...s/resteasy/test/microprofile/config/resource/MicroProfileConfigUseGlobalApplication2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jboss.resteasy.test.microprofile.config.resource; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@ApplicationPath("app2") | ||
public class MicroProfileConfigUseGlobalApplication2 extends Application { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...jboss/resteasy/test/microprofile/config/resource/MicroProfileConfigUseGlobalResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.jboss.resteasy.test.microprofile.config.resource; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
@Path("/") | ||
public class MicroProfileConfigUseGlobalResource { | ||
|
||
@Inject Config config; | ||
|
||
@GET | ||
@Produces("text/plain") | ||
@Path("prefix") | ||
public String prefix() { | ||
String p = ConfigProvider.getConfig().getOptionalValue("resteasy.servlet.mapping.prefix", String.class).orElse("d'oh"); | ||
return p; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...n-tests/src/test/resources/org/jboss/resteasy/test/microprofile/config/web_use_global.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
<listener> | ||
<listener-class> | ||
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap | ||
</listener-class> | ||
</listener> | ||
|
||
</web-app> |