PageRenderTime 44ms CodeModel.GetById 32ms app.highlight 11ms 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
 1package org.jboss.as.test.integration.ws.context.application;
 2
 3import java.net.URL;
 4
 5import junit.framework.Assert;
 6
 7import org.jboss.arquillian.test.api.ArquillianResource;
 8import org.jboss.shrinkwrap.api.ShrinkWrap;
 9import org.jboss.shrinkwrap.api.spec.WebArchive;
10import org.junit.Test;
11
12/**
13 * Base class for context.application tests. Unit test checks if context-root parameter is honored regardles of deploy content.
14 * 
15 * @author baranowb
16 * 
17 */
18public class ContextRootTestBase {
19
20    protected static final String WAR_DEPLOYMENT_NAME = "ws-notannotated";
21    protected static final String WAR_DEPLOYMENT_UNIT_NAME = WAR_DEPLOYMENT_NAME + "-XXX.war";
22    protected static final String EAR_DEPLOYMENT_NAME = "ws-notannotated";
23    protected static final String EAR_DEPLOYMENT_UNIT_NAME = EAR_DEPLOYMENT_NAME + "-XXX.ear";
24    protected static final String DEPLOYMENT_RESOURCES = "org/jboss/as/test/integration/ws/context/application/notannotated";
25
26    protected static final String TEST_PATH = "/test1/";
27
28    @ArquillianResource
29    URL baseUrl;
30
31    protected static WebArchive createWAR(Class beanClass) {
32        final WebArchive war = ShrinkWrap.create(WebArchive.class, WAR_DEPLOYMENT_UNIT_NAME);
33
34        war.addClass(beanClass);
35
36        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
37
38        // war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/application.xml"), "application.xml");
39        war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/index.html"), "index.html");
40        war.addAsWebResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/index.xhtml"), "index.xhtml");
41
42        war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/templates"), "templates");
43        war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/beans.xml"), "beans.xml");
44        war.addAsWebInfResource(tccl.getResource(DEPLOYMENT_RESOURCES + "/WEB-INF/faces-config.xml"), "faces-config.xml");
45        return war;
46    }
47
48    @Test
49    public void testContextRoot() {
50        Assert.assertEquals("Wrong context root!", TEST_PATH, baseUrl.getPath());
51    }
52
53}