Skip to content

Commit 17bb2a7

Browse files
author
Gary Gregory
committed
Sort test members.
1 parent dcb09db commit 17bb2a7

91 files changed

Lines changed: 6514 additions & 6514 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,33 @@ public void constantCharsetNames() {
5656
assertNotNull(Charset.forName(ByteOrderMark.UTF_32LE.getCharsetName()));
5757
}
5858

59-
/** Test {@link ByteOrderMark#length()} */
59+
/** Test Errors */
6060
@Test
61-
public void testLength() {
62-
assertEquals(1, TEST_BOM_1.length(), "test1 length");
63-
assertEquals(2, TEST_BOM_2.length(), "test2 length");
64-
assertEquals(3, TEST_BOM_3.length(), "test3 length");
61+
public void errors() {
62+
try {
63+
new ByteOrderMark(null, 1,2,3);
64+
fail("null charset name, expected IllegalArgumentException");
65+
} catch (final IllegalArgumentException e) {
66+
// expected
67+
}
68+
try {
69+
new ByteOrderMark("", 1,2,3);
70+
fail("no charset name, expected IllegalArgumentException");
71+
} catch (final IllegalArgumentException e) {
72+
// expected
73+
}
74+
try {
75+
new ByteOrderMark("a", (int[])null);
76+
fail("null bytes, expected IllegalArgumentException");
77+
} catch (final IllegalArgumentException e) {
78+
// expected
79+
}
80+
try {
81+
new ByteOrderMark("b");
82+
fail("empty bytes, expected IllegalArgumentException");
83+
} catch (final IllegalArgumentException e) {
84+
// expected
85+
}
6586
}
6687

6788
/** Test {@link ByteOrderMark#get(int)} */
@@ -109,33 +130,12 @@ public void testHashCode() {
109130
assertEquals(bomClassHash + 6, TEST_BOM_3.hashCode(), "hash test3 ");
110131
}
111132

112-
/** Test Errors */
133+
/** Test {@link ByteOrderMark#length()} */
113134
@Test
114-
public void errors() {
115-
try {
116-
new ByteOrderMark(null, 1,2,3);
117-
fail("null charset name, expected IllegalArgumentException");
118-
} catch (final IllegalArgumentException e) {
119-
// expected
120-
}
121-
try {
122-
new ByteOrderMark("", 1,2,3);
123-
fail("no charset name, expected IllegalArgumentException");
124-
} catch (final IllegalArgumentException e) {
125-
// expected
126-
}
127-
try {
128-
new ByteOrderMark("a", (int[])null);
129-
fail("null bytes, expected IllegalArgumentException");
130-
} catch (final IllegalArgumentException e) {
131-
// expected
132-
}
133-
try {
134-
new ByteOrderMark("b");
135-
fail("empty bytes, expected IllegalArgumentException");
136-
} catch (final IllegalArgumentException e) {
137-
// expected
138-
}
135+
public void testLength() {
136+
assertEquals(1, TEST_BOM_1.length(), "test1 length");
137+
assertEquals(2, TEST_BOM_2.length(), "test2 length");
138+
assertEquals(3, TEST_BOM_3.length(), "test3 length");
139139
}
140140

141141
/** Test {@link ByteOrderMark#toString()} */

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
@SuppressWarnings("deprecation") // testing deprecated code
3333
public class CharsetsTestCase {
3434

35+
@Test
36+
public void testIso8859_1() {
37+
assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
38+
}
39+
3540
@Test
3641
public void testRequiredCharsets() {
3742
final SortedMap<String, Charset> requiredCharsets = Charsets.requiredCharsets();
@@ -45,11 +50,6 @@ public void testRequiredCharsets() {
4550
assertEquals(requiredCharsets.get("UTF-16LE").name(), "UTF-16LE");
4651
}
4752

48-
@Test
49-
public void testIso8859_1() {
50-
assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
51-
}
52-
5353
@Test
5454
public void testToCharset() {
5555
assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null));

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

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ public class CopyUtilsTest {
5858
// Tests
5959
// ----------------------------------------------------------------
6060

61-
@Test
62-
public void testCtor() {
63-
new CopyUtils();
64-
// Nothing to assert, the constructor is public and does not blow up.
65-
}
66-
6761
@Test
6862
public void copy_byteArrayToOutputStream() throws Exception {
6963
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
@@ -88,32 +82,6 @@ public void copy_byteArrayToWriter() throws Exception {
8882
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
8983
}
9084

91-
@Test
92-
public void testCopy_byteArrayToWriterWithEncoding() throws Exception {
93-
final String inDataStr = "data";
94-
final String charsetName = "UTF-8";
95-
final StringWriter writer = new StringWriter();
96-
CopyUtils.copy(inDataStr.getBytes(charsetName), writer, charsetName);
97-
assertEquals(inDataStr, writer.toString());
98-
}
99-
100-
@SuppressWarnings("resource") // 'in' is deliberately not closed
101-
@Test
102-
public void testCopy_inputStreamToOutputStream() throws Exception {
103-
InputStream in = new ByteArrayInputStream(inData);
104-
in = new ThrowOnCloseInputStream(in);
105-
106-
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
107-
final OutputStream out = new ThrowOnFlushAndCloseOutputStream(baout, false, true);
108-
109-
final int count = CopyUtils.copy(in, out);
110-
111-
assertEquals(0, in.available(), "Not all bytes were read");
112-
assertEquals(inData.length, baout.size(), "Sizes differ");
113-
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
114-
assertEquals(inData.length, count);
115-
}
116-
11785
@SuppressWarnings("resource") // 'in' is deliberately not closed
11886
@Test
11987
public void copy_inputStreamToWriter() throws Exception {
@@ -141,28 +109,6 @@ public void copy_inputStreamToWriterWithEncoding() throws Exception {
141109
assertEquals(inDataStr, writer.toString());
142110
}
143111

144-
@SuppressWarnings("resource") // 'in' is deliberately not closed
145-
@Test
146-
public void testCopy_readerToOutputStream() throws Exception {
147-
InputStream in = new ByteArrayInputStream(inData);
148-
in = new ThrowOnCloseInputStream(in);
149-
final Reader reader = new java.io.InputStreamReader(in, StandardCharsets.US_ASCII);
150-
151-
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
152-
final OutputStream out = new ThrowOnFlushAndCloseOutputStream(baout, false, true);
153-
154-
CopyUtils.copy(reader, out);
155-
//Note: this method *does* flush. It is equivalent to:
156-
// OutputStreamWriter _out = new OutputStreamWriter(fout);
157-
// IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int );
158-
// _out.flush();
159-
// out = fout;
160-
161-
// Note: rely on the method to flush
162-
assertEquals(inData.length, baout.size(), "Sizes differ");
163-
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
164-
}
165-
166112
@SuppressWarnings("resource") // 'in' is deliberately not closed
167113
@Test
168114
public void copy_readerToWriter() throws Exception {
@@ -215,4 +161,58 @@ public void copy_stringToWriter() throws Exception {
215161
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
216162
}
217163

164+
@Test
165+
public void testCopy_byteArrayToWriterWithEncoding() throws Exception {
166+
final String inDataStr = "data";
167+
final String charsetName = "UTF-8";
168+
final StringWriter writer = new StringWriter();
169+
CopyUtils.copy(inDataStr.getBytes(charsetName), writer, charsetName);
170+
assertEquals(inDataStr, writer.toString());
171+
}
172+
173+
@SuppressWarnings("resource") // 'in' is deliberately not closed
174+
@Test
175+
public void testCopy_inputStreamToOutputStream() throws Exception {
176+
InputStream in = new ByteArrayInputStream(inData);
177+
in = new ThrowOnCloseInputStream(in);
178+
179+
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
180+
final OutputStream out = new ThrowOnFlushAndCloseOutputStream(baout, false, true);
181+
182+
final int count = CopyUtils.copy(in, out);
183+
184+
assertEquals(0, in.available(), "Not all bytes were read");
185+
assertEquals(inData.length, baout.size(), "Sizes differ");
186+
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
187+
assertEquals(inData.length, count);
188+
}
189+
190+
@SuppressWarnings("resource") // 'in' is deliberately not closed
191+
@Test
192+
public void testCopy_readerToOutputStream() throws Exception {
193+
InputStream in = new ByteArrayInputStream(inData);
194+
in = new ThrowOnCloseInputStream(in);
195+
final Reader reader = new java.io.InputStreamReader(in, StandardCharsets.US_ASCII);
196+
197+
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
198+
final OutputStream out = new ThrowOnFlushAndCloseOutputStream(baout, false, true);
199+
200+
CopyUtils.copy(reader, out);
201+
//Note: this method *does* flush. It is equivalent to:
202+
// OutputStreamWriter _out = new OutputStreamWriter(fout);
203+
// IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int );
204+
// _out.flush();
205+
// out = fout;
206+
207+
// Note: rely on the method to flush
208+
assertEquals(inData.length, baout.size(), "Sizes differ");
209+
assertArrayEquals(inData, baout.toByteArray(), "Content differs");
210+
}
211+
212+
@Test
213+
public void testCtor() {
214+
new CopyUtils();
215+
// Nothing to assert, the constructor is public and does not blow up.
216+
}
217+
218218
} // CopyUtilsTest

0 commit comments

Comments
 (0)