Skip to content

Commit 1de6355

Browse files
committed
Suppress deprecation warnings for code that tests the deprecated methods
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1470207 13f79535-47bb-0310-9956-ffa450edef68
1 parent f98a1dd commit 1de6355

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void testCopy_inputStreamToOutputStream_IO84() throws Exception {
156156
}
157157

158158
//-----------------------------------------------------------------------
159-
@SuppressWarnings("resource") // 'in' is deliberately not closed
159+
@SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
160160
public void testCopy_inputStreamToWriter() throws Exception {
161161
InputStream in = new ByteArrayInputStream(inData);
162162
in = new YellOnCloseInputStream(in);
@@ -165,7 +165,7 @@ public void testCopy_inputStreamToWriter() throws Exception {
165165
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
166166
final Writer writer = new OutputStreamWriter(baout, "US-ASCII");
167167

168-
IOUtils.copy(in, writer);
168+
IOUtils.copy(in, writer); // deliberately testing deprecated method
169169
out.off();
170170
writer.flush();
171171

@@ -174,6 +174,7 @@ public void testCopy_inputStreamToWriter() throws Exception {
174174
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
175175
}
176176

177+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
177178
public void testCopy_inputStreamToWriter_nullIn() throws Exception {
178179
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
179180
final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
@@ -184,10 +185,11 @@ public void testCopy_inputStreamToWriter_nullIn() throws Exception {
184185
} catch (final NullPointerException ex) {}
185186
}
186187

188+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
187189
public void testCopy_inputStreamToWriter_nullOut() throws Exception {
188190
final InputStream in = new ByteArrayInputStream(inData);
189191
try {
190-
IOUtils.copy(in, (Writer) null);
192+
IOUtils.copy(in, (Writer) null); // deliberately testing deprecated method
191193
fail();
192194
} catch (final NullPointerException ex) {}
193195
}
@@ -249,7 +251,7 @@ public void testCopy_inputStreamToWriter_Encoding_nullEncoding() throws Exceptio
249251
}
250252

251253
//-----------------------------------------------------------------------
252-
@SuppressWarnings("resource") // 'in' is deliberately not closed
254+
@SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
253255
public void testCopy_readerToOutputStream() throws Exception {
254256
InputStream in = new ByteArrayInputStream(inData);
255257
in = new YellOnCloseInputStream(in);
@@ -258,7 +260,7 @@ public void testCopy_readerToOutputStream() throws Exception {
258260
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
259261
final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
260262

261-
IOUtils.copy(reader, out);
263+
IOUtils.copy(reader, out); // deliberately testing deprecated method
262264
//Note: this method *does* flush. It is equivalent to:
263265
// OutputStreamWriter _out = new OutputStreamWriter(fout);
264266
// IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int );
@@ -270,7 +272,8 @@ public void testCopy_readerToOutputStream() throws Exception {
270272
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
271273
}
272274

273-
public void testCopy_readerToOutputStream_nullIn() throws Exception {
275+
@SuppressWarnings("deprecation")
276+
public void testCopy_readerToOutputStream_nullIn() throws Exception { // deliberately testing deprecated method
274277
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
275278
final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
276279
try {
@@ -279,13 +282,13 @@ public void testCopy_readerToOutputStream_nullIn() throws Exception {
279282
} catch (final NullPointerException ex) {}
280283
}
281284

282-
@SuppressWarnings("resource") // 'in' is deliberately not closed
285+
@SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
283286
public void testCopy_readerToOutputStream_nullOut() throws Exception {
284287
InputStream in = new ByteArrayInputStream(inData);
285288
in = new YellOnCloseInputStream(in);
286289
final Reader reader = new InputStreamReader(in, "US-ASCII");
287290
try {
288-
IOUtils.copy(reader, (OutputStream) null);
291+
IOUtils.copy(reader, (OutputStream) null); // deliberately testing deprecated method
289292
fail();
290293
} catch (final NullPointerException ex) {}
291294
}

src/test/java/org/apache/commons/io/IOUtilsTestCase.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ public void testReadFully_Reader_Offset() throws Exception {
705705
IOUtils.closeQuietly(reader);
706706
}
707707

708+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
708709
public void testReadLines_InputStream() throws Exception {
709710
final File file = newFile("lines.txt");
710711
InputStream in = null;
@@ -986,6 +987,7 @@ public void testToByteArray_InputStream_SizeZero() throws Exception {
986987
}
987988
}
988989

990+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
989991
public void testToByteArray_Reader() throws IOException {
990992
final String charsetName = "UTF-8";
991993
final byte[] expecteds = charsetName.getBytes(charsetName);
@@ -1033,6 +1035,7 @@ public void testToByteArray_URLConnection() throws Exception {
10331035
Assert.assertEquals(FILE_SIZE, actual.length);
10341036
}
10351037

1038+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
10361039
public void testToCharArray_InputStream() throws Exception {
10371040
final FileInputStream fin = new FileInputStream(m_testFile);
10381041
try {
@@ -1079,9 +1082,11 @@ public void testToCharArray_Reader() throws Exception {
10791082
* @throws Exception
10801083
* on error
10811084
*/
1085+
@SuppressWarnings("javadoc") // deliberately testing deprecated method
10821086
public void testToInputStream_CharSequence() throws Exception {
10831087
final CharSequence csq = new StringBuilder("Abc123Xyz!");
1084-
InputStream inStream = IOUtils.toInputStream(csq);
1088+
@SuppressWarnings("deprecation")
1089+
InputStream inStream = IOUtils.toInputStream(csq); // deliberately testing deprecated method
10851090
byte[] bytes = IOUtils.toByteArray(inStream);
10861091
assertEqualContent(csq.toString().getBytes(), bytes);
10871092
inStream = IOUtils.toInputStream(csq, (String) null);
@@ -1102,8 +1107,10 @@ public void testToInputStream_CharSequence() throws Exception {
11021107
* @throws Exception
11031108
* on error
11041109
*/
1110+
@SuppressWarnings("javadoc") // deliberately testing deprecated method
11051111
public void testToInputStream_String() throws Exception {
11061112
final String str = "Abc123Xyz!";
1113+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
11071114
InputStream inStream = IOUtils.toInputStream(str);
11081115
byte[] bytes = IOUtils.toByteArray(inStream);
11091116
assertEqualContent(str.getBytes(), bytes);
@@ -1129,6 +1136,7 @@ public void testToString_ByteArray() throws Exception {
11291136
}
11301137
}
11311138

1139+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
11321140
public void testToString_InputStream() throws Exception {
11331141
final FileInputStream fin = new FileInputStream(m_testFile);
11341142
try {
@@ -1152,6 +1160,7 @@ public void testToString_Reader() throws Exception {
11521160
}
11531161
}
11541162

1163+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
11551164
public void testToString_URI() throws Exception {
11561165
final URI url = m_testFile.toURI();
11571166
final String out = IOUtils.toString(url);
@@ -1174,6 +1183,7 @@ public void testToString_URI_CharsetNameNull() throws Exception {
11741183
testToString_URI(null);
11751184
}
11761185

1186+
@SuppressWarnings("deprecation") // deliberately testing deprecated method
11771187
public void testToString_URL() throws Exception {
11781188
final URL url = m_testFile.toURI().toURL();
11791189
final String out = IOUtils.toString(url);

src/test/java/org/apache/commons/io/IOUtilsWriteTestCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @version $Id$
3333
* @see IOUtils
3434
*/
35+
@SuppressWarnings("deprecation") // includes tests for deprecated methods
3536
public class IOUtilsWriteTestCase extends FileBasedTestCase {
3637

3738
private static final int FILE_SIZE = 1024 * 4 + 1;

src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public void testUTF16WithSingleByteRead() throws IOException {
105105
testWithSingleByteRead(TEST_STRING, "UTF-16");
106106
}
107107

108+
@SuppressWarnings("deprecation")
108109
@Test
109110
public void testReadZero() throws Exception {
110111
final String inStr = "test";
@@ -117,6 +118,7 @@ public void testReadZero() throws Exception {
117118
r.close();
118119
}
119120

121+
@SuppressWarnings("deprecation")
120122
@Test
121123
public void testReadZeroEmptyString() throws Exception {
122124
final ReaderInputStream r = new ReaderInputStream(new StringReader(""));

0 commit comments

Comments
 (0)