-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
180 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...tlp/common/src/test/java/io/opentelemetry/exporter/otlp/internal/retry/RetryUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.exporter.otlp.internal.retry; | ||
|
||
import static org.assertj.core.api.Assertions.as; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import io.opentelemetry.exporter.otlp.internal.grpc.DefaultGrpcExporterBuilder; | ||
import io.opentelemetry.exporter.otlp.internal.grpc.OkHttpGrpcExporterBuilder; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import org.assertj.core.api.InstanceOfAssertFactories; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class RetryUtilTest { | ||
|
||
@Test | ||
void setRetryPolicyOnDelegate_DefaultGrpcExporterBuilder() throws URISyntaxException { | ||
RetryPolicy retryPolicy = RetryPolicy.getDefault(); | ||
DefaultGrpcExporterBuilder<?> builder = | ||
new DefaultGrpcExporterBuilder<>( | ||
"test", unused -> null, 0, new URI("http://localhost"), "test"); | ||
|
||
RetryUtil.setRetryPolicyOnDelegate(new WithDelegate(builder), retryPolicy); | ||
|
||
assertThat(builder) | ||
.extracting("retryPolicy", as(InstanceOfAssertFactories.type(RetryPolicy.class))) | ||
.isEqualTo(retryPolicy); | ||
} | ||
|
||
@Test | ||
void setRetryPolicyOnDelegate_OkHttpGrpcExporterBuilder() throws URISyntaxException { | ||
RetryPolicy retryPolicy = RetryPolicy.getDefault(); | ||
OkHttpGrpcExporterBuilder<?> builder = | ||
new OkHttpGrpcExporterBuilder<>("test", "/test", 0, new URI("http://localhost")); | ||
|
||
RetryUtil.setRetryPolicyOnDelegate(new WithDelegate(builder), retryPolicy); | ||
|
||
assertThat(builder) | ||
.extracting("retryPolicy", as(InstanceOfAssertFactories.type(RetryPolicy.class))) | ||
.isEqualTo(retryPolicy); | ||
} | ||
|
||
@Test | ||
void setRetryPolicyOnDelegate_InvalidUsage() { | ||
assertThatThrownBy( | ||
() -> RetryUtil.setRetryPolicyOnDelegate(new Object(), RetryPolicy.getDefault())) | ||
.hasMessageContaining("Unable to access delegate reflectively"); | ||
assertThatThrownBy( | ||
() -> | ||
RetryUtil.setRetryPolicyOnDelegate( | ||
new WithDelegate(new Object()), RetryPolicy.getDefault())) | ||
.hasMessageContaining( | ||
"delegate field is not type DefaultGrpcExporterBuilder or OkHttpGrpcExporterBuilder"); | ||
} | ||
|
||
@SuppressWarnings({"UnusedVariable", "FieldCanBeLocal"}) | ||
private static class WithDelegate { | ||
private final Object delegate; | ||
|
||
private WithDelegate(Object delegate) { | ||
this.delegate = delegate; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.