Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad4a086
commit 5061d37
Showing
16 changed files
with
458 additions
and
93 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
jaxrs/as8-integration-testing/ejb-singleton-test/pom.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,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs-all</artifactId> | ||
<version>3.0.3.Final</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.jboss.resteasy.test</groupId> | ||
<artifactId>as8-application-test</artifactId> | ||
<packaging>war</packaging> | ||
<description/> | ||
<url>http://maven.apache.org</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<version>1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.ejb</groupId> | ||
<artifactId>jboss-ejb-api_3.1_spec</artifactId> | ||
<version>1.0.2.Final</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-client</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<finalName>ejb-singleton-test</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jboss.as.plugins</groupId> | ||
<artifactId>jboss-as-maven-plugin</artifactId> | ||
<version>7.4.Final</version> | ||
<executions> | ||
<execution> | ||
<id>jboss-deploy</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>deploy</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>jboss-undeploy</id> | ||
<phase>post-integration-test</phase> | ||
<goals> | ||
<goal>undeploy</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>surefire-it</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
...testing/ejb-singleton-test/src/main/java/org/jboss/resteasy/tests/ScannedApplication.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,19 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@ApplicationPath("/") | ||
public class ScannedApplication extends Application | ||
{ | ||
public java.util.Set<java.lang.Class<?>> getClasses() { | ||
Set<Class<?>> resources = new HashSet<Class<?>>(); | ||
resources.add(SingletonRootResource.class); | ||
return resources; | ||
}} |
13 changes: 13 additions & 0 deletions
13
...n-testing/ejb-singleton-test/src/main/java/org/jboss/resteasy/tests/SingletonLocalIF.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,13 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
import javax.ws.rs.GET; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
public interface SingletonLocalIF | ||
{ | ||
@GET | ||
String get(); | ||
} |
66 changes: 66 additions & 0 deletions
66
...ting/ejb-singleton-test/src/main/java/org/jboss/resteasy/tests/SingletonRootResource.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,66 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.EJB; | ||
import javax.ejb.EJBException; | ||
import javax.ejb.Singleton; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.core.Application; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.Response; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@Singleton | ||
@Path("root") | ||
public class SingletonRootResource | ||
{ | ||
@EJB | ||
SingletonSubResource sub; | ||
|
||
@EJB | ||
SingletonLocalIF rl; | ||
|
||
|
||
@Path("sub") | ||
public SingletonSubResource getSub() | ||
{ | ||
return sub; | ||
} | ||
|
||
@Path("intfsub") | ||
public SingletonLocalIF getLocalSub() { | ||
return rl; | ||
} | ||
|
||
|
||
@Context | ||
private Application injectedApplication; | ||
private boolean isJaxrsInjectedPriorToPostConstruct = false; | ||
|
||
@PostConstruct | ||
public void postConstruct() | ||
{ | ||
isJaxrsInjectedPriorToPostConstruct = injectedApplication != null; | ||
} | ||
|
||
@Path("injected") | ||
@GET | ||
public String injected(){ | ||
return String.valueOf(isJaxrsInjectedPriorToPostConstruct); | ||
} | ||
|
||
@Path("exception") | ||
@GET | ||
public String throwException (){ | ||
throw new EJBException(new WebApplicationException(Response.Status.CREATED)); | ||
} | ||
|
||
|
||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...sting/ejb-singleton-test/src/main/java/org/jboss/resteasy/tests/SingletonSubResource.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,19 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
import javax.ejb.Singleton; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Produces; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@Singleton | ||
public class SingletonSubResource | ||
{ | ||
@GET | ||
@Produces("text/plain") | ||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...-testing/ejb-singleton-test/src/main/java/org/jboss/resteasy/tests/SingletonTestBean.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,30 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
import javax.ejb.Local; | ||
import javax.ejb.Stateless; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.UriInfo; | ||
|
||
@Stateless(name = "SingletonTestBean") | ||
@Local({ SingletonLocalIF.class }) | ||
public class SingletonTestBean implements SingletonLocalIF | ||
{ | ||
|
||
public SingletonTestBean() { | ||
} | ||
|
||
public void remove() { | ||
} | ||
|
||
@Context | ||
private UriInfo ui; | ||
|
||
@Override | ||
@GET | ||
public String get() { | ||
return "GET: " + ui.getRequestUri().toASCIIString() + | ||
" Hello From Singleton Local EJB Sub"; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
jaxrs/as8-integration-testing/ejb-singleton-test/src/main/webapp/WEB-INF/web.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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app 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" | ||
version="3.0"> | ||
|
||
</web-app> |
39 changes: 39 additions & 0 deletions
39
...on-testing/ejb-singleton-test/src/test/java/org/jboss/resteasy/tests/ApplicationTest.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,39 @@ | ||
package org.jboss.resteasy.tests; | ||
|
||
import junit.framework.Assert; | ||
import org.junit.Test; | ||
|
||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.client.WebTarget; | ||
import javax.ws.rs.core.Response; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
public class ApplicationTest | ||
{ | ||
|
||
@Test | ||
public void testSingleton() throws Exception | ||
{ | ||
Client client = ClientBuilder.newClient(); | ||
String value = null; | ||
WebTarget base = client.target("http://localhost:8080/ejb-singleton-test/root"); | ||
value = base.path("sub").request().get(String.class); | ||
Assert.assertEquals("hello", value); | ||
value = base.path("injected").request().get(String.class); | ||
Assert.assertEquals("true", value); | ||
value = base.path("intfsub").request().get(String.class); | ||
System.out.println(value); | ||
|
||
Response response = base.path("exception").request().get(); | ||
Assert.assertEquals(201, response.getStatus()); | ||
|
||
|
||
|
||
client.close(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.