-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
11 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
42 changes: 42 additions & 0 deletions
42
...c/test/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboHeadersGetterTest.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,42 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.apachedubbo.v2_7; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.Iterator; | ||
import org.apache.dubbo.common.URL; | ||
import org.apache.dubbo.rpc.RpcContext; | ||
import org.apache.dubbo.rpc.RpcInvocation; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class DubboHeadersGetterTest { | ||
|
||
@Mock RpcContext context; | ||
|
||
@Test | ||
@SuppressWarnings("deprecation") // deprecation for RpcInvocation() | ||
void testKeys() { | ||
when(context.getUrl()).thenReturn(new URL("http", "localhost", 1)); | ||
when(context.getRemoteAddress()).thenReturn(new InetSocketAddress(1)); | ||
when(context.getLocalAddress()).thenReturn(new InetSocketAddress(1)); | ||
|
||
RpcInvocation invocation = new RpcInvocation(); | ||
invocation.setAttachment("key", "value"); | ||
DubboRequest request = DubboRequest.create(invocation, context); | ||
|
||
Iterator<String> iterator = DubboHeadersGetter.INSTANCE.keys(request).iterator(); | ||
assertThat(iterator.hasNext()).isTrue(); | ||
assertThat(iterator.next()).isEqualTo("key"); | ||
assertThat(iterator.hasNext()).isFalse(); | ||
} | ||
} |
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