mirror of https://github.com/grpc/grpc-java.git
Add package name to the method string.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83353207
This commit is contained in:
parent
ee86ee41a0
commit
f8524a17b8
|
|
@ -57,7 +57,6 @@ public final class MutableHandlerRegistryImpl extends MutableHandlerRegistry {
|
|||
@Override
|
||||
@Nullable
|
||||
public Method lookupMethod(String methodName) {
|
||||
methodName = methodName.replace('.', '/');
|
||||
if (!methodName.startsWith("/")) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,20 +82,20 @@ public class MutableHandlerRegistryImplTest {
|
|||
@Test
|
||||
public void simpleLookup() {
|
||||
assertNull(registry.addService(basicServiceDefinition));
|
||||
Method method = registry.lookupMethod("/basic.flow");
|
||||
Method method = registry.lookupMethod("/basic/flow");
|
||||
assertSame(flowMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(basicServiceDefinition, method.getServiceDefinition());
|
||||
method = registry.lookupMethod("/basic.flow");
|
||||
method = registry.lookupMethod("/basic/flow");
|
||||
assertSame(flowMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(basicServiceDefinition, method.getServiceDefinition());
|
||||
method = registry.lookupMethod("/basic/flow");
|
||||
assertSame(flowMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(basicServiceDefinition, method.getServiceDefinition());
|
||||
|
||||
assertNull(registry.lookupMethod("basic.flow"));
|
||||
assertNull(registry.lookupMethod("/basic.basic"));
|
||||
assertNull(registry.lookupMethod("/flow.flow"));
|
||||
assertNull(registry.lookupMethod("/completely.random"));
|
||||
assertNull(registry.lookupMethod("basic/flow"));
|
||||
assertNull(registry.lookupMethod("/basic/basic"));
|
||||
assertNull(registry.lookupMethod("/flow/flow"));
|
||||
assertNull(registry.lookupMethod("/completely/random"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -103,13 +103,13 @@ public class MutableHandlerRegistryImplTest {
|
|||
assertNull(registry.addService(basicServiceDefinition));
|
||||
assertNull(registry.addService(multiServiceDefinition));
|
||||
|
||||
Method method = registry.lookupMethod("/basic.flow");
|
||||
Method method = registry.lookupMethod("/basic/flow");
|
||||
assertSame(flowMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(basicServiceDefinition, method.getServiceDefinition());
|
||||
method = registry.lookupMethod("/multi.couple");
|
||||
method = registry.lookupMethod("/multi/couple");
|
||||
assertSame(coupleMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(multiServiceDefinition, method.getServiceDefinition());
|
||||
method = registry.lookupMethod("/multi.few");
|
||||
method = registry.lookupMethod("/multi/few");
|
||||
assertSame(fewMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(multiServiceDefinition, method.getServiceDefinition());
|
||||
}
|
||||
|
|
@ -117,25 +117,25 @@ public class MutableHandlerRegistryImplTest {
|
|||
@Test
|
||||
public void removeAndLookup() {
|
||||
assertNull(registry.addService(multiServiceDefinition));
|
||||
assertNotNull(registry.lookupMethod("/multi.couple"));
|
||||
assertNotNull(registry.lookupMethod("/multi.few"));
|
||||
assertNotNull(registry.lookupMethod("/multi/couple"));
|
||||
assertNotNull(registry.lookupMethod("/multi/few"));
|
||||
assertTrue(registry.removeService(multiServiceDefinition));
|
||||
assertNull(registry.lookupMethod("/multi.couple"));
|
||||
assertNull(registry.lookupMethod("/multi.few"));
|
||||
assertNull(registry.lookupMethod("/multi/couple"));
|
||||
assertNull(registry.lookupMethod("/multi/few"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceAndLookup() {
|
||||
assertNull(registry.addService(basicServiceDefinition));
|
||||
assertNotNull(registry.lookupMethod("/basic.flow"));
|
||||
assertNotNull(registry.lookupMethod("/basic/flow"));
|
||||
ServerServiceDefinition replaceServiceDefinition = ServerServiceDefinition.builder("basic")
|
||||
.addMethod("another", requestMarshaller, responseMarshaller, handler).build();
|
||||
ServerMethodDefinition<?, ?> anotherMethodDefinition =
|
||||
replaceServiceDefinition.getMethods().get(0);
|
||||
assertSame(basicServiceDefinition, registry.addService(replaceServiceDefinition));
|
||||
|
||||
assertNull(registry.lookupMethod("/basic.flow"));
|
||||
Method method = registry.lookupMethod("/basic.another");
|
||||
assertNull(registry.lookupMethod("/basic/flow"));
|
||||
Method method = registry.lookupMethod("/basic/another");
|
||||
assertSame(anotherMethodDefinition, method.getMethodDefinition());
|
||||
assertSame(replaceServiceDefinition, method.getServiceDefinition());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ public class TestServiceGrpc {
|
|||
|
||||
private TestServiceServiceDescriptor() {
|
||||
emptyCall = createMethodDescriptor(
|
||||
"TestService", METHOD_EMPTY_CALL);
|
||||
"grpc.testing.TestService", METHOD_EMPTY_CALL);
|
||||
unaryCall = createMethodDescriptor(
|
||||
"TestService", METHOD_UNARY_CALL);
|
||||
"grpc.testing.TestService", METHOD_UNARY_CALL);
|
||||
streamingOutputCall = createMethodDescriptor(
|
||||
"TestService", METHOD_STREAMING_OUTPUT_CALL);
|
||||
"grpc.testing.TestService", METHOD_STREAMING_OUTPUT_CALL);
|
||||
streamingInputCall = createMethodDescriptor(
|
||||
"TestService", METHOD_STREAMING_INPUT_CALL);
|
||||
"grpc.testing.TestService", METHOD_STREAMING_INPUT_CALL);
|
||||
fullDuplexCall = createMethodDescriptor(
|
||||
"TestService", METHOD_FULL_DUPLEX_CALL);
|
||||
"grpc.testing.TestService", METHOD_FULL_DUPLEX_CALL);
|
||||
halfDuplexCall = createMethodDescriptor(
|
||||
"TestService", METHOD_HALF_DUPLEX_CALL);
|
||||
"grpc.testing.TestService", METHOD_HALF_DUPLEX_CALL);
|
||||
}
|
||||
|
||||
private TestServiceServiceDescriptor(
|
||||
|
|
@ -302,7 +302,7 @@ public class TestServiceGrpc {
|
|||
|
||||
public static com.google.net.stubby.ServerServiceDefinition bindService(
|
||||
final TestService serviceImpl) {
|
||||
return com.google.net.stubby.ServerServiceDefinition.builder("TestService")
|
||||
return com.google.net.stubby.ServerServiceDefinition.builder("grpc.testing.TestService")
|
||||
.addMethod(createMethodDefinition(
|
||||
METHOD_EMPTY_CALL,
|
||||
asyncUnaryRequestCall(
|
||||
|
|
|
|||
Loading…
Reference in New Issue