Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 118 additions & 68 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,140 +13,190 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>org.hobsoft</groupId>
<artifactId>hobsoft-parent</artifactId>
<version>0.4.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>org.hobsoft.spring</groupId>
<artifactId>spring-rest-template-logger</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.1.GEMMA</version>

<name>Spring RestTemplate Logger</name>
<description>Spring RestTemplate customizer to log HTTP traffic.</description>
<url>https://github.com/markhobson/rest-template-logger</url>
<inceptionYear>2017</inceptionYear>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:git@github.com:markhobson/rest-template-logger.git</connection>
<developerConnection>scm:git:git@github.com:markhobson/rest-template-logger.git</developerConnection>
<url>https://github.com/markhobson/rest-template-logger</url>
<tag>HEAD</tag>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/markhobson/rest-template-logger/issues</url>
</issueManagement>

<developers>
<developer>
<id>markhobson</id>
<name>Mark Hobson</name>
<email>markhobson@gmail.com</email>
<roles>
<role>Project Lead</role>
</roles>
<timezone>0</timezone>
</developer>
</developers>


<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.test.skip>true</maven.test.skip>
<nexus.url>https://nexus.gemma-atos.net:8443/repository</nexus.url>
</properties>

<distributionManagement>
<snapshotRepository>
<id>maven-snapshots</id>
<url>${nexus.url}/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>maven-releases</id>
<url>${nexus.url}/maven-releases/</url>
</repository>
</distributionManagement>

<build>

<pluginManagement>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.32.1</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
<recipe>org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2</recipe>
<recipe>org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration</recipe>
<recipe>org.openrewrite.hibernate.MigrateToHibernate63</recipe>
<recipe>org.openrewrite.hibernate.TypeAnnotationParameter</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-spring</artifactId>
<version>5.11.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-hibernate</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
</plugin>

</plugins>

</pluginManagement>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>


</build>


<profiles>
<profile>
<id>repos</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>maven-public</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>${nexus.url}/maven-public/</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>

<dependencyManagement>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.4.RELEASE</version>
<version>3.2.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.26.0</version>
<version>2.27.2</version>
</dependency>

<!-- ##### REWRITE BOM -->
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-recipe-bom</artifactId>
<version>2.11.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- ####REWRITE BOM -->
</dependencies>

</dependencyManagement>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public String formatRequest(HttpRequest request, byte[] body)
{
String formattedBody = formatBody(body, getCharset(request));

return String.format("Request: %s %s %s", request.getMethod(), request.getURI(), formattedBody);
return "Request: %s %s %s".formatted(request.getMethod(), request.getURI(), formattedBody);
}

@Override
public String formatResponse(ClientHttpResponse response) throws IOException
{
String formattedBody = formatBody(copyToByteArray(response.getBody()), getCharset(response));

return String.format("Response: %s %s", response.getStatusCode().value(), formattedBody);
return "Response: %s %s".formatted(response.getStatusCode().value(), formattedBody);
}

// ----------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import java.io.IOException;
import java.net.URI;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpResponse;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.parseMediaType;
Expand All @@ -45,7 +45,7 @@ public class DefaultLogFormatterTest
// JUnit methods
// ----------------------------------------------------------------------------------------------------------------

@Before
@BeforeEach
public void setUp()
{
formatter = new DefaultLogFormatter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
package org.hobsoft.spring.resttemplatelogger;

import org.apache.commons.logging.Log;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;

import static java.net.HttpURLConnection.HTTP_OK;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand All @@ -49,8 +49,8 @@ public class LoggingCustomizerIT
// fields
// ----------------------------------------------------------------------------------------------------------------

@Rule
public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort());
@RegisterExtension
private WireMockExtension wireMockRule = WireMockExtension.newInstance().options(options().dynamicPort()).build();

private Log log;

Expand All @@ -60,7 +60,7 @@ public class LoggingCustomizerIT
// JUnit methods
// ----------------------------------------------------------------------------------------------------------------

@Before
@BeforeEach
public void setUp()
{
log = mock(Log.class);
Expand All @@ -84,7 +84,7 @@ public void canLogRequest()

restTemplate.postForEntity("/hello", "world", String.class);

verify(log).debug(String.format("Request: POST http://localhost:%d/hello world", wireMockRule.port()));
verify(log).debug("Request: POST http://localhost:%d/hello world".formatted(wireMockRule.port()));
}

@Test
Expand Down
Loading