Skip to content

Commit

Permalink
Merge pull request #5 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Jan 17, 2024
2 parents 5c1b259 + 803ad7a commit 3116df9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down
2 changes: 1 addition & 1 deletion README_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,7 +111,7 @@ private static List<HttpPartFormatter> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -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<String>, List<String>, List<ReportPortalMessage>> logs = runChainComplexMessageCapture(requestSpecification,
createBasicResponse(null)
Expand All @@ -569,17 +568,17 @@ public void test_logger_text_and_image_multipart() throws IOException {
}

public static Iterable<Object[]> 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 }
);
}

Expand Down

0 comments on commit 3116df9

Please sign in to comment.