ProxyingDiscoveryService { @VisibleForTesting static String getActualRoot(HttpServletRequest request) throws InternalServerErrorException { String uri = request.getRequestURI(); int index = uri.indexOf("discovery/v1/apis"); if (index == -1) { logger.atSevere() .log("Could not compute discovery root from url: %s", request.getRequestURI()); throw new InternalServerErrorException("Internal Server Error"); } StringBuffer url = request.getRequestURL(); return url.substring(0, url.length() - (uri.length() - index)); }  @ApiMethod(ignored = AnnotationBoolean.TRUE) synchronized void initialize(DiscoveryProvider discoveryProvider); @ApiMethod( name = "apis.getRest", path = "apis/{api}/{version}/rest" ) RestDescription getRestDocument(HttpServletRequest request, @Named("api") String name,
      @Named("version") String version); @ApiMethod( name = "apis.getRpc", path = "apis/{api}/{version}/rpc" ) RpcDescription getRpcDocument(HttpServletRequest request, @Named("api") String name,
      @Named("version") String version); @ApiMethod( name = "apis.list", path = "apis" ) DirectoryList getApiList(HttpServletRequest request);  }
@Test public void getActualRoot_badRoot() throws Exception { try { ProxyingDiscoveryService.getActualRoot(createRequest("badroot")); fail("expected InternalServerErrorException"); } catch (InternalServerErrorException e) { } }