Search in sources :

Example 91 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class SubDeploymentAvailableInClassPathTestCase method testServletClassNotAvailableToEjbInEar.

/**
     * Tests that for a .ear like this one:
     * myapp.ear
     * |
     * |--- web.war
     * |
     * |--- ejb.jar
     * <p/>
     * <p/>
     * the classes within the ejb.jar *don't* have access to the classes in the web.war
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("ear-with-single-war")
public void testServletClassNotAvailableToEjbInEar(@ArquillianResource(EjbInvokingServlet.class) URL baseUrl) throws Exception {
    try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
        final String classInWar = HelloWorldServlet.class.getName();
        final String requestURL = baseUrl.toURI() + EjbInvokingServlet.URL_PATTERN + "?" + EjbInvokingServlet.CLASS_IN_WAR_PARAMETER + "=" + classInWar;
        final HttpGet request = new HttpGet(requestURL);
        final HttpResponse response = httpClient.execute(request);
        final HttpEntity entity = response.getEntity();
        Assert.assertNotNull("Response message from servlet was null", entity);
        final String responseMessage = EntityUtils.toString(entity);
        Assert.assertEquals("Unexpected echo message from servlet", EjbInvokingServlet.SUCCESS_MESSAGE, responseMessage);
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 92 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class SubDeploymentAvailableInClassPathTestCase method testWarsDontSeeEachOtherInEar.

/**
     * Tests that for a .ear like this one:
     * myapp.ear
     * |
     * |--- web-one.war
     * |
     * |--- web-two.war
     * <p/>
     * <p/>
     * the classes within the web-one.war *don't* have access to the classes in the web-two.war
     *
     * @throws Exception
     */
@Test
@OperateOnDeployment("ear-with-multiple-wars")
public void testWarsDontSeeEachOtherInEar(@ContainerResource ManagementClient managementClient) throws Exception {
    try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
        final String classInOtherWar = HelloWorldServlet.class.getName();
        final String requestURL = managementClient.getWebUri() + "/" + OTHER_WEB_APP_CONTEXT + ServletInOtherWar.URL_PATTERN + "?" + ServletInOtherWar.CLASS_IN_OTHER_WAR_PARAMETER + "=" + classInOtherWar;
        final HttpGet request = new HttpGet(requestURL);
        final HttpResponse response = httpClient.execute(request);
        final HttpEntity entity = response.getEntity();
        Assert.assertNotNull("Response message from servlet was null", entity);
        final String responseMessage = EntityUtils.toString(entity);
        Assert.assertEquals("Unexpected echo message from servlet", ServletInOtherWar.SUCCESS_MESSAGE, responseMessage);
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 93 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class XercesUsageTestCase method testXercesUsageInServletInJSFApp.

/**
     * Test that a JSF web application, with xerces jar packaged within the deployment, functions correctly while using
     * the packaged xerces API.
     *
     * @throws Exception
     */
@OperateOnDeployment("app-with-jsf")
@Test
public void testXercesUsageInServletInJSFApp() throws Exception {
    final HttpClient httpClient = new DefaultHttpClient();
    final String xml = "dummy.xml";
    final String requestURL = withJsf.toExternalForm() + XercesUsageServlet.URL_PATTERN + "?" + XercesUsageServlet.XML_RESOURCE_NAME_PARAMETER + "=" + xml;
    final HttpGet request = new HttpGet(requestURL);
    final HttpResponse response = httpClient.execute(request);
    int statusCode = response.getStatusLine().getStatusCode();
    Assert.assertEquals("Unexpected status code", 200, statusCode);
    final HttpEntity entity = response.getEntity();
    Assert.assertNotNull("Response message from servlet was null", entity);
    final String responseMessage = EntityUtils.toString(entity);
    Assert.assertEquals("Unexpected echo message from servlet", XercesUsageServlet.SUCCESS_MESSAGE, responseMessage);
}
Also used : HttpEntity(org.apache.http.HttpEntity) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 94 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class XercesUsageTestCase method testXercesUsageInServletInNonJSFApp.

/**
     * Test that a non-JSF web application, with xerces jar packaged within the deployment, functions correctly
     * while using the packaged xerces API.
     *
     * @throws Exception
     */
@OperateOnDeployment("app-without-jsf")
@Test
public void testXercesUsageInServletInNonJSFApp() throws Exception {
    final HttpClient httpClient = new DefaultHttpClient();
    final String xml = "dummy.xml";
    final String requestURL = withoutJsf.toExternalForm() + XercesUsageServlet.URL_PATTERN + "?" + XercesUsageServlet.XML_RESOURCE_NAME_PARAMETER + "=" + xml;
    final HttpGet request = new HttpGet(requestURL);
    final HttpResponse response = httpClient.execute(request);
    int statusCode = response.getStatusLine().getStatusCode();
    Assert.assertEquals("Unexpected status code", 200, statusCode);
    final HttpEntity entity = response.getEntity();
    Assert.assertNotNull("Response message from servlet was null", entity);
    final String responseMessage = EntityUtils.toString(entity);
    Assert.assertEquals("Unexpected echo message from servlet", XercesUsageServlet.SUCCESS_MESSAGE, responseMessage);
}
Also used : HttpEntity(org.apache.http.HttpEntity) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Aggregations

OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)94 Test (org.junit.Test)93 URL (java.net.URL)31 URI (java.net.URI)22 HttpGet (org.apache.http.client.methods.HttpGet)20 HttpResponse (org.apache.http.HttpResponse)17 InitialContext (javax.naming.InitialContext)15 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)13 QName (javax.xml.namespace.QName)11 Service (javax.xml.ws.Service)11 HttpEntity (org.apache.http.HttpEntity)10 Bus (org.apache.cxf.Bus)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)5 WebConversation (com.meterware.httpunit.WebConversation)5 WebForm (com.meterware.httpunit.WebForm)5 WebRequest (com.meterware.httpunit.WebRequest)5