1   /*
2    * InputStreamToBlobConverterTest.java
3    * Created on 4 Август 2006 г., 15:44
4    */
5   
6   package org.weda.converter;
7   
8   import java.io.ByteArrayInputStream;
9   import java.sql.Blob;
10  import java.util.Arrays;
11  import junit.framework.TestCase;
12  import org.apache.commons.io.IOUtils;
13  import org.weda.converter.impl.InputStreamToBlobConverter;
14  import org.weda.converter.impl.InputStreamToByteConverter;
15  
16  /**
17   *
18   * @author Mikhail Titov
19   */
20  public class InputStreamToBlobConverterTest extends TestCase {
21      
22      /**
23       * Creates a new instance of InputStreamToBlobConverterTest
24       */
25      public InputStreamToBlobConverterTest(String name) {
26          super(name);
27      }
28      
29      public void test() throws Exception{
30          //ValueTypeConverter converter = new InputStreamToBlobConverter();
31          //checkConvert(converter);
32      }
33      
34      public void checkConvert(ValueTypeConverter converter) throws Exception{
35          byte[] arr = new byte[]{1,2,3,4,5,6};
36          ByteArrayInputStream is = new ByteArrayInputStream(arr);
37          Blob blob = (Blob)converter.convert(Blob.class, is, null);
38          byte[] res = IOUtils.toByteArray(blob.getBinaryStream());
39          assertTrue(Arrays.equals(arr, res));        
40      }
41      
42  }