PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/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. */
  22. package org.jboss.as.test.integration.jaxrs.integration.ejb;
  23. import java.net.URL;
  24. import java.util.concurrent.TimeUnit;
  25. import org.jboss.arquillian.container.test.api.Deployment;
  26. import org.jboss.arquillian.container.test.api.RunAsClient;
  27. import org.jboss.arquillian.junit.Arquillian;
  28. import org.jboss.arquillian.test.api.ArquillianResource;
  29. import org.jboss.as.test.integration.common.HttpRequest;
  30. import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml;
  31. import org.jboss.shrinkwrap.api.Archive;
  32. import org.jboss.shrinkwrap.api.ShrinkWrap;
  33. import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
  34. import org.jboss.shrinkwrap.api.spec.JavaArchive;
  35. import org.jboss.shrinkwrap.api.spec.WebArchive;
  36. import org.junit.Test;
  37. import org.junit.runner.RunWith;
  38. import static org.junit.Assert.assertEquals;
  39. /**
  40. * Tests injections of CDI beans into JAX-RS resources with an EAR based deployment structure
  41. *
  42. * @author Stuart Douglas
  43. */
  44. @RunWith(Arquillian.class)
  45. @RunAsClient
  46. public class JaxrsEjbInterceptorsEarTestCase {
  47. @Deployment(testable = false)
  48. public static Archive<?> deploy() {
  49. EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsnoap.ear");
  50. final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejbjar.jar");
  51. ejbJar.addClasses(EJBResource.class, EjbInterceptor.class);
  52. ear.addAsModule(ejbJar);
  53. WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war");
  54. war.addPackage(HttpRequest.class.getPackage());
  55. war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" +
  56. " <servlet-name>javax.ws.rs.core.Application</servlet-name>\n" +
  57. " <url-pattern>/myjaxrs/*</url-pattern>\n" +
  58. " </servlet-mapping>\n" +
  59. "\n"),"web.xml");
  60. ear.addAsModule(war);
  61. return ear;
  62. }
  63. @ArquillianResource
  64. private URL url;
  65. private String performCall(String urlPattern) throws Exception {
  66. return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS);
  67. }
  68. @Test
  69. public void testJaxRsWithNoApplication() throws Exception {
  70. String result = performCall("myjaxrs/ejbInterceptor");
  71. assertEquals("Hello World", result);
  72. }
  73. }