1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public class ResourceHandlerRegistryTests {
65
65
66
66
67
67
@ BeforeEach
68
- public void setUp () {
68
+ public void setup () {
69
69
GenericWebApplicationContext appContext = new GenericWebApplicationContext ();
70
70
appContext .refresh ();
71
71
@@ -77,8 +77,14 @@ public void setUp() {
77
77
this .response = new MockHttpServletResponse ();
78
78
}
79
79
80
+ private ResourceHttpRequestHandler getHandler (String pathPattern ) {
81
+ SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping ) this .registry .getHandlerMapping ();
82
+ return (ResourceHttpRequestHandler ) hm .getUrlMap ().get (pathPattern );
83
+ }
84
+
85
+
80
86
@ Test
81
- public void noResourceHandlers () throws Exception {
87
+ public void noResourceHandlers () {
82
88
this .registry = new ResourceHandlerRegistry (new GenericWebApplicationContext (), new MockServletContext ());
83
89
assertThat ((Object ) this .registry .getHandlerMapping ()).isNull ();
84
90
}
@@ -127,7 +133,7 @@ public void hasMappingForPattern() {
127
133
}
128
134
129
135
@ Test
130
- public void resourceChain () throws Exception {
136
+ public void resourceChain () {
131
137
ResourceResolver mockResolver = Mockito .mock (ResourceResolver .class );
132
138
ResourceTransformer mockTransformer = Mockito .mock (ResourceTransformer .class );
133
139
this .registration .resourceChain (true ).addResolver (mockResolver ).addTransformer (mockTransformer );
@@ -149,7 +155,7 @@ public void resourceChain() throws Exception {
149
155
}
150
156
151
157
@ Test
152
- public void resourceChainWithoutCaching () throws Exception {
158
+ public void resourceChainWithoutCaching () {
153
159
this .registration .resourceChain (false );
154
160
155
161
ResourceHttpRequestHandler handler = getHandler ("/resources/**" );
@@ -163,7 +169,7 @@ public void resourceChainWithoutCaching() throws Exception {
163
169
}
164
170
165
171
@ Test
166
- public void resourceChainWithVersionResolver () throws Exception {
172
+ public void resourceChainWithVersionResolver () {
167
173
VersionResourceResolver versionResolver = new VersionResourceResolver ()
168
174
.addFixedVersionStrategy ("fixed" , "/**/*.js" )
169
175
.addContentVersionStrategy ("/**" );
@@ -187,7 +193,7 @@ public void resourceChainWithVersionResolver() throws Exception {
187
193
}
188
194
189
195
@ Test
190
- public void resourceChainWithOverrides () throws Exception {
196
+ public void resourceChainWithOverrides () {
191
197
CachingResourceResolver cachingResolver = Mockito .mock (CachingResourceResolver .class );
192
198
VersionResourceResolver versionResolver = Mockito .mock (VersionResourceResolver .class );
193
199
WebJarsResourceResolver webjarsResolver = Mockito .mock (WebJarsResourceResolver .class );
@@ -222,7 +228,7 @@ public void resourceChainWithOverrides() throws Exception {
222
228
}
223
229
224
230
@ Test
225
- public void urlResourceWithCharset () throws Exception {
231
+ public void urlResourceWithCharset () {
226
232
this .registration .addResourceLocations ("[charset=ISO-8859-1]file:///tmp" );
227
233
this .registration .resourceChain (true );
228
234
@@ -238,9 +244,4 @@ public void urlResourceWithCharset() throws Exception {
238
244
assertThat (locationCharsets .values ().iterator ().next ()).isEqualTo (StandardCharsets .ISO_8859_1 );
239
245
}
240
246
241
- private ResourceHttpRequestHandler getHandler (String pathPattern ) {
242
- SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping ) this .registry .getHandlerMapping ();
243
- return (ResourceHttpRequestHandler ) hm .getUrlMap ().get (pathPattern );
244
- }
245
-
246
247
}
0 commit comments