Skip to content

Commit

Permalink
feat: Introduce AverageSystemLoadServletTomcatIT
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Jun 4, 2024
1 parent 3715474 commit bf8510e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jboss.test.clusterbench.it.tomcat;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;

import java.io.File;

/**
* @author Radoslav Husar
*/
public abstract class AbstractTomcatIT {

@Deployment(testable = false)
public static Archive<?> deployment() {
return ShrinkWrap
.create(ZipImporter.class, "clusterbench.war")
.importFrom(new File("target/clusterbench-ee10-web-tomcat.war"))
.as(WebArchive.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/

package org.jboss.test.clusterbench.it.tomcat;

import static org.junit.Assert.assertEquals;

import java.net.URL;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.test.clusterbench.web.session.HttpSessionServlet;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Tomcat version of the smoke test for {@link org.jboss.test.clusterbench.web.load.AverageSystemLoadServlet}.
*
* @author Radoslav Husar
*/
@RunWith(Arquillian.class)
@RunAsClient
public class AverageSystemLoadServletTomcatIT extends AbstractTomcatIT {

@Test
public void test(@ArquillianResource(HttpSessionServlet.class) URL baseURL) throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet(baseURL.toURI() + "/averagesystemload?milliseconds=1000&threads=4");
System.out.println(httpGet);

try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
assertEquals(200, response.getStatusLine().getStatusCode());

String responseBody = EntityUtils.toString(response.getEntity());
assertEquals("DONE", responseBody);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Optional;
Expand All @@ -19,14 +18,9 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.clusterbench.web.session.HttpSessionServlet;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -36,15 +30,7 @@
*/
@RunWith(Arquillian.class)
@RunAsClient
public class HttpSessionServletTomcatIT {

@Deployment(testable = false)
public static Archive<?> deployment() {
return ShrinkWrap
.create(ZipImporter.class, "clusterbench.war")
.importFrom(new File("target/clusterbench-ee10-web-tomcat.war"))
.as(WebArchive.class);
}
public class HttpSessionServletTomcatIT extends AbstractTomcatIT {

@Test
public void test(@ArquillianResource(HttpSessionServlet.class) URL baseURL) throws Exception {
Expand Down

0 comments on commit bf8510e

Please sign in to comment.