diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java index 5f26250..35ceb72 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java @@ -10,14 +10,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; import org.springframework.grpc.sample.proto.SimpleGrpc; import org.springframework.test.annotation.DirtiesContext; +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; + @SpringBootTest(properties = { "grpc.client.test.address=static://localhost:9090", "grpc.client.test.negotiationType=plaintext", "debug=true" }) -@Disabled("Until client is autoconfigured") public class GrpcServerApplicationTests { private static Log log = LogFactory.getLog(GrpcServerApplicationTests.class); @@ -42,4 +46,13 @@ public class GrpcServerApplicationTests { assertEquals("Hello ==> Alien", response.getMessage()); } + @TestConfiguration + static class ExtraConfiguration { + @Bean + SimpleGrpc.SimpleBlockingStub stub() { + var channel = Grpc.newChannelBuilderForAddress("0.0.0.0", 9090, InsecureChannelCredentials.create()) + .build(); + return SimpleGrpc.newBlockingStub(channel); + } + } } diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/YetAnotherApplicationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/YetAnotherApplicationTests.java index 95e8e2f..9032d22 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/YetAnotherApplicationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/YetAnotherApplicationTests.java @@ -32,6 +32,7 @@ class YetAnotherApplicationTests { @TestConfiguration static class ExtraConfiguration { + } } diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/package-info.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/package-info.java deleted file mode 100644 index d937b20..0000000 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Grpc server events. - */ - -package org.springframework.grpc.server.event; diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycle.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java similarity index 97% rename from spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycle.java rename to spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java index ae3a94b..7ea0f4a 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycle.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycle.java @@ -16,7 +16,7 @@ * Partial copy from net.devh:grpc-spring-boot-starter. */ -package org.springframework.grpc.server.event; +package org.springframework.grpc.server.lifecycle; import static java.util.Objects.requireNonNull; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -113,7 +113,7 @@ public class GrpcServerLifecycle implements SmartLifecycle { this.server = localServer.start(); final String address = this.server.getListenSockets().toString(); final int port = this.server.getPort(); - logger.info("gRPC Server started, listening on address: " + address + ", port: " + port); + logger.info("gRPC Server started, listening on address: " + this.server.getListenSockets()); this.eventPublisher.publishEvent(new GrpcServerStartedEvent(this, localServer, address, port)); // Prevent the JVM from shutting down while the server is running diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycleEvent.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycleEvent.java similarity index 97% rename from spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycleEvent.java rename to spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycleEvent.java index eaef1e9..2f91060 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerLifecycleEvent.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerLifecycleEvent.java @@ -16,7 +16,7 @@ * Partial copy from net.devh:grpc-spring-boot-starter. */ -package org.springframework.grpc.server.event; +package org.springframework.grpc.server.lifecycle; import static java.util.Objects.requireNonNull; diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerShutdownEvent.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerShutdownEvent.java similarity index 97% rename from spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerShutdownEvent.java rename to spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerShutdownEvent.java index d7f5b44..5521429 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerShutdownEvent.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerShutdownEvent.java @@ -16,7 +16,7 @@ * Partial copy from net.devh:grpc-spring-boot-starter. */ -package org.springframework.grpc.server.event; +package org.springframework.grpc.server.lifecycle; import java.time.Clock; diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerStartedEvent.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerStartedEvent.java similarity index 98% rename from spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerStartedEvent.java rename to spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerStartedEvent.java index 3d28b5c..9cbe8d2 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerStartedEvent.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerStartedEvent.java @@ -16,7 +16,7 @@ * Partial copy from net.devh:grpc-spring-boot-starter. */ -package org.springframework.grpc.server.event; +package org.springframework.grpc.server.lifecycle; import static java.util.Objects.requireNonNull; diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerTerminatedEvent.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerTerminatedEvent.java similarity index 97% rename from spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerTerminatedEvent.java rename to spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerTerminatedEvent.java index 2d4f870..1b9b6dc 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/event/GrpcServerTerminatedEvent.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/GrpcServerTerminatedEvent.java @@ -15,7 +15,7 @@ * * Partial copy from net.devh:grpc-spring-boot-starter. */ -package org.springframework.grpc.server.event; +package org.springframework.grpc.server.lifecycle; import java.time.Clock; diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/package-info.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/package-info.java new file mode 100644 index 0000000..846b49c --- /dev/null +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/lifecycle/package-info.java @@ -0,0 +1,5 @@ +/** + * Grpc server events. + */ + +package org.springframework.grpc.server.lifecycle; diff --git a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServiceAutoConfiguration.java b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServiceAutoConfiguration.java index f5b4fb4..aa938da 100644 --- a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServiceAutoConfiguration.java +++ b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServiceAutoConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.grpc.server.GrpcServerFactory; -import org.springframework.grpc.server.event.GrpcServerLifecycle; +import org.springframework.grpc.server.lifecycle.GrpcServerLifecycle; import io.grpc.BindableService; import io.grpc.ServerServiceDefinition;