From f8524a17b80a3830775257b68e14a692f2e96a93 Mon Sep 17 00:00:00 2001 From: yangg Date: Tue, 6 Jan 2015 10:35:03 -0800 Subject: [PATCH] Add package name to the method string. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83353207 --- .../stubby/MutableHandlerRegistryImpl.java | 1 - .../MutableHandlerRegistryImplTest.java | 32 +++++++++---------- .../testing/integration/TestServiceGrpc.java | 14 ++++---- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/google/net/stubby/MutableHandlerRegistryImpl.java b/core/src/main/java/com/google/net/stubby/MutableHandlerRegistryImpl.java index c67856db35..217b1c0c2f 100644 --- a/core/src/main/java/com/google/net/stubby/MutableHandlerRegistryImpl.java +++ b/core/src/main/java/com/google/net/stubby/MutableHandlerRegistryImpl.java @@ -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; } diff --git a/core/src/test/java/com/google/net/stubby/MutableHandlerRegistryImplTest.java b/core/src/test/java/com/google/net/stubby/MutableHandlerRegistryImplTest.java index 794ebb5079..98df01a4d3 100644 --- a/core/src/test/java/com/google/net/stubby/MutableHandlerRegistryImplTest.java +++ b/core/src/test/java/com/google/net/stubby/MutableHandlerRegistryImplTest.java @@ -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()); } diff --git a/integration-testing/src/main/java/com/google/net/stubby/testing/integration/TestServiceGrpc.java b/integration-testing/src/main/java/com/google/net/stubby/testing/integration/TestServiceGrpc.java index abdffb682a..c60cce2d86 100644 --- a/integration-testing/src/main/java/com/google/net/stubby/testing/integration/TestServiceGrpc.java +++ b/integration-testing/src/main/java/com/google/net/stubby/testing/integration/TestServiceGrpc.java @@ -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(