forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for duplicate services - mutiny and plain; from quarkusio#44326
- Loading branch information
Showing
17 changed files
with
317 additions
and
12 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
35 changes: 35 additions & 0 deletions
35
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/Duplicate2ServiceTest.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,35 @@ | ||
package io.quarkus.grpc.server; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.quarkus.grpc.server.dups.Poke2Service; | ||
import io.quarkus.grpc.server.dups.PokeService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
// 2 same implBase services | ||
@Disabled("Currently not detected at build time") | ||
public class Duplicate2ServiceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Poke2Service.class, PokeService.class) | ||
.addPackage(Poke.class.getPackage())) | ||
.assertException(t -> { | ||
Assertions.assertTrue(t.getMessage().contains("Duplicated gRPC service")); | ||
}); | ||
|
||
@Test | ||
void testDuplicateService() { | ||
fail("Should not be called"); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...sions/grpc/deployment/src/test/java/io/quarkus/grpc/server/DuplicateBeansServiceTest.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,34 @@ | ||
package io.quarkus.grpc.server; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.quarkus.grpc.server.dups.MutinyPoke2Service; | ||
import io.quarkus.grpc.server.dups.MutinyPokeService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
// 2 same beans services | ||
public class DuplicateBeansServiceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MutinyPokeService.class, MutinyPoke2Service.class) | ||
.addPackage(Poke.class.getPackage())) | ||
.assertException(t -> { | ||
// fails with CDI / Arc | ||
Assertions.assertTrue(t.getMessage().contains("Ambiguous dependencies")); | ||
}); | ||
|
||
@Test | ||
void testDuplicateService() { | ||
fail("Should not be called"); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/DuplicateServiceTest.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,33 @@ | ||
package io.quarkus.grpc.server; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.quarkus.grpc.server.dups.MutinyPokeService; | ||
import io.quarkus.grpc.server.dups.PokeService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
// 1 implBase + 1 bean | ||
public class DuplicateServiceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MutinyPokeService.class, PokeService.class) | ||
.addPackage(Poke.class.getPackage())) | ||
.assertException(t -> { | ||
Assertions.assertTrue(t.getMessage().contains("Duplicated gRPC service")); | ||
}); | ||
|
||
@Test | ||
void testDuplicateService() { | ||
fail("Should not be called"); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/MDuplicate2ServiceTest.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,35 @@ | ||
package io.quarkus.grpc.server; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.quarkus.grpc.server.dups.MPoke2Service; | ||
import io.quarkus.grpc.server.dups.MPokeService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
// 2 same mutinyImplBase services | ||
@Disabled("Currently not detected at build time") | ||
public class MDuplicate2ServiceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MPoke2Service.class, MPokeService.class) | ||
.addPackage(Poke.class.getPackage())) | ||
.assertException(t -> { | ||
Assertions.assertTrue(t.getMessage().contains("Duplicated gRPC service")); | ||
}); | ||
|
||
@Test | ||
void testDuplicateService() { | ||
fail("Should not be called"); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...sions/grpc/deployment/src/test/java/io/quarkus/grpc/server/VertxDuplicateServiceTest.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,34 @@ | ||
package io.quarkus.grpc.server; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.quarkus.grpc.server.dups.MutinyPokeService; | ||
import io.quarkus.grpc.server.dups.PokeService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
// 1 implBase + 1 bean -- with Vert.x based gRPC | ||
public class VertxDuplicateServiceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MutinyPokeService.class, PokeService.class) | ||
.addPackage(Poke.class.getPackage())) | ||
.overrideConfigKey("quarkus.grpc.server.use-separate-server", "false") | ||
.assertException(t -> { | ||
Assertions.assertTrue(t.getMessage().contains("Duplicated gRPC service")); | ||
}); | ||
|
||
@Test | ||
void testDuplicateService() { | ||
fail("Should not be called"); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/MPoke2Service.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,15 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.MutinyPokeGrpc; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class MPoke2Service extends MutinyPokeGrpc.PokeImplBase { | ||
@Override | ||
public Uni<PokeReply> poke(PokeRequest request) { | ||
return super.poke(request); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/MPokeService.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,15 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.MutinyPokeGrpc; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class MPokeService extends MutinyPokeGrpc.PokeImplBase { | ||
@Override | ||
public Uni<PokeReply> poke(PokeRequest request) { | ||
return super.poke(request); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/Mutiny2PokeService.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,15 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class Mutiny2PokeService implements Poke { | ||
@Override | ||
public Uni<PokeReply> poke(PokeRequest request) { | ||
return null; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/MutinyPoke2Service.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,15 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class MutinyPoke2Service implements Poke { | ||
@Override | ||
public Uni<PokeReply> poke(PokeRequest request) { | ||
return null; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/MutinyPokeService.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,15 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.Poke; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class MutinyPokeService implements Poke { | ||
@Override | ||
public Uni<PokeReply> poke(PokeRequest request) { | ||
return null; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/Poke2Service.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,14 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.PokeGrpc; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.grpc.stub.StreamObserver; | ||
import io.quarkus.grpc.GrpcService; | ||
|
||
@GrpcService | ||
public class Poke2Service extends PokeGrpc.PokeImplBase { | ||
@Override | ||
public void poke(PokeRequest request, StreamObserver<PokeReply> responseObserver) { | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/dups/PokeService.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,14 @@ | ||
package io.quarkus.grpc.server.dups; | ||
|
||
import io.grpc.examples.dups.PokeGrpc; | ||
import io.grpc.examples.dups.PokeReply; | ||
import io.grpc.examples.dups.PokeRequest; | ||
import io.grpc.stub.StreamObserver; | ||
import io.quarkus.grpc.GrpcService; | ||
|
||
@GrpcService | ||
public class PokeService extends PokeGrpc.PokeImplBase { | ||
@Override | ||
public void poke(PokeRequest request, StreamObserver<PokeReply> responseObserver) { | ||
} | ||
} |
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,20 @@ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.dups"; | ||
option java_outer_classname = "DupsFooProto"; | ||
option objc_class_prefix = "DF"; | ||
|
||
package dups; | ||
|
||
service Poke { | ||
rpc poke (PokeRequest) returns (PokeReply) {} | ||
} | ||
|
||
message PokeRequest { | ||
string name = 1; | ||
} | ||
|
||
message PokeReply { | ||
string message = 1; | ||
} |
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
Oops, something went wrong.