Search in sources :

Example 56 with OperateOnDeployment

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

the class ResponseBufferSizeTestCase method increaseBufferSizeTest.

@Test
@OperateOnDeployment(DEPLOYMENT)
public void increaseBufferSizeTest(@ArquillianResource URL url) throws Exception {
    URL testURL = new URL(url.toString() + "ResponseBufferSizeServlet?" + ResponseBufferSizeServlet.SIZE_CHANGE_PARAM_NAME + "=1.5" + "&" + ResponseBufferSizeServlet.DATA_LENGTH_IN_PERCENTS_PARAM_NAME + // more than original size, less than new buffer size
    "=0.8");
    final HttpGet request = new HttpGet(testURL.toString());
    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
    CloseableHttpResponse response = null;
    try {
        response = httpClient.execute(request);
        Assert.assertEquals("Failed to access " + testURL, HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
        String content = EntityUtils.toString(response.getEntity());
        Assert.assertFalse(content.contains(ResponseBufferSizeServlet.RESPONSE_COMMITED_MESSAGE));
        final Header[] transferEncodingHeaders = response.getHeaders("Transfer-Encoding");
        log.trace("transferEncodingHeaders: " + Arrays.toString(transferEncodingHeaders));
        final Header[] contentLengthHeader = response.getHeaders("Content-Length");
        log.trace("contentLengthHeader: " + Arrays.toString(contentLengthHeader));
        for (Header transferEncodingHeader : transferEncodingHeaders) {
            Assert.assertNotEquals("Transfer-Encoding shouldn't be chunked as set BufferSize shouldn't be filled yet, " + "probably caused due https://bugzilla.redhat.com/show_bug.cgi?id=1212566", "chunked", transferEncodingHeader.getValue());
        }
        Assert.assertFalse("Content-Length header not specified", contentLengthHeader.length == 0);
    } finally {
        IOUtils.closeQuietly(response);
        httpClient.close();
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Header(org.apache.http.Header) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 57 with OperateOnDeployment

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

the class ServletRunAsTestCase method runDestroyMethodInStopServer.

/**
     * Restart server for invoking HttpServlet.destroy() method during stopping server. It also hit Servlet for initialization
     * of Servlet before server is restarted.
     *
     * @param url
     * @throws Exception
     */
@Test
@InSequence(10)
@OperateOnDeployment(DEPLOYMENT)
public void runDestroyMethodInStopServer(@ArquillianResource URL url) throws Exception {
    deployer.deploy(DEPLOYMENT);
    URL servletUrl = new URL(url.toExternalForm() + RunAsAdminServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, CORRECT_ROLE_AND_STOP_SERVER.getAbsolutePath()));
    Utils.makeCall(servletUrl.toURI(), HTTP_OK);
    servletUrl = new URL(url.toExternalForm() + RunAsUserServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, INCORRECT_ROLE_AND_STOP_SERVER.getAbsolutePath()));
    Utils.makeCall(servletUrl.toURI(), HTTP_OK);
    ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient(), 50000);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 58 with OperateOnDeployment

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

the class ServletRunAsTestCase method runServletWithCorrectRole.

/**
     * Access Servlet which uses RunAs with correct role needed for secured EJB invocation.
     * <p>
     * This method will run init() and doGet() method and stores results.
     *
     * @param url
     * @throws Exception
     */
@Test
@InSequence(1)
@OperateOnDeployment(DEPLOYMENT)
public void runServletWithCorrectRole(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + RunAsAdminServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, CORRECT_ROLE_AND_UNDEPLOY.getAbsolutePath()));
    correctRoleResult = Utils.makeCall(servletUrl.toURI(), HTTP_OK);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 59 with OperateOnDeployment

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

the class WebSecurityDIGESTTestCase method testWrongUser.

/**
     * Check whether user with incorrect credentials has not access to secured page.
     *
     * @param url
     * @throws Exception
     */
@OperateOnDeployment(DEPLOYMENT)
@Test
public void testWrongUser(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1));
    Utils.makeCallWithBasicAuthn(servletUrl, WRONG_USER, WRONG_USER_PASSWORD, HTTP_UNAUTHORIZED);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 60 with OperateOnDeployment

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

the class TransportGuaranteeTestCase method deployAnnWar.

/*@ArquillianResource
    @OperateOnDeployment(TG_ANN + WAR)
    ManagementClient managementClient;*/
//private boolean beforeServerManagerInitialized = false;
@Deployment(name = TG_ANN + WAR, order = 1, testable = false)
public static WebArchive deployAnnWar() throws Exception {
    log.trace("starting deployAnnWar()");
    WebArchive war = ShrinkWrap.create(WebArchive.class, TG_ANN + WAR);
    war.addClass(TransportGuaranteeAnnotatedServlet.class);
    war.addAsResource(TransportGuaranteeTestCase.class.getPackage(), "users.properties", "users.properties");
    war.addAsResource(TransportGuaranteeTestCase.class.getPackage(), "roles.properties", "roles.properties");
    war.setWebXML(TransportGuaranteeTestCase.class.getPackage(), "annotated-web.xml");
    war.addAsWebInfResource(TransportGuaranteeTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml");
    return war;
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Deployment(org.jboss.arquillian.container.test.api.Deployment)

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