Skip to content

Commit 9ba2f53

Browse files
committed
use RackLogger's methods in MockServletContext
1 parent 75a354e commit 9ba2f53

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/spec/java/org/jruby/rack/mock/MockServletContext.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.springframework.core.io.Resource;
4040
import org.springframework.core.io.ResourceLoader;
4141

42+
import static org.jruby.rack.RackLogger.*;
43+
4244
/**
4345
* Mock implementation of the {@link javax.servlet.ServletContext} interface.
4446
*
@@ -72,7 +74,7 @@ public class MockServletContext implements ServletContext {
7274
private static final String TEMP_DIR_SYSTEM_PROPERTY = "java.io.tmpdir";
7375

7476
private static final String TEMP_DIR_CONTEXT_ATTRIBUTE = "javax.servlet.context.tempdir";
75-
77+
7678
private final ResourceLoader resourceLoader;
7779

7880
private final String resourceBasePath;
@@ -171,9 +173,9 @@ public void log(String level, String message) {
171173
public void log(String level, String message, Throwable e) {
172174
// NOOP
173175
}
174-
176+
175177
}
176-
178+
177179
public void setContextPath(String contextPath) {
178180
this.contextPath = (contextPath != null ? contextPath : "");
179181
}
@@ -250,7 +252,7 @@ public Set<String> getResourcePaths(String path) {
250252
return resourcePaths;
251253
}
252254
catch (IOException ex) {
253-
logger.log("WARN: Couldn't get resource paths for " + resource, ex);
255+
logger.log(WARN, "Couldn't get resource paths for " + resource, ex);
254256
return null;
255257
}
256258
}
@@ -267,7 +269,7 @@ public URL getResource(String path) throws MalformedURLException {
267269
throw ex;
268270
}
269271
catch (IOException ex) {
270-
logger.log("WARN: Couldn't get URL for " + resource, ex);
272+
logger.log(WARN, "Couldn't get URL for " + resource, ex);
271273
return null;
272274
}
273275
}
@@ -281,7 +283,7 @@ public InputStream getResourceAsStream(String path) {
281283
return resource.getInputStream();
282284
}
283285
catch (IOException ex) {
284-
logger.log("WARN: Couldn't open InputStream for " + resource, ex);
286+
logger.log(WARN, "Couldn't open InputStream for " + resource, ex);
285287
return null;
286288
}
287289
}
@@ -328,14 +330,14 @@ public RackLogger getLogger() {
328330
public void setLogger(RackLogger logger) {
329331
this.logger = logger == null ? new NullLogger() : logger;
330332
}
331-
333+
332334
public String getRealPath(String path) {
333335
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
334336
try {
335337
return resource.getFile().getAbsolutePath();
336338
}
337339
catch (IOException ex) {
338-
logger.log("WARN: Couldn't determine real path of resource " + resource, ex);
340+
logger.log(WARN, "Couldn't determine real path of resource " + resource, ex);
339341
return null;
340342
}
341343
}
@@ -345,14 +347,14 @@ public String getServerInfo() {
345347
}
346348

347349
public String getInitParameter(String name) {
348-
if (name == null) {
350+
if (name == null) {
349351
throw new IllegalArgumentException("parameter name must not be null");
350352
}
351353
return this.initParameters.get(name);
352354
}
353355

354356
public void addInitParameter(String name, String value) {
355-
if (name == null) {
357+
if (name == null) {
356358
throw new IllegalArgumentException("parameter name must not be null");
357359
}
358360
this.initParameters.put(name, value);
@@ -363,7 +365,7 @@ public Enumeration<String> getInitParameterNames() {
363365
}
364366

365367
public Object getAttribute(String name) {
366-
if (name == null) {
368+
if (name == null) {
367369
throw new IllegalArgumentException("attribute name must not be null");
368370
}
369371
return this.attributes.get(name);
@@ -374,7 +376,7 @@ public Enumeration<String> getAttributeNames() {
374376
}
375377

376378
public void setAttribute(String name, Object value) {
377-
if (name == null) {
379+
if (name == null) {
378380
throw new IllegalArgumentException("attribute name must not be null");
379381
}
380382
if (value != null) {
@@ -386,7 +388,7 @@ public void setAttribute(String name, Object value) {
386388
}
387389

388390
public void removeAttribute(String name) {
389-
if (name == null) {
391+
if (name == null) {
390392
throw new IllegalArgumentException("attribute name must not be null");
391393
}
392394
this.attributes.remove(name);
@@ -410,7 +412,7 @@ private static class MimeTypeResolver {
410412
public static String getMimeType(String filePath) {
411413
return FileTypeMap.getDefaultFileTypeMap().getContentType(filePath);
412414
}
413-
415+
414416
}
415417

416418

0 commit comments

Comments
 (0)