PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ws/context/application/ContextRootTestBase.java

#
Java | 53 lines | 32 code | 14 blank | 7 comment | 0 complexity | c14a8f69502ea9dcd221a1f16164cb37 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. package org.jboss.as.test.integration.ws.context.application;
  2. import java.net.URL;
  3. import junit.framework.Assert;
  4. import org.jboss.arquillian.test.api.ArquillianResource;
  5. import org.jboss.shrinkwrap.api.ShrinkWrap;
  6. import org.jboss.shrinkwrap.api.spec.WebArchive;
  7. import org.junit.Test;
  8. /**
  9. * Base class for context.application tests. Unit test checks if context-root parameter is honored regardles of deploy content.
  10. *
  11. * @author baranowb
  12. *
  13. */
  14. public class ContextRootTestBase {
  15. protected static final String WAR_DEPLOYMENT_NAME = "ws-notannotated";
  16. protected static final String WAR_DEPLOYMENT_UNIT_NAME = WAR_DEPLOYMENT_NAME + "-XXX.war";
  17. protected static final String EAR_DEPLOYMENT_NAME = "ws-notannotated";
  18. protected static final String EAR_DEPLOYMENT_UNIT_NAME = EAR_DEPLOYMENT_NAME + "-XXX.ear";
  19. protected static final String DEPLOYMENT_RESOURCES = "org/jboss/as/test/integration/ws/context/application/notannotated";
  20. protected static final String TEST_PATH = "/test1/";
  21. @ArquillianResource
  22. URL baseUrl;
  23. protected static WebArchive createWAR(Class beanClass) {
  24. final WebArchive war = ShrinkWrap.create(WebArchive.class, WAR_DEPLOYMENT_UNIT_NAME);
  25. war.addClass(beanClass);
  26. ClassLoader tccl = Thread.currentThread().getContextClassLoader();
  27. // war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/application.xml"), "application.xml");
  28. war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/index.html"), "index.html");
  29. war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/index.xhtml"), "index.xhtml");
  30. war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/templates"), "templates");
  31. war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/beans.xml"), "beans.xml");
  32. war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/faces-config.xml"), "faces-config.xml");
  33. return war;
  34. }
  35. @Test
  36. public void testContextRoot() {
  37. Assert.assertEquals("Wrong context root!", TEST_PATH, baseUrl.getPath());
  38. }
  39. }