From 5d10ba8657a9b7f1d9f5d442c3a3ba10d1665c31 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 4 Aug 2023 18:04:15 +0300 Subject: [PATCH 1/4] Maven links update --- README.md | 2 +- README_TEMPLATE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5771b1a..c8cbceb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Report Portal logger for OkHttp3 client -[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-okhttp3.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22logger-java-okhttp3%22) +[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-okhttp3.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/logger-java-okhttp3) [![CI Build](https://github.com/reportportal/logger-java-okhttp3/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/logger-java-okhttp3/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/reportportal/logger-java-okhttp3/branch/develop/graph/badge.svg?token=M2J13Z075Y)](https://codecov.io/gh/reportportal/logger-java-okhttp3) [![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/) diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index a8c73ce..98811c8 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -1,6 +1,6 @@ # Report Portal logger for OkHttp3 client -[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-okhttp3.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22logger-java-okhttp3%22) +[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-okhttp3.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/logger-java-okhttp3) [![CI Build](https://github.com/reportportal/logger-java-okhttp3/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/logger-java-okhttp3/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/reportportal/logger-java-okhttp3/branch/develop/graph/badge.svg?token=M2J13Z075Y)](https://codecov.io/gh/reportportal/logger-java-okhttp3) [![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/) From 871c01f91e77a66754e28ee400ea9e9c60f49e62 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 17 Jan 2024 14:09:10 +0300 Subject: [PATCH 2/4] Version update --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5e55562..ff8628a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=5.0.4-SNAPSHOT +version=5.1.0-SNAPSHOT description=Report Portal logger for OkHttp3 client junit5_version=5.6.3 junit5_runner_version=1.6.3 From d2469d6a6cb8567a868ac2e19ea209c5d8f30e40 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 17 Jan 2024 14:12:58 +0300 Subject: [PATCH 3/4] Dependency versions update --- CHANGELOG.md | 4 ++++ build.gradle | 7 +++---- .../reportportal/okhttp3/support/HttpEntityFactory.java | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff26121..6e16120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated on [5.2.0](https://github.com/reportportal/client-java/releases/tag/5.2.0), by @HardNorth +- `utils-java-formatting` library version updated on version [5.2.0](https://github.com/reportportal/utils-java-formatting/releases/tag/5.2.0), by @HardNorth +- OkHttp3 dependency marked as `implementation` to force users specify their own versions, by @HardNorth ## [5.0.3] ### Changed diff --git a/build.gradle b/build.gradle index b4e3b26..cf41c70 100644 --- a/build.gradle +++ b/build.gradle @@ -37,12 +37,11 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.1.22' + api 'com.epam.reportportal:client-java:5.2.0' api 'com.google.code.findbugs:jsr305:3.0.2' api 'com.epam.reportportal:commons-model:5.0.0' - api 'com.squareup.okhttp3:okhttp:4.10.0' - api 'com.epam.reportportal:utils-java-formatting:5.1.6' - implementation 'org.apache.httpcomponents:httpcore:4.4.15' + api 'com.epam.reportportal:utils-java-formatting:5.2.0' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2' diff --git a/src/main/java/com/epam/reportportal/okhttp3/support/HttpEntityFactory.java b/src/main/java/com/epam/reportportal/okhttp3/support/HttpEntityFactory.java index 9fee1b1..31683ad 100644 --- a/src/main/java/com/epam/reportportal/okhttp3/support/HttpEntityFactory.java +++ b/src/main/java/com/epam/reportportal/okhttp3/support/HttpEntityFactory.java @@ -24,9 +24,9 @@ import com.epam.reportportal.formatting.http.entities.Cookie; import com.epam.reportportal.formatting.http.entities.Header; import com.epam.reportportal.formatting.http.entities.Param; +import com.epam.reportportal.utils.http.ContentType; import okhttp3.*; import okio.Buffer; -import org.apache.http.entity.ContentType; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -111,7 +111,7 @@ private static List toParts(@Nonnull RequestBody body, return multipartBody.parts().stream().map(it -> { RequestBody partBody = it.body(); String partMimeType = ofNullable(partBody.contentType()).map(Object::toString) - .orElse(ContentType.APPLICATION_OCTET_STREAM.getMimeType()); + .orElse(ContentType.APPLICATION_OCTET_STREAM); BodyType bodyPartType = getBodyType(partMimeType, bodyTypeMap); HttpPartFormatter.Builder partBuilder; if (BodyType.TEXT == bodyPartType) { From 803ad7a62a8c55f3008aabe11191a3a462c38540 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 17 Jan 2024 14:16:29 +0300 Subject: [PATCH 4/4] Fix build --- ...rtPortalOkHttp3LoggingInterceptorTest.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/test/java/com/epam/reportportal/okhttp3/ReportPortalOkHttp3LoggingInterceptorTest.java b/src/test/java/com/epam/reportportal/okhttp3/ReportPortalOkHttp3LoggingInterceptorTest.java index b4b746c..61ff1c8 100644 --- a/src/test/java/com/epam/reportportal/okhttp3/ReportPortalOkHttp3LoggingInterceptorTest.java +++ b/src/test/java/com/epam/reportportal/okhttp3/ReportPortalOkHttp3LoggingInterceptorTest.java @@ -26,11 +26,10 @@ import com.epam.reportportal.service.ReportPortal; import com.epam.reportportal.service.step.StepReporter; import com.epam.reportportal.utils.files.Utils; +import com.epam.reportportal.utils.http.ContentType; import okhttp3.*; import okio.BufferedSink; import org.apache.commons.lang3.tuple.Triple; -import org.apache.http.HttpHeaders; -import org.apache.http.entity.ContentType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Test; @@ -67,7 +66,7 @@ public class ReportPortalOkHttp3LoggingInterceptorTest { private static final int STATUS_CODE = 201; private static final String EMPTY_REQUEST = "**>>> REQUEST**\n" + METHOD + " to " + URI; private static final String EMPTY_RESPONSE = "**<<< RESPONSE**\n" + STATUS_CODE; - private static final String HTTP_HEADER = HttpHeaders.CONTENT_TYPE; + private static final String HTTP_HEADER = "Content-Type"; private static final String HTTP_HEADER_VALUE = JSON_TYPE; private static Interceptor.Chain getChain(Request request, Response response) { @@ -387,7 +386,7 @@ public void test_logger_headers_and_cookies(String contentType) throws IOExcepti @Test public void test_logger_empty_image_body() throws IOException { - String mimeType = ContentType.IMAGE_JPEG.getMimeType(); + String mimeType = ContentType.IMAGE_JPEG; Request request = mockBasicRequest(mimeType); RequestBody requestBody = mock(RequestBody.class); when(request.body()).thenReturn(requestBody); @@ -450,7 +449,7 @@ public void test_logger_image_body(String mimeType) throws IOException { @Test public void test_logger_null_response() throws IOException { - String mimeType = ContentType.IMAGE_JPEG.getMimeType(); + String mimeType = ContentType.IMAGE_JPEG; Request request = mockBasicRequest(mimeType); when(request.headers()).thenReturn(new Headers.Builder().build()); when(request.body()).thenReturn(null); @@ -463,7 +462,7 @@ public void test_logger_null_response() throws IOException { @Test public void test_logger_empty_multipart() throws IOException { - String mimeType = ContentType.MULTIPART_FORM_DATA.getMimeType(); + String mimeType = ContentType.MULTIPART_FORM_DATA; Request requestSpecification = mockBasicRequest(mimeType, new Headers.Builder().build(), mock(MultipartBody.class) @@ -490,15 +489,15 @@ private MultipartBody.Builder getBinaryPart(String mimeType, String filePath) th private MultipartBody getBinaryBody(String mimeType, String filePath) throws IOException { return getBinaryPart(mimeType, filePath - ).setType(Objects.requireNonNull(MediaType.parse(ContentType.MULTIPART_FORM_DATA.getMimeType()))).build(); + ).setType(Objects.requireNonNull(MediaType.parse(ContentType.MULTIPART_FORM_DATA))).build(); } @Test public void test_logger_image_multipart() throws IOException { byte[] image = getResource(IMAGE); - String imageType = ContentType.IMAGE_JPEG.getMimeType(); - MultipartBody body = getBinaryBody(ContentType.IMAGE_JPEG.getMimeType(), IMAGE); - String mimeType = ContentType.MULTIPART_FORM_DATA.getMimeType(); + String imageType = ContentType.IMAGE_JPEG; + MultipartBody body = getBinaryBody(ContentType.IMAGE_JPEG, IMAGE); + String mimeType = ContentType.MULTIPART_FORM_DATA; Request request = mockBasicRequest(mimeType); when(request.body()).thenReturn(body); @@ -538,13 +537,13 @@ private MultipartBody getBinaryTextBody(String textType, String text, String bin @Test public void test_logger_text_and_image_multipart() throws IOException { byte[] image = getResource(IMAGE); - String requestType = ContentType.MULTIPART_FORM_DATA.getMimeType(); - String imageType = ContentType.IMAGE_JPEG.getMimeType(); - String textType = ContentType.TEXT_PLAIN.getMimeType(); + String requestType = ContentType.MULTIPART_FORM_DATA; + String imageType = ContentType.IMAGE_JPEG; + String textType = ContentType.TEXT_PLAIN; String message = "test_message"; Request requestSpecification = mockBasicRequest(requestType); - MultipartBody requestBody = getBinaryTextBody(textType, message, ContentType.IMAGE_JPEG.getMimeType(), IMAGE); + MultipartBody requestBody = getBinaryTextBody(textType, message, ContentType.IMAGE_JPEG, IMAGE); when(requestSpecification.body()).thenReturn(requestBody); Triple, List, List> logs = runChainComplexMessageCapture(requestSpecification, createBasicResponse(null) @@ -569,17 +568,17 @@ public void test_logger_text_and_image_multipart() throws IOException { } public static Iterable invalidContentTypes() { - return Arrays.asList(new Object[] { "", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), - ContentType.APPLICATION_OCTET_STREAM.getMimeType() }, - new Object[] { "*/*", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), "*/*" }, - new Object[] { "something invalid", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), - ContentType.APPLICATION_OCTET_STREAM.getMimeType() }, - new Object[] { "/", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), - ContentType.APPLICATION_OCTET_STREAM.getMimeType() }, - new Object[] { "#*'\\`%^!@/\"$;", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), - ContentType.APPLICATION_OCTET_STREAM.getMimeType() }, - new Object[] { "a/a;F#%235f\\=f324$%^&", ContentType.APPLICATION_OCTET_STREAM.getMimeType(), - ContentType.APPLICATION_OCTET_STREAM.getMimeType() } + return Arrays.asList(new Object[] { "", ContentType.APPLICATION_OCTET_STREAM, + ContentType.APPLICATION_OCTET_STREAM }, + new Object[] { "*/*", ContentType.APPLICATION_OCTET_STREAM, "*/*" }, + new Object[] { "something invalid", ContentType.APPLICATION_OCTET_STREAM, + ContentType.APPLICATION_OCTET_STREAM }, + new Object[] { "/", ContentType.APPLICATION_OCTET_STREAM, + ContentType.APPLICATION_OCTET_STREAM }, + new Object[] { "#*'\\`%^!@/\"$;", ContentType.APPLICATION_OCTET_STREAM, + ContentType.APPLICATION_OCTET_STREAM }, + new Object[] { "a/a;F#%235f\\=f324$%^&", ContentType.APPLICATION_OCTET_STREAM, + ContentType.APPLICATION_OCTET_STREAM } ); }