Skip to content

Commit

Permalink
Fixed Armenia related test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
reta committed Jan 4, 2024
1 parent ad7878b commit f7d2001
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions module/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2023 The OpenZipkin Authors
Copyright 2016-2024 The OpenZipkin Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -96,7 +96,7 @@

<dependency>
<groupId>${armeria.groupId}</groupId>
<artifactId>armeria-junit4</artifactId>
<artifactId>armeria-junit5</artifactId>
<version>${armeria.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -17,6 +17,7 @@
import com.linecorp.armeria.client.HttpClient;
import com.linecorp.armeria.client.SimpleDecoratingHttpClient;
import com.linecorp.armeria.common.AggregatedHttpRequest;
import com.linecorp.armeria.common.AggregationOptions;
import com.linecorp.armeria.common.HttpData;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpRequest;
Expand Down Expand Up @@ -84,11 +85,13 @@ static Function<HttpClient, HttpClient> newDecorator(String region,
@Override public HttpResponse execute(ClientRequestContext ctx, HttpRequest req) {
// We aggregate the request body with pooled objects because signing implies reading it before
// sending it to Elasticsearch.
return HttpResponse.from(
req.aggregateWithPooledObjects(ctx.eventLoop(), ctx.alloc()).thenApply(aggReg -> {
return HttpResponse.of(
req.aggregate(AggregationOptions.usePooledObjects(ctx.alloc())).thenApply(aggReg -> {
try {
AggregatedHttpRequest signed = sign(ctx, aggReg);
return unwrap().execute(ctx, signed.toHttpRequest());
final HttpRequest httpRequest = signed.toHttpRequest();
ctx.updateRequest(httpRequest);
return unwrap().execute(ctx, httpRequest);
} catch (Exception e) {
return HttpResponse.ofFailure(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -27,14 +27,15 @@
import com.linecorp.armeria.common.RequestHeaders;
import com.linecorp.armeria.common.SessionProtocol;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.testing.junit4.server.ServerRule;
import com.linecorp.armeria.testing.junit5.server.ServerExtension;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.ClassRule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -48,9 +49,9 @@ class AWSSignatureVersion4Test {
static final AtomicReference<AggregatedHttpResponse> MOCK_RESPONSE =
new AtomicReference<>();

@ClassRule public static ServerRule server = new ServerRule() {
@RegisterExtension static ServerExtension server = new ServerExtension() {
@Override protected void configure(ServerBuilder sb) {
sb.serviceUnder("/", (ctx, req) -> HttpResponse.from(
sb.serviceUnder("/", (ctx, req) -> HttpResponse.of(
req.aggregate().thenApply(agg -> {
CAPTURED_REQUEST.set(agg);
return MOCK_RESPONSE.get().toHttpResponse();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -21,11 +21,12 @@
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.armeria.common.MediaType;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.testing.junit4.server.ServerRule;
import com.linecorp.armeria.testing.junit5.server.ServerExtension;

import java.util.concurrent.atomic.AtomicReference;
import org.junit.ClassRule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static com.linecorp.armeria.common.SessionProtocol.HTTP;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -38,9 +39,9 @@ class ElasticsearchDomainEndpointTest {
static final AtomicReference<AggregatedHttpResponse> MOCK_RESPONSE =
new AtomicReference<>();

@ClassRule public static ServerRule server = new ServerRule() {
@RegisterExtension static ServerExtension server = new ServerExtension() {
@Override protected void configure(ServerBuilder sb) {
sb.serviceUnder("/", (ctx, req) -> HttpResponse.from(
sb.serviceUnder("/", (ctx, req) -> HttpResponse.of(
req.aggregate().thenApply(agg -> {
CAPTURED_REQUEST.set(agg);
return MOCK_RESPONSE.get().toHttpResponse();
Expand Down

0 comments on commit f7d2001

Please sign in to comment.