|
|
|
|
@ -1,5 +1,5 @@
@@ -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.*;
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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()); |
|
|
|
|
|