forked from clusterbench/clusterbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce AverageSystemLoadServletTomcatIT
- Loading branch information
Showing
3 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...sts/tomcat-10.1/src/test/java/org/jboss/test/clusterbench/it/tomcat/AbstractTomcatIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...src/test/java/org/jboss/test/clusterbench/it/tomcat/AverageSystemLoadServletTomcatIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters