1 package nom.tam.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 import static org.junit.Assert.assertEquals;
35
36 import java.io.EOFException;
37 import java.io.IOException;
38
39 import org.junit.Test;
40
41 public class DefaultMethodsTest {
42
43 @Test
44 public void testMarkSupported() throws Exception {
45 assertEquals(true, new DefaultInput().markSupported());
46 }
47
48 @Test(expected = EOFException.class)
49 public void testReadArrayFullyException() throws Exception {
50 int[] array = new int[2];
51 new DefaultInput().readArrayFully(array);
52
53 }
54
55 @Test
56 public void testReadArrayFullySuccess() throws Exception {
57 int[] array = new int[2];
58 new DefaultInput() {
59 @Override
60 public long readLArray(Object o) throws IOException {
61 return 4L * array.length;
62 }
63 }.readArrayFully(array);
64 }
65
66 @Test
67 public void testReadBooleanArray() throws Exception {
68 Boolean[] b = new Boolean[1];
69 assertEquals(b.length, new DefaultInput().read(b));
70 assertEquals(false, b[0]);
71 }
72
73 @Test
74 public void testWriteBooleanArray() throws Exception {
75 Boolean[] b = new Boolean[] {Boolean.TRUE, Boolean.FALSE};
76 new DefaultOutput().write(b);
77
78 }
79
80 @Test(expected = NullPointerException.class)
81 public void testWriteBooleanNull() throws Exception {
82 Boolean[] b = new Boolean[] {Boolean.TRUE, Boolean.FALSE, null};
83 new DefaultOutput().write(b);
84
85 }
86
87 class DefaultInput implements ArrayDataInput {
88
89 @Override
90 public int read() throws IOException {
91
92 return 0;
93 }
94
95 @Override
96 public int read(byte[] b, int from, int length) throws IOException {
97
98 return 0;
99 }
100
101 @Override
102 public boolean readBoolean() throws IOException {
103
104 return false;
105 }
106
107 @Override
108 public byte readByte() throws IOException {
109
110 return 0;
111 }
112
113 @Override
114 public char readChar() throws IOException {
115
116 return 0;
117 }
118
119 @Override
120 public double readDouble() throws IOException {
121
122 return 0;
123 }
124
125 @Override
126 public float readFloat() throws IOException {
127
128 return 0;
129 }
130
131 @Override
132 public void readFully(byte[] b) throws IOException {
133
134
135 }
136
137 @Override
138 public int readInt() throws IOException {
139
140 return 0;
141 }
142
143 @Override
144 public String readLine() throws IOException {
145
146 return null;
147 }
148
149 @Override
150 public long readLong() throws IOException {
151
152 return 0;
153 }
154
155 @Override
156 public short readShort() throws IOException {
157
158 return 0;
159 }
160
161 @Override
162 public String readUTF() throws IOException {
163
164 return null;
165 }
166
167 @Override
168 public int readUnsignedByte() throws IOException {
169
170 return 0;
171 }
172
173 @Override
174 public int readUnsignedShort() throws IOException {
175
176 return 0;
177 }
178
179 @Override
180 public int skipBytes(int n) throws IOException {
181
182 return 0;
183 }
184
185 @Override
186 public void close() throws IOException {
187
188
189 }
190
191 @Override
192 public void mark(int readlimit) throws IOException {
193
194
195 }
196
197 @Override
198 public int read(byte[] buf) throws IOException {
199
200 return 0;
201 }
202
203 @Override
204 public int read(boolean[] buf) throws IOException {
205
206 return 0;
207 }
208
209 @Override
210 public int read(boolean[] buf, int offset, int size) throws IOException {
211
212 return 0;
213 }
214
215 @Override
216 public int read(char[] buf) throws IOException {
217
218 return 0;
219 }
220
221 @Override
222 public int read(char[] buf, int offset, int size) throws IOException {
223
224 return 0;
225 }
226
227 @Override
228 public int read(double[] buf) throws IOException {
229
230 return 0;
231 }
232
233 @Override
234 public int read(double[] buf, int offset, int size) throws IOException {
235
236 return 0;
237 }
238
239 @Override
240 public int read(float[] buf) throws IOException {
241
242 return 0;
243 }
244
245 @Override
246 public int read(float[] buf, int offset, int size) throws IOException {
247
248 return 0;
249 }
250
251 @Override
252 public int read(int[] buf) throws IOException {
253
254 return 0;
255 }
256
257 @Override
258 public int read(int[] buf, int offset, int size) throws IOException {
259
260 return 0;
261 }
262
263 @Override
264 public int read(long[] buf) throws IOException {
265
266 return 0;
267 }
268
269 @Override
270 public int read(long[] buf, int offset, int size) throws IOException {
271
272 return 0;
273 }
274
275 @Override
276 public int read(short[] buf) throws IOException {
277
278 return 0;
279 }
280
281 @Override
282 public int read(short[] buf, int offset, int size) throws IOException {
283
284 return 0;
285 }
286
287 @Override
288 public int readArray(Object o) throws IOException, IllegalArgumentException {
289
290 return 0;
291 }
292
293 @Override
294 public long readLArray(Object o) throws IOException, IllegalArgumentException {
295
296 return 0;
297 }
298
299 @Override
300 public void reset() throws IOException {
301
302
303 }
304
305 @Override
306 public long skip(long distance) throws IOException {
307
308 return 0;
309 }
310
311 @Override
312 public void skipAllBytes(long toSkip) throws IOException {
313
314
315 }
316
317 @Override
318 public void readFully(byte[] b, int off, int len) throws IOException {
319
320
321 }
322 }
323
324 public static class DefaultOutput implements ArrayDataOutput {
325
326 @Override
327 public void write(int b) throws IOException {
328
329
330 }
331
332 @Override
333 public void write(byte[] b) throws IOException {
334
335
336 }
337
338 @Override
339 public void write(byte[] b, int off, int len) throws IOException {
340
341
342 }
343
344 @Override
345 public void writeBoolean(boolean v) throws IOException {
346
347
348 }
349
350 @Override
351 public void writeByte(int v) throws IOException {
352
353
354 }
355
356 @Override
357 public void writeBytes(String s) throws IOException {
358
359
360 }
361
362 @Override
363 public void writeChar(int v) throws IOException {
364
365
366 }
367
368 @Override
369 public void writeChars(String s) throws IOException {
370
371
372 }
373
374 @Override
375 public void writeDouble(double v) throws IOException {
376
377
378 }
379
380 @Override
381 public void writeFloat(float v) throws IOException {
382
383
384 }
385
386 @Override
387 public void writeInt(int v) throws IOException {
388
389
390 }
391
392 @Override
393 public void writeLong(long v) throws IOException {
394
395
396 }
397
398 @Override
399 public void writeShort(int v) throws IOException {
400
401
402 }
403
404 @Override
405 public void writeUTF(String s) throws IOException {
406
407
408 }
409
410 @Override
411 public void close() throws IOException {
412
413
414 }
415
416 @Override
417 public void flush() throws IOException {
418
419
420 }
421
422 @Override
423 public void write(boolean[] buf) throws IOException {
424
425
426 }
427
428 @Override
429 public void write(boolean[] buf, int offset, int size) throws IOException {
430
431
432 }
433
434 @Override
435 public void write(char[] buf) throws IOException {
436
437
438 }
439
440 @Override
441 public void write(char[] buf, int offset, int size) throws IOException {
442
443
444 }
445
446 @Override
447 public void write(double[] buf) throws IOException {
448
449
450 }
451
452 @Override
453 public void write(double[] buf, int offset, int size) throws IOException {
454
455
456 }
457
458 @Override
459 public void write(float[] buf) throws IOException {
460
461
462 }
463
464 @Override
465 public void write(float[] buf, int offset, int size) throws IOException {
466
467
468 }
469
470 @Override
471 public void write(int[] buf) throws IOException {
472
473
474 }
475
476 @Override
477 public void write(int[] buf, int offset, int size) throws IOException {
478
479
480 }
481
482 @Override
483 public void write(long[] buf) throws IOException {
484
485
486 }
487
488 @Override
489 public void write(long[] buf, int offset, int size) throws IOException {
490
491
492 }
493
494 @Override
495 public void write(short[] buf) throws IOException {
496
497
498 }
499
500 @Override
501 public void write(short[] buf, int offset, int size) throws IOException {
502
503
504 }
505
506 @Override
507 public void write(String[] buf) throws IOException {
508
509
510 }
511
512 @Override
513 public void write(String[] buf, int offset, int size) throws IOException {
514
515
516 }
517
518 @Override
519 public void writeArray(Object o) throws IOException, IllegalArgumentException {
520
521
522 }
523 }
524
525 }