Skip to content

Commit

Permalink
Upgrade to org.apache.httpcomponents.client5:httpclient5 - Tomcat mod…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Dec 6, 2024
1 parent ce64741 commit 7638d8f
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 170 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.test.clusterbench.it.shared;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Smoke test for {@link org.jboss.test.clusterbench.web.load.AverageSystemLoadServlet}.
*
* @author Radoslav Husar
*/
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public abstract class AbstractAverageSystemLoadServletIT {

@Test
public void test() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:8080/clusterbench/averagesystemload?milliseconds=1000&threads=4");

httpClient.execute(httpGet, response -> {
assertEquals(200, response.getCode());

String responseBody = EntityUtils.toString(response.getEntity());
assertEquals("DONE", responseBody);

return null;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.test.clusterbench.it.shared;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Optional;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @author Radoslav Husar
*/
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public abstract class AbstractHttpSessionServletIT {

@Test
public void test() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:8080/clusterbench/session");

httpClient.execute(httpGet, response -> {
assertEquals(200, response.getCode());

String responseBody = EntityUtils.toString(response.getEntity());
assertEquals("0", responseBody);

// Also ensure session is created
Optional<String> jsessionIdCookie = Arrays.stream(response.getHeaders("Set-Cookie")).map(Header::getValue).filter(cookie -> cookie.startsWith("JSESSIONID=")).findFirst();
assertTrue(jsessionIdCookie.isPresent());

return null;
});

httpClient.execute(httpGet, response -> {
assertEquals(200, response.getCode());

String responseBody = EntityUtils.toString(response.getEntity());
assertEquals("1", responseBody);

return null;
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @author Tommaso Borgato
* @author Radoslav Husar
/*
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.test.clusterbench.it.shared;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
53 changes: 21 additions & 32 deletions integration-tests/tomcat-10.1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,28 @@
</parent>

<artifactId>clusterbench-it-tomcat-10.1</artifactId>
<packaging>jar</packaging>

<name>ClusterBench ITs: Tomcat 10.1</name>

<properties>
<catalina.home>${project.build.directory}/apache-tomcat-${version.org.apache.tomcat}</catalina.home>
</properties>

<dependencies>
<!-- Needed by ARQ -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-tomcat-managed-10</artifactId>
<version>1.2.2.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.test</groupId>
<artifactId>clusterbench-ee10-web</artifactId>
<classifier>classes</classifier>
<artifactId>clusterbench-it-shares</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -79,48 +66,50 @@
</testResource>
</testResources>
<plugins>
<!-- Deploy built clusterbench.war -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-war</id>
<id>unpack-tomcat</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.test</groupId>
<artifactId>clusterbench-ee10-web</artifactId>
<type>war</type>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>${version.org.apache.tomcat}</version>
<type>zip</type>
<overWrite>true</overWrite>
<classifier>tomcat</classifier>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>**</includes>
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
</configuration>
</execution>
<execution>
<id>unpack-tomcat</id>
<id>copy-war</id>
<phase>generate-test-resources</phase>
<goals>
<goal>unpack</goal>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>${version.org.apache.tomcat}</version>
<type>zip</type>
<groupId>org.jboss.test</groupId>
<artifactId>clusterbench-ee10-web</artifactId>
<type>war</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>**</includes>
<classifier>tomcat</classifier>
<outputDirectory>${catalina.home}/webapps</outputDirectory>
<destFileName>clusterbench.war</destFileName>
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright The ClusterBench Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.test.clusterbench.it.tomcat;

import org.jboss.test.clusterbench.it.shared.AbstractAverageSystemLoadServletIT;

/**
* @author Radoslav Husar
*/
public class AverageSystemLoadServletIT extends AbstractAverageSystemLoadServletIT {
// Inherit.
}

This file was deleted.

Loading

0 comments on commit 7638d8f

Please sign in to comment.