Skip to content

Commit

Permalink
Merge pull request #1682 from yuppie-flu/update-spring-to-6.2
Browse files Browse the repository at this point in the history
Update Spring to 6.2
  • Loading branch information
fatroom authored Jan 7, 2025
2 parents 83e2365 + 7875c52 commit e59f2e9
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<spring.version>6.1.14</spring.version>
<spring.version>6.2.1</spring.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.annotation.Nonnull;
import java.net.URI;
import java.util.Map;

@AllArgsConstructor
final class HttpOutputMessageClientHttpRequestAdapter implements ClientHttpRequest {
Expand All @@ -22,6 +23,7 @@ public ClientHttpResponse execute() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public HttpMethod getMethod() {
throw new UnsupportedOperationException();
Expand All @@ -33,4 +35,9 @@ public URI getURI() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public Map<String, Object> getAttributes() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ void getURI() {
assertThrows(UnsupportedOperationException.class, unit::getURI);
}

@Test
void getAttributes() {
assertThrows(UnsupportedOperationException.class, unit::getAttributes);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import org.apache.hc.core5.http.HttpEntityContainer;
import org.apache.hc.core5.http.HttpResponse;
import org.springframework.http.HttpHeaders;
import org.springframework.http.client.AbstractClientHttpResponse;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.client.ClientHttpResponse;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -17,7 +18,7 @@
import static org.zalando.riptide.httpclient.EmptyInputStream.EMPTY;

@Slf4j
final class ApacheClientHttpResponse extends AbstractClientHttpResponse {
final class ApacheClientHttpResponse implements ClientHttpResponse {

private final HttpHeaders headers = new HttpHeaders();
private final HttpResponse response;
Expand Down Expand Up @@ -48,9 +49,10 @@ private static InputStream getBody(final HttpResponse response) throws IOExcepti
});
}

@Nonnull
@Override
public int getRawStatusCode() {
return response.getCode();
public HttpStatusCode getStatusCode() {
return HttpStatusCode.valueOf(response.getCode());
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Optional;

@AllArgsConstructor
Expand Down Expand Up @@ -46,6 +47,12 @@ public URI getURI() {
}
}

@Nonnull
@Override
public Map<String, Object> getAttributes() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public HttpHeaders getHeaders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -50,6 +51,12 @@ public URI getURI() {
}
}

@Nonnull
@Override
public Map<String, Object> getAttributes() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public HttpHeaders getHeaders() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.zalando.riptide.httpclient;

import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
import org.junit.jupiter.api.Test;
import org.springframework.http.client.ClientHttpRequest;

import java.net.URISyntaxException;

Expand All @@ -20,4 +23,13 @@ void shouldThrowIllegalArgumentException() throws URISyntaxException {
assertThrows(IllegalArgumentException.class, request::getURI);
}

@Test
void shouldNotSupportGetAttributes() {
final HttpClient client = mock(HttpClient.class);
final HttpPost request = new HttpPost("https://example.org");

final ClientHttpRequest unit = new BufferingApacheClientHttpRequest(client, request);

assertThrows(UnsupportedOperationException.class, unit::getAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ void shouldThrowIllegalArgumentException() throws URISyntaxException {
assertThrows(IllegalArgumentException.class, request::getURI);
}

@Test
void shouldNotSupportGetAttributes() {
final HttpClient client = mock(HttpClient.class);
final HttpPost request = new HttpPost("https://example.org");

final ClientHttpRequest unit = new StreamingApacheClientHttpRequest(client, request);

assertThrows(UnsupportedOperationException.class, unit::getAttributes);
}

}

0 comments on commit e59f2e9

Please sign in to comment.