Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -30,9 +30,9 @@ import static org.junit.Assert.*;
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class InputStreamEditorTests {
|
||||
public class InputStreamEditorTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCtorWithNullResourceEditor() throws Exception {
|
||||
new InputStreamEditor(null);
|
||||
}
|
||||
@@ -41,7 +41,8 @@ public final class InputStreamEditorTests {
|
||||
public void testSunnyDay() throws Exception {
|
||||
InputStream stream = null;
|
||||
try {
|
||||
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class";
|
||||
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
|
||||
"/" + ClassUtils.getShortName(getClass()) + ".class";
|
||||
InputStreamEditor editor = new InputStreamEditor();
|
||||
editor.setAsText(resource);
|
||||
Object value = editor.getValue();
|
||||
@@ -49,14 +50,15 @@ public final class InputStreamEditorTests {
|
||||
assertTrue(value instanceof InputStream);
|
||||
stream = (InputStream) value;
|
||||
assertTrue(stream.available() > 0);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testWhenResourceDoesNotExist() throws Exception {
|
||||
String resource = "classpath:bingo!";
|
||||
InputStreamEditor editor = new InputStreamEditor();
|
||||
@@ -66,7 +68,8 @@ public final class InputStreamEditorTests {
|
||||
@Test
|
||||
public void testGetAsTextReturnsNullByDefault() throws Exception {
|
||||
assertNull(new InputStreamEditor().getAsText());
|
||||
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class";
|
||||
String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
|
||||
"/" + ClassUtils.getShortName(getClass()) + ".class";
|
||||
InputStreamEditor editor = new InputStreamEditor();
|
||||
editor.setAsText(resource);
|
||||
assertNull(editor.getAsText());
|
||||
|
||||
@@ -85,6 +85,7 @@ public class EncodedResource {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code Resource} held by this {@code EncodedResource}.
|
||||
*/
|
||||
@@ -152,17 +153,17 @@ public class EncodedResource {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof EncodedResource) {
|
||||
EncodedResource that = (EncodedResource) obj;
|
||||
return (this.resource.equals(that.resource) &&
|
||||
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
|
||||
ObjectUtils.nullSafeEquals(this.encoding, that.encoding));
|
||||
if (!(other instanceof EncodedResource)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
EncodedResource otherResource = (EncodedResource) other;
|
||||
return (this.resource.equals(otherResource.resource) &&
|
||||
ObjectUtils.nullSafeEquals(this.charset, otherResource.charset) &&
|
||||
ObjectUtils.nullSafeEquals(this.encoding, otherResource.encoding));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user