@Override public String getDescription() { return this.delegate.getDescription(); } }
@Override public String getDescription() { return this.original.getDescription(); }
@Override public String getDescription() { return this.gzipped.getDescription(); }
@Override public String getDescription() { return this.original.getDescription(); }
@Override public String getDescription() { return this.gzipped.getDescription(); }
@Override public String getDescription() { return this.encoded.getDescription(); }
@Override public String getDescription() { return this.encoded.getDescription(); }
/** * Return a description of the resource that this bean definition * came from (for the purpose of showing context in case of errors). */ @Override @Nullable public String getResourceDescription() { return (this.resource != null ? this.resource.getDescription() : null); }
/** * Return the description for the given Resource; if the description is * empty, return the class name of the resource plus its identity hash code. * @see org.springframework.core.io.Resource#getDescription() */ private static String getNameForResource(Resource resource) { String name = resource.getDescription(); if (!StringUtils.hasText(name)) { name = resource.getClass().getSimpleName() + "@" + System.identityHashCode(resource); } return name; }
/** * This implementation compares description strings. * @see #getDescription() */ @Override public boolean equals(Object other) { return (this == other || (other instanceof Resource && ((Resource) other).getDescription().equals(getDescription()))); }
/** * Get the description of the bean configuration source that triggered the error, * as contained within this Problem's Location object. * @see #getLocation() */ public String getResourceDescription() { return getLocation().getResource().getDescription(); }
@Test public void description() { Resource resource = new PathResource(TEST_FILE); assertThat(resource.getDescription(), containsString("path [")); assertThat(resource.getDescription(), containsString(TEST_FILE)); }
@Test // SPR-13149 public void resolveWithNullRequest() { String file = "js/foo.js"; Resource resolved = this.resolver.resolveResource(null, file, this.locations).block(TIMEOUT); assertEquals(getResource(file).getDescription(), resolved.getDescription()); assertEquals(getResource(file).getFilename(), resolved.getFilename()); }
@Test // SPR-13149 public void resolveWithNullRequest() { String file = "js/foo.js"; Resource resolved = this.resolver.resolveResource(null, file, this.locations); assertEquals(getResource(file).getDescription(), resolved.getDescription()); assertEquals(getResource(file).getFilename(), resolved.getFilename()); }
@Test public void testInputStreamResourceWithDescription() throws IOException { InputStream is = new ByteArrayInputStream("testString".getBytes()); Resource resource = new InputStreamResource(is, "my description"); assertTrue(resource.exists()); assertTrue(resource.isOpen()); String content = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream())); assertEquals("testString", content); assertTrue(resource.getDescription().contains("my description")); assertEquals(resource, new InputStreamResource(is)); }
@Test public void resolveGzippedWithVersion() { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); String file = "foo-e36d2e05253c6c7085a91522ce43a0b4.css"; Resource actual = this.resolver.resolveResource(exchange, file, this.locations).block(TIMEOUT); assertEquals(getResource("foo.css.gz").getDescription(), actual.getDescription()); assertEquals(getResource("foo.css").getFilename(), actual.getFilename()); assertTrue(actual instanceof HttpResource); }
@Test public void testByteArrayResourceWithDescription() throws IOException { Resource resource = new ByteArrayResource("testString".getBytes(), "my description"); assertTrue(resource.exists()); assertFalse(resource.isOpen()); String content = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream())); assertEquals("testString", content); assertTrue(resource.getDescription().contains("my description")); assertEquals(resource, new ByteArrayResource("testString".getBytes())); }
@Test public void resolveGzippedWithVersion() { String file = "foo-e36d2e05253c6c7085a91522ce43a0b4.css"; MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Accept-Encoding", "gzip"); Resource resolved = this.resolver.resolveResource(request, file, this.locations); assertEquals(getResource("foo.css.gz").getDescription(), resolved.getDescription()); assertEquals(getResource("foo.css").getFilename(), resolved.getFilename()); assertTrue(resolved instanceof HttpResource); }
@Test public void resolveGzipped() { MockServerWebExchange exchange = MockServerWebExchange.from( MockServerHttpRequest.get("").header("Accept-Encoding", "gzip")); String file = "js/foo.js"; Resource actual = this.resolver.resolveResource(exchange, file, this.locations).block(TIMEOUT); assertEquals(getResource(file + ".gz").getDescription(), actual.getDescription()); assertEquals(getResource(file).getFilename(), actual.getFilename()); assertTrue(actual instanceof HttpResource); HttpHeaders headers = ((HttpResource) actual).getResponseHeaders(); assertEquals("gzip", headers.getFirst(HttpHeaders.CONTENT_ENCODING)); assertEquals("Accept-Encoding", headers.getFirst(HttpHeaders.VARY)); }
@Test public void resolveGzipped() { String file = "js/foo.js"; MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Accept-Encoding", "gzip"); Resource actual = this.resolver.resolveResource(request, file, this.locations); assertEquals(getResource(file + ".gz").getDescription(), actual.getDescription()); assertEquals(getResource(file).getFilename(), actual.getFilename()); assertTrue(actual instanceof HttpResource); HttpHeaders headers = ((HttpResource) actual).getResponseHeaders(); assertEquals("gzip", headers.getFirst(HttpHeaders.CONTENT_ENCODING)); assertEquals("Accept-Encoding", headers.getFirst(HttpHeaders.VARY)); }