Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,24 +64,24 @@ public final class ParserContext {
|
||||
}
|
||||
|
||||
|
||||
public final XmlReaderContext getReaderContext() {
|
||||
public XmlReaderContext getReaderContext() {
|
||||
return this.readerContext;
|
||||
}
|
||||
|
||||
public final BeanDefinitionRegistry getRegistry() {
|
||||
public BeanDefinitionRegistry getRegistry() {
|
||||
return this.readerContext.getRegistry();
|
||||
}
|
||||
|
||||
public final BeanDefinitionParserDelegate getDelegate() {
|
||||
public BeanDefinitionParserDelegate getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final BeanDefinition getContainingBeanDefinition() {
|
||||
public BeanDefinition getContainingBeanDefinition() {
|
||||
return this.containingBeanDefinition;
|
||||
}
|
||||
|
||||
public final boolean isNested() {
|
||||
public boolean isNested() {
|
||||
return (this.containingBeanDefinition != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ public class ResourceHandlerRegistryTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
GenericWebApplicationContext appContext = new GenericWebApplicationContext();
|
||||
appContext.refresh();
|
||||
|
||||
@@ -77,8 +77,14 @@ public class ResourceHandlerRegistryTests {
|
||||
this.response = new MockHttpServletResponse();
|
||||
}
|
||||
|
||||
private ResourceHttpRequestHandler getHandler(String pathPattern) {
|
||||
SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.registry.getHandlerMapping();
|
||||
return (ResourceHttpRequestHandler) hm.getUrlMap().get(pathPattern);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noResourceHandlers() throws Exception {
|
||||
public void noResourceHandlers() {
|
||||
this.registry = new ResourceHandlerRegistry(new GenericWebApplicationContext(), new MockServletContext());
|
||||
assertThat((Object) this.registry.getHandlerMapping()).isNull();
|
||||
}
|
||||
@@ -127,7 +133,7 @@ public class ResourceHandlerRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceChain() throws Exception {
|
||||
public void resourceChain() {
|
||||
ResourceResolver mockResolver = Mockito.mock(ResourceResolver.class);
|
||||
ResourceTransformer mockTransformer = Mockito.mock(ResourceTransformer.class);
|
||||
this.registration.resourceChain(true).addResolver(mockResolver).addTransformer(mockTransformer);
|
||||
@@ -149,7 +155,7 @@ public class ResourceHandlerRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceChainWithoutCaching() throws Exception {
|
||||
public void resourceChainWithoutCaching() {
|
||||
this.registration.resourceChain(false);
|
||||
|
||||
ResourceHttpRequestHandler handler = getHandler("/resources/**");
|
||||
@@ -163,7 +169,7 @@ public class ResourceHandlerRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceChainWithVersionResolver() throws Exception {
|
||||
public void resourceChainWithVersionResolver() {
|
||||
VersionResourceResolver versionResolver = new VersionResourceResolver()
|
||||
.addFixedVersionStrategy("fixed", "/**/*.js")
|
||||
.addContentVersionStrategy("/**");
|
||||
@@ -187,7 +193,7 @@ public class ResourceHandlerRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceChainWithOverrides() throws Exception {
|
||||
public void resourceChainWithOverrides() {
|
||||
CachingResourceResolver cachingResolver = Mockito.mock(CachingResourceResolver.class);
|
||||
VersionResourceResolver versionResolver = Mockito.mock(VersionResourceResolver.class);
|
||||
WebJarsResourceResolver webjarsResolver = Mockito.mock(WebJarsResourceResolver.class);
|
||||
@@ -222,7 +228,7 @@ public class ResourceHandlerRegistryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlResourceWithCharset() throws Exception {
|
||||
public void urlResourceWithCharset() {
|
||||
this.registration.addResourceLocations("[charset=ISO-8859-1]file:///tmp");
|
||||
this.registration.resourceChain(true);
|
||||
|
||||
@@ -238,9 +244,4 @@ public class ResourceHandlerRegistryTests {
|
||||
assertThat(locationCharsets.values().iterator().next()).isEqualTo(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
private ResourceHttpRequestHandler getHandler(String pathPattern) {
|
||||
SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.registry.getHandlerMapping();
|
||||
return (ResourceHttpRequestHandler) hm.getUrlMap().get(pathPattern);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -286,7 +286,6 @@ public class ResourceHttpRequestHandlerTests {
|
||||
|
||||
@Test // SPR-14368
|
||||
public void getResourceWithMediaTypeResolvedThroughServletContext() throws Exception {
|
||||
|
||||
MockServletContext servletContext = new MockServletContext() {
|
||||
@Override
|
||||
public String getMimeType(String filePath) {
|
||||
@@ -310,7 +309,6 @@ public class ResourceHttpRequestHandlerTests {
|
||||
|
||||
@Test
|
||||
public void testInvalidPath() throws Exception {
|
||||
|
||||
// Use mock ResourceResolver: i.e. we're only testing upfront validations...
|
||||
|
||||
Resource resource = mock(Resource.class);
|
||||
@@ -656,7 +654,7 @@ public class ResourceHttpRequestHandlerTests {
|
||||
assertThat(ranges[11]).isEqualTo("t.");
|
||||
}
|
||||
|
||||
@Test // gh-25976
|
||||
@Test // gh-25976
|
||||
public void partialContentByteRangeWithEncodedResource(GzipSupport.GzippedFiles gzippedFiles) throws Exception {
|
||||
String path = "js/foo.js";
|
||||
gzippedFiles.create(path);
|
||||
@@ -685,7 +683,7 @@ public class ResourceHttpRequestHandlerTests {
|
||||
assertThat(this.response.getHeaderValues("Vary")).containsExactly("Accept-Encoding");
|
||||
}
|
||||
|
||||
@Test // gh-25976
|
||||
@Test // gh-25976
|
||||
public void partialContentWithHttpHead() throws Exception {
|
||||
this.request.setMethod("HEAD");
|
||||
this.request.addHeader("Range", "bytes=0-1");
|
||||
|
||||
Reference in New Issue
Block a user