/jboss-as-7.1.1.Final/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/JaxrsEjbInterceptorsEarTestCase.java
Java | 87 lines | 47 code | 14 blank | 26 comment | 0 complexity | 5bf29fdcfb41f8901dd7e969dc04336b MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
1/*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2010, Red Hat Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22package org.jboss.as.test.integration.jaxrs.integration.ejb;
23
24import java.net.URL;
25import java.util.concurrent.TimeUnit;
26
27import org.jboss.arquillian.container.test.api.Deployment;
28import org.jboss.arquillian.container.test.api.RunAsClient;
29import org.jboss.arquillian.junit.Arquillian;
30import org.jboss.arquillian.test.api.ArquillianResource;
31import org.jboss.as.test.integration.common.HttpRequest;
32import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml;
33import org.jboss.shrinkwrap.api.Archive;
34import org.jboss.shrinkwrap.api.ShrinkWrap;
35import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
36import org.jboss.shrinkwrap.api.spec.JavaArchive;
37import org.jboss.shrinkwrap.api.spec.WebArchive;
38import org.junit.Test;
39import org.junit.runner.RunWith;
40
41import static org.junit.Assert.assertEquals;
42
43/**
44 * Tests injections of CDI beans into JAX-RS resources with an EAR based deployment structure
45 *
46 * @author Stuart Douglas
47 */
48@RunWith(Arquillian.class)
49@RunAsClient
50public class JaxrsEjbInterceptorsEarTestCase {
51
52 @Deployment(testable = false)
53 public static Archive<?> deploy() {
54
55 EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsnoap.ear");
56
57 final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejbjar.jar");
58 ejbJar.addClasses(EJBResource.class, EjbInterceptor.class);
59 ear.addAsModule(ejbJar);
60
61 WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war");
62 war.addPackage(HttpRequest.class.getPackage());
63 war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" +
64 " <servlet-name>javax.ws.rs.core.Application</servlet-name>\n" +
65 " <url-pattern>/myjaxrs/*</url-pattern>\n" +
66 " </servlet-mapping>\n" +
67 "\n"),"web.xml");
68
69 ear.addAsModule(war);
70 return ear;
71 }
72
73 @ArquillianResource
74 private URL url;
75
76 private String performCall(String urlPattern) throws Exception {
77 return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS);
78 }
79
80 @Test
81 public void testJaxRsWithNoApplication() throws Exception {
82 String result = performCall("myjaxrs/ejbInterceptor");
83 assertEquals("Hello World", result);
84 }
85
86
87}