@Test public void reportsToStringWhenAuthorizationFails() throws Exception { try { new SecuredHost( new Host() { @Override public String toString() { return "hello, world!"; } @Override public boolean isHidden(final URI uri) { return true; } @Override public boolean authorized(final String user, final String pwd) { return false; } @Override public Resource fetch(final URI uri, final Range range, final Version version) { throw new UnsupportedOperationException(); } @Override public void close() { throw new UnsupportedOperationException(); } @Override public String syslog() { throw new UnsupportedOperationException(); } @Override public Stats stats() { throw new UnsupportedOperationException(); } }, HttpRequestMocker.toRequest( "GET / HTTP/1.1\nAuthorization: Basic dGVzdDp0ZXN0\n\n" ) ).fetch( URI.create("/test-request.html"), Range.ENTIRE, Version.LATEST ); Assert.fail("authorization failed expected, but didn't happen"); } catch (final HttpException ex) { MatcherAssert.assertThat( HttpResponseMocker.toString(ex.response()), Matchers.containsString("hello") ); } }
@Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats(); }
SecuredHost implements Host { @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) public Resource fetch(@NotNull final URI uri, @NotNull final Range range, @NotNull final Version version)throws IOException { final Resource res; if (this.isHidden(uri)) { res = this.secured(uri, range, version); } else { res = this.host.fetch(uri, range, version); } return res; } SecuredHost(@NotNull final Host hst,
        @NotNull final HttpRequest rqst); @Override @Loggable(value = Loggable.DEBUG, ignore = IOException.class) Resource fetch(@NotNull final URI uri, @NotNull final Range range,
        @NotNull final Version version); @Override boolean isHidden(@NotNull final URI uri); @Override boolean authorized(@NotNull final String user,
        @NotNull final String password); @Override void close(); @Override String syslog(); @Override Stats stats();  }