Skip to content

Commit 549748e

Browse files
therepanicdsyer
authored andcommitted
Add test for default target resolution in DefaultGrpcChannelFactoryTests
Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
1 parent 17256b3 commit 549748e

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2023-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.grpc.client;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.mockito.Mockito.mock;
21+
22+
import java.util.List;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
/**
27+
* Tests for {@link DefaultGrpcChannelFactory}.
28+
*
29+
* @author Andrey Litvitski
30+
*/
31+
class DefaultGrpcChannelFactoryTests {
32+
33+
@Test
34+
void defaultTargetResolvesToLocalhost() {
35+
var factory = new DefaultGrpcChannelFactory<>(List.of(), mock());
36+
assertThat(factory.targets).isSameAs(VirtualTargets.DEFAULT);
37+
assertThat(factory.targets.getTarget("default")).isEqualTo("localhost:9090");
38+
}
39+
40+
}

spring-grpc-core/src/test/java/org/springframework/grpc/client/GrpcChannelFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void defaultSupportsEverythingExceptInProcess() {
208208
assertThat(channelFactory.supports("static:127.0.0.1")).isTrue();
209209
assertThat(channelFactory.supports("in-process:foo")).isFalse();
210210
assertThat(channelFactory.supports("default")).isFalse();
211-
}
211+
}
212212

213213
@Test
214214
void nettySupportsEverythingExceptInProcess() {

0 commit comments

Comments
 (0)