1
2
3
4
5
6 package org.weda.converter;
7
8 import java.io.ByteArrayInputStream;
9 import java.util.Arrays;
10 import junit.framework.TestCase;
11 import org.weda.converter.impl.InputStreamToByteConverter;
12
13 /**
14 *
15 * @author Mikhail Titov
16 */
17 public class InputStreamToByteConverterTest extends TestCase{
18
19 public InputStreamToByteConverterTest(String name) {
20 super(name);
21 }
22
23 public void test() throws Exception{
24 ValueTypeConverter converter = new InputStreamToByteConverter();
25 checkConvert(converter);
26 }
27
28 public void checkConvert(ValueTypeConverter converter) throws Exception{
29 byte[] arr = new byte[]{1,2,3,4,5,6};
30 ByteArrayInputStream is = new ByteArrayInputStream(arr);
31 Class toType = Class.forName("[B");
32 byte[] res = (byte[])converter.convert(toType, is, null);
33 assertTrue(Arrays.equals(arr, res));
34 }
35
36 }