Skip to content

Commit a5bddc3

Browse files
author
Alexander Furer
committed
test fixes
1 parent 0071d63 commit a5bddc3

File tree

1 file changed

+6
-6
lines changed
  • grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc

1 file changed

+6
-6
lines changed

grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc/DemoAppTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.grpc.health.v1.HealthCheckRequest;
99
import io.grpc.health.v1.HealthCheckResponse;
1010
import io.grpc.health.v1.HealthGrpc;
11-
import io.grpc.protobuf.services.ProtoReflectionService;
1211
import io.grpc.reflection.v1alpha.ServerReflectionGrpc;
1312
import io.grpc.reflection.v1alpha.ServerReflectionRequest;
1413
import io.grpc.reflection.v1alpha.ServerReflectionResponse;
@@ -22,19 +21,18 @@
2221
import org.mockito.Mockito;
2322
import org.springframework.beans.factory.annotation.Autowired;
2423
import org.springframework.beans.factory.annotation.Qualifier;
25-
import org.springframework.beans.factory.annotation.Value;
26-
2724
import org.springframework.boot.test.context.SpringBootTest;
2825
import org.springframework.boot.test.rule.OutputCapture;
2926
import org.springframework.boot.test.web.client.TestRestTemplate;
3027
import org.springframework.http.HttpStatus;
3128
import org.springframework.http.ResponseEntity;
3229
import org.springframework.test.context.junit4.SpringRunner;
3330

34-
import java.net.URI;
3531
import java.util.ArrayList;
3632
import java.util.List;
33+
import java.util.concurrent.CountDownLatch;
3734
import java.util.concurrent.ExecutionException;
35+
import java.util.concurrent.TimeUnit;
3836

3937
import static org.hamcrest.CoreMatchers.containsString;
4038
import static org.hamcrest.CoreMatchers.not;
@@ -106,6 +104,7 @@ public void testDefaultConfigurer(){
106104
public void testReflection() throws InterruptedException {
107105
List<String> discoveredServiceNames = new ArrayList<>();
108106
ServerReflectionRequest request = ServerReflectionRequest.newBuilder().setListServices("services").setHost("localhost").build();
107+
CountDownLatch latch = new CountDownLatch(1);
109108
ServerReflectionGrpc.newStub(channel).serverReflectionInfo(new StreamObserver<ServerReflectionResponse>() {
110109
@Override
111110
public void onNext(ServerReflectionResponse value) {
@@ -122,10 +121,11 @@ public void onError(Throwable t) {
122121

123122
@Override
124123
public void onCompleted() {
125-
124+
latch.countDown();
126125
}
127126
}).onNext(request);
128-
Thread.sleep(1000l);
127+
128+
latch.await(1, TimeUnit.SECONDS);
129129
assertFalse(discoveredServiceNames.isEmpty());
130130
}
131131

0 commit comments

Comments
 (0)