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
Showing
6 changed files
with
389 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/CDIEJBApplication.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,37 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.ws.rs.core.Application; | ||
|
||
public class CDIEJBApplication extends Application { | ||
|
||
public java.util.Set<java.lang.Class<?>> getClasses() { | ||
Set<Class<?>> resources = new HashSet<Class<?>>(); | ||
resources.add(EJBResource.class); | ||
resources.add(EJBRootResource.class); | ||
return resources; | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
...red-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/CDIEJBTestCase.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,136 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
import java.net.URL; | ||
|
||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.client.Invocation; | ||
import javax.ws.rs.client.WebTarget; | ||
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.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@Ignore | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class CDIEJBTestCase | ||
{ | ||
|
||
@ArquillianResource | ||
private URL baseURL; | ||
|
||
private Client client = ClientBuilder.newClient(); | ||
|
||
@Deployment(testable = false) | ||
public static WebArchive createDeployments() | ||
{ | ||
WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxrs-integration-cdiejb.war"); | ||
archive | ||
.addManifest() | ||
.addClasses(CDIEJBApplication.class, EJBLocal.class, EJBLocalBean.class, EJBResource.class, | ||
EJBRootResource.class).addAsWebInfResource(getWebXml(), "web.xml"); | ||
return archive; | ||
} | ||
|
||
private static StringAsset getWebXml() | ||
{ | ||
return new StringAsset( | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
+ "<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\">" + "<servlet>" + " <servlet-name>Mapping</servlet-name>" | ||
+ " <servlet-class>org.jboss.wsf.stack.cxf.JAXRSServletExt</servlet-class>" + " <init-param>" | ||
+ " <param-name>javax.ws.rs.Application</param-name>" | ||
+ " <param-value>com.sun.ts.tests.jaxrs.platform.ejbsingleton.TSAppConfig</param-value>" | ||
+ " </init-param>" + "</servlet>" + "<servlet-mapping>" | ||
+ " <servlet-name>Mapping</servlet-name>" + " <url-pattern>/*</url-pattern>" | ||
+ "</servlet-mapping></web-app>"); | ||
} | ||
|
||
@Test | ||
public void testRootResource(String urlPattern) throws Exception | ||
{ | ||
WebTarget target = client.target(baseURL + "/root"); | ||
Invocation.Builder builder = target.request(); | ||
Response response = builder.buildGet().invoke(); | ||
|
||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertTrue(response.readEntity(String.class).contains("From EJB Root Resource")); | ||
} | ||
|
||
@Test | ||
public void testSubResource(String urlPattern) throws Exception | ||
{ | ||
WebTarget target = client.target(baseURL + "/root/sub"); | ||
Invocation.Builder builder = target.request(); | ||
Response response = builder.buildGet().invoke(); | ||
|
||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertTrue(response.readEntity(String.class).contains("From EJB Resource")); | ||
} | ||
|
||
@Test | ||
public void testLocalEjbSubResource(String urlPattern) throws Exception | ||
{ | ||
WebTarget target = client.target(baseURL + "/root/local"); | ||
Invocation.Builder builder = target.request(); | ||
Response response = builder.buildGet().invoke(); | ||
|
||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertTrue(response.readEntity(String.class).contains("From EJBLocalBean")); | ||
} | ||
|
||
@Test | ||
public void testUnwrapException(String urlPattern) throws Exception | ||
{ | ||
WebTarget target = client.target(baseURL + "/root/exception"); | ||
Invocation.Builder builder = target.request(); | ||
Response response = builder.buildGet().invoke(); | ||
|
||
Assert.assertEquals(201, response.getStatus()); | ||
} | ||
|
||
@Test | ||
public void testPriorPostConstructor(String urlPattern) throws Exception | ||
{ | ||
WebTarget target = client.target(baseURL + "/root/priorpost"); | ||
Invocation.Builder builder = target.request(); | ||
Response response = builder.buildGet().invoke(); | ||
|
||
Assert.assertEquals(200, response.getStatus()); | ||
Assert.assertTrue(response.readEntity(String.class).contains("true")); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...te/shared-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/EJBLocal.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,33 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
import javax.ws.rs.GET; | ||
|
||
public interface EJBLocal | ||
{ | ||
|
||
public void remove(); | ||
|
||
@GET | ||
public String get() throws Exception; | ||
} |
53 changes: 53 additions & 0 deletions
53
...hared-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/EJBLocalBean.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,53 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
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 = "EJBLocalBean") | ||
@Local( | ||
{EJBLocal.class}) | ||
public class EJBLocalBean implements EJBLocal | ||
{ | ||
|
||
public EJBLocalBean() | ||
{ | ||
} | ||
|
||
public void remove() | ||
{ | ||
} | ||
|
||
@Context | ||
private UriInfo ui; | ||
|
||
@GET | ||
public String get() | ||
{ | ||
return "GET: " + ui.getRequestUri().toASCIIString() + "From EJBLocalBean"; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...shared-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/EJBResource.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,40 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
import javax.ejb.Singleton; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.UriInfo; | ||
|
||
@Singleton | ||
public class EJBResource { | ||
|
||
@Context private UriInfo ui; | ||
|
||
@GET | ||
public String get() { | ||
return "GET: " + ui.getRequestUri().toASCIIString() + "From EJB Resource"; | ||
} | ||
} | ||
|
||
|
90 changes: 90 additions & 0 deletions
90
...ed-rest-tests/src/test/java/org/jboss/test/jaxrs/integration/cdi/ejb/EJBRootResource.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,90 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2016, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.test.jaxrs.integration.cdi.ejb; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.ejb.EJB; | ||
import javax.ejb.EJBException; | ||
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.Status; | ||
import javax.ws.rs.core.UriInfo; | ||
|
||
@Path("/root") | ||
public class EJBRootResource | ||
{ | ||
|
||
@Context | ||
private UriInfo uri; | ||
|
||
@GET | ||
public String get() | ||
{ | ||
return "GET: " + uri.getRequestUri().toASCIIString() + "From EJB Root Resource"; | ||
} | ||
|
||
@EJB | ||
EJBResource r; | ||
|
||
@Path("/sub") | ||
public EJBResource getSub() | ||
{ | ||
return r; | ||
} | ||
|
||
@EJB | ||
EJBLocal rl; | ||
|
||
@Path("/local") | ||
public EJBLocal getLocal() | ||
{ | ||
return rl; | ||
} | ||
|
||
@Path("exception") | ||
@GET | ||
public String throwException() | ||
{ | ||
throw new EJBException(new WebApplicationException(Status.CREATED)); | ||
} | ||
|
||
@Context | ||
private Application application; | ||
|
||
private boolean isPostConstruct = false; | ||
|
||
@PostConstruct | ||
public void postConstruct() | ||
{ | ||
isPostConstruct = application != null; | ||
} | ||
|
||
@Path("priorpost") | ||
@GET | ||
public String jaxrsInjectPriorPostConstructOnRootResource() | ||
{ | ||
return String.valueOf(isPostConstruct); | ||
} | ||
} |