-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Introduce custom NameResolver.Args #11669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
707e1da
Introduce NameResolver.Args extensions.
jdcormie 54e089b
Introduce NameResolver.Args extensions.
jdcormie f2a7b81
Merge remote-tracking branch 'origin/multi-user-nrp' into multi-user-nrp
jdcormie ce2930f
Introduce NameResolver.Args extensions.
jdcormie 2f30771
fixes
jdcormie 1a21575
understand
jdcormie 07cb7c2
appropriate
jdcormie 169e993
meaning
jdcormie a5c714a
javadoc
jdcormie 1874264
polish
jdcormie 2fbfc89
value/key
jdcormie a4b6f07
rename
jdcormie 7f48a33
Address code review comments.
jdcormie 76d1742
javadoc
jdcormie a216397
Copy forward AttributesTest.java
jdcormie 29d01c7
Beef up unit tests
jdcormie 9fbbc6e
Merge branch 'master' into multi-user-nrp
jdcormie 1a79734
Merge branch 'grpc:master' into multi-user-nrp
jdcormie 9ff19f7
Rename get/setExtension to be like CallOptions#get/setOption
jdcormie 3124a91
Delete Extensions nested class completely.
jdcormie 7653270
A few more extended -> custom renames
jdcormie 5d4a24d
one more extension rename
jdcormie 38946a4
Disallow null arg keys/values just like CallOptions does.
jdcormie 2575fb1
returns
jdcormie e7fbb5c
extension
jdcormie 2a97cb7
Merge branch `grpc:master` into multi-user-nrp
jdcormie 0857a68
checkNotNull
jdcormie 079a548
Merge branch 'multi-user-nrp' of https://github.com/jdcormie/grpc-jav…
jdcormie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy forward AttributesTest.java
- Loading branch information
commit a216397a03c2c1513d66ca3b07f26385f04bc0ea
There are no files selected for viewing
This file contains hidden or 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
67 changes: 67 additions & 0 deletions
67
api/src/test/java/io/grpc/NameResolverArgsExtensionsTest.java
This file contains hidden or 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,67 @@ | ||
/* | ||
* Copyright 2024 The gRPC 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.grpc; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static org.junit.Assert.assertSame; | ||
|
||
import io.grpc.NameResolver.Args; | ||
import io.grpc.NameResolver.Args.Extensions; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** Unit tests for {@link NameResolver.Args.Extensions}. */ | ||
@RunWith(JUnit4.class) | ||
public class NameResolverArgsExtensionsTest { | ||
private static final Args.Key<String> YOLO_KEY = Args.Key.create("yolo"); | ||
|
||
@Test | ||
public void buildExtensions() { | ||
Extensions attrs = Extensions.newBuilder().set(YOLO_KEY, "To be, or not to be?").build(); | ||
assertSame("To be, or not to be?", attrs.get(YOLO_KEY)); | ||
assertThat(attrs.keysForTest()).hasSize(1); | ||
} | ||
|
||
@Test | ||
public void duplicates() { | ||
Extensions attrs = | ||
Extensions.newBuilder() | ||
.set(YOLO_KEY, "To be?") | ||
.set(YOLO_KEY, "Or not to be?") | ||
.set(Args.Key.create("yolo"), "I'm not a duplicate") | ||
.build(); | ||
assertThat(attrs.get(YOLO_KEY)).isEqualTo("Or not to be?"); | ||
assertThat(attrs.keysForTest()).hasSize(2); | ||
} | ||
|
||
@Test | ||
public void toBuilder() { | ||
Extensions attrs = | ||
Extensions.newBuilder().set(YOLO_KEY, "To be?").build().toBuilder() | ||
.set(YOLO_KEY, "Or not to be?") | ||
.set(Args.Key.create("yolo"), "I'm not a duplicate") | ||
.build(); | ||
assertThat(attrs.get(YOLO_KEY)).isEqualTo("Or not to be?"); | ||
assertThat(attrs.keysForTest()).hasSize(2); | ||
} | ||
|
||
@Test | ||
public void empty() { | ||
assertThat(Extensions.EMPTY.keysForTest()).isEmpty(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.