Skip to content

Commit

Permalink
JBEAP-11748 "No JAX-RS Activator" warning in JBDS 10.4.0 when importi…
Browse files Browse the repository at this point in the history
…ng spring-resteasy
  • Loading branch information
ctomc committed Jul 13, 2017
1 parent babb6c7 commit 8ad5454
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 224 deletions.
42 changes: 19 additions & 23 deletions spring-resteasy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,33 @@ And the same set as above but using the `locating` path.
* [${project.artifactId}/locating/matrixParam;param=matrix](http://localhost:8080/${project.artifactId}/locating/matrixParam;param=matrix)
* [${project.artifactId}/locating/uriParam/789](http://localhost:8080/${project.artifactId}/locating/uriParam/789)

## Undeploy the Archive

## Run the Tests

1. Make sure you have **started** the ${product.name} server as described above and **deployed** the quickstart.
2. Open a command prompt and navigate to the root directory of this quickstart.
3. Type the following command to run the test goal with the following profile activated:

mvn install -Prest-test
1. Make sure you have started the ${product.name} server as described above.
2. Open a command line and navigate to the root directory of this quickstart.
3. When you are finished testing, type this command to undeploy the archive:

4. You should see the following output:
mvn wildfly:undeploy

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.jboss.as.quickstarts.resteasyspring.test.ResteasySpringTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.211 sec
## Run the Arquillian Functional Tests

Results :
This quickstart provides Arquillian functional tests as well. They are located in the functional-tests/ subdirectory under
the root directory of this quickstart. Functional tests verify that your application behaves correctly from the user's point
of view. The tests open a browser instance, simulate clicking around the page as a normal user would do, and then close the browser instance.

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
To run these tests, you must build the main project as described above.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
1. Open a command line and navigate to the root directory of this quickstart.
2. Build the quickstart WAR using the following command:

mvn clean package

3. Navigate to the functional-tests/ directory in this quickstart.
4. If you have a running instance of the ${product.name} server, as described above, run the remote tests by typing the following command:

## Undeploy the Archive
mvn clean verify -Parq-remote

1. Make sure you have started the ${product.name} server as described above.
2. Open a command line and navigate to the root directory of this quickstart.
3. When you are finished testing, type this command to undeploy the archive:
5. If you prefer to run the functional tests using managed instance of the ${product.name} server, meaning the tests will start the
server for you, type the following command:

mvn wildfly:undeploy
mvn clean verify -Parq-managed
57 changes: 13 additions & 44 deletions spring-resteasy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,51 +101,20 @@
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>


</dependencies>

<profiles>
<profile>
<!-- The default profile skips all tests, though you can tune it to run just unit tests based on a custom pattern -->
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- The default profile skips all tests, though you can tune it to run just unit tests based on a custom pattern -->
<id>rest-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>surefire-it</id>
<goals>
<goal>test</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.jboss.as.quickstarts.resteasyspring;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

/**
* @author Tomaz Cerar (c) 2017 Red Hat Inc.
*/
@ApplicationPath("/")
public class JaxRsActivator extends Application {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.jboss.as.quickstarts.resteasyspring.test;

import java.net.URI;
import java.net.URL;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
Expand All @@ -27,105 +28,119 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
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.arquillian.test.api.ArquillianResource;
import org.jboss.as.quickstarts.resteasyspring.GreetingBean;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Basic unit tests for resteasy spring integration
*/
public class ResteasySpringTest {

@RunWith(Arquillian.class)
@RunAsClient
public class ResteasySpringIT {
@Deployment
public static WebArchive getDeployment() {
return ShrinkWrap.create(WebArchive.class, "spring-resteasy.war")
.addPackages(true, GreetingBean.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsWebInfResource("web.xml")
.addAsWebInfResource("applicationContext.xml")
.addAsLibraries(Maven.configureResolver()
.resolve("org.springframework:spring-web:4.3.9.RELEASE")
.withTransitivity().asFile());
}

@ArquillianResource
URL url;

@Test
public void testHelloSpringResource() throws Exception {
CloseableHttpClient client = HttpClients.createDefault();
try {
try (CloseableHttpClient client = HttpClients.createDefault()) {
{
URI uri = new URIBuilder()
.setScheme("http")
.setHost("localhost:8080")
.setPath("/spring-resteasy/hello")
.setHost(url.getHost())
.setPort(url.getPort())
.setPath(url.getPath() + "hello")
.setParameter("name", "JBoss Developer")
.build();
HttpGet method = new HttpGet(uri);
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("JBoss Developer"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/basic");
CloseableHttpResponse response = client.execute(method);
try {
HttpGet method = new HttpGet(url.toString() + "basic");
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("basic"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpPut method = new HttpPut("http://localhost:8080/spring-resteasy/basic");
HttpPut method = new HttpPut(url.toString() + "basic");
method.setEntity(new StringEntity("basic", ContentType.TEXT_PLAIN));
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_NO_CONTENT, response.getStatusLine().getStatusCode());
} finally {
response.close();
method.releaseConnection();
}
}
{
URI uri = new URIBuilder()
.setScheme("http")
.setHost("localhost:8080")
.setPath("/spring-resteasy/queryParam")
.setHost(url.getHost())
.setPort(url.getPort())
.setPath(url.getPath() + "queryParam")
.setParameter("param", "hello world")
.build();
HttpGet method = new HttpGet(uri);
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("hello world"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/matrixParam;param=matrix");
CloseableHttpResponse response = client.execute(method);
try {
HttpGet method = new HttpGet(url.toString() + "matrixParam;param=matrix");
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("matrix"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/uriParam/1234");
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("1234"));
} finally {
response.close();
method.releaseConnection();
}
}
} finally {
client.close();
}
}

@Test
public void testLocatingResource() throws Exception {
CloseableHttpClient client = HttpClients.createDefault();
try {
try (CloseableHttpClient client = HttpClients.createDefault()) {
{
URI uri = new URIBuilder()
.setScheme("http")
Expand All @@ -134,34 +149,28 @@ public void testLocatingResource() throws Exception {
.setParameter("name", "JBoss Developer")
.build();
HttpGet method = new HttpGet(uri);
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("JBoss Developer"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/locating/basic");
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("basic"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpPut method = new HttpPut("http://localhost:8080/spring-resteasy/locating/basic");
method.setEntity(new StringEntity("basic", ContentType.TEXT_PLAIN));
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_NO_CONTENT, response.getStatusLine().getStatusCode());
} finally {
response.close();
method.releaseConnection();
}
}
Expand All @@ -173,39 +182,31 @@ public void testLocatingResource() throws Exception {
.setParameter("param", "hello world")
.build();
HttpGet method = new HttpGet(uri);
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("hello world"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/locating/matrixParam;param=matrix");
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("matrix"));
} finally {
response.close();
method.releaseConnection();
}
}
{
HttpGet method = new HttpGet("http://localhost:8080/spring-resteasy/locating/uriParam/1234");
CloseableHttpResponse response = client.execute(method);
try {
try (CloseableHttpResponse response = client.execute(method)) {
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("1234"));
} finally {
response.close();
method.releaseConnection();
}
}
} finally {
client.close();
}
}

Expand Down
Loading

0 comments on commit 8ad5454

Please sign in to comment.