@Override public final T fallbackHandlerRegistry(HandlerRegistry registry) { if (registry != null) { this.fallbackRegistry = registry; } else { this.fallbackRegistry = DEFAULT_FALLBACK_REGISTRY; } return thisT(); }
@Test public void handlerRegistryPriorities() throws Exception { fallbackRegistry = mock(HandlerRegistry.class); builder.addService( ServerServiceDefinition.builder(new ServiceDescriptor("Waiter", METHOD)) .addMethod(METHOD, callHandler).build()); transportServer = new SimpleServer(); createAndStartServer(); ServerTransportListener transportListener = transportServer.registerNewServerTransport(new SimpleServerTransport()); transportListener.transportReady(Attributes.EMPTY); Metadata requestHeaders = new Metadata(); StatsTraceContext statsTraceCtx = StatsTraceContext.newServerContext(streamTracerFactories, "Waiter/serve", requestHeaders); when(stream.statsTraceContext()).thenReturn(statsTraceCtx); // This call will be handled by callHandler from the internal registry transportListener.streamCreated(stream, "Waiter/serve", requestHeaders); assertEquals(1, executor.runDueTasks()); verify(callHandler).startCall(Matchers.<ServerCall<String, Integer>>anyObject(), Matchers.<Metadata>anyObject()); // This call will be handled by the fallbackRegistry because it's not registred in the internal // registry. transportListener.streamCreated(stream, "Service1/Method2", requestHeaders); assertEquals(1, executor.runDueTasks()); verify(fallbackRegistry).lookupMethod("Service1/Method2", AUTHORITY); verifyNoMoreInteractions(callHandler); verifyNoMoreInteractions(fallbackRegistry); }
@Override public DropwizardServerBuilder fallbackHandlerRegistry(@Nullable final HandlerRegistry fallbackRegistry) { origin.fallbackHandlerRegistry(fallbackRegistry); return this; }