1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.dbunit.dataset.datatype;
22
23 import java.io.InputStream;
24 import java.io.OutputStream;
25 import java.sql.Blob;
26 import java.sql.SQLException;
27
28
29
30
31
32
33 public class TestBlob implements Blob
34 {
35 private byte[] data = new byte[0];
36
37 public TestBlob(byte[] data)
38 {
39 this.data = data;
40 }
41
42 public long length() throws SQLException
43 {
44 return data.length;
45 }
46
47 public byte[] getBytes(long pos, int length) throws SQLException
48 {
49 byte[] result = new byte[length];
50 System.arraycopy(data, (int) pos - 1, result, 0, length);
51 return result;
52 }
53
54 public InputStream getBinaryStream() throws SQLException
55 {
56 throw new SQLException("TestBlob does not support getBinaryStream()");
57 }
58
59 public long position(byte[] pattern, long start) throws SQLException
60 {
61 throw new SQLException("TestBlob does not support position(byte[], long)");
62 }
63
64 public long position(Blob pattern, long start) throws SQLException
65 {
66 throw new SQLException("TestBlob does not support position(Blob, long)");
67 }
68
69 public int setBytes(long pos, byte[] bytes) throws SQLException
70 {
71 throw new SQLException("TestBlob does not support setBytes(long, byte[])");
72 }
73
74 public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
75 {
76 throw new SQLException("TestBlob does not support setBytes(long, byte[], int, int)");
77 }
78
79 public OutputStream setBinaryStream(long pos) throws SQLException
80 {
81 throw new SQLException("TestBlob does not support setBinaryStream(long)");
82 }
83
84 public void truncate(long len) throws SQLException
85 {
86 throw new SQLException("TestBlob does not support truncate(long)");
87 }
88
89 public void free() throws SQLException
90 {
91 throw new SQLException("TestBlob does not support free()");
92 }
93
94 public InputStream getBinaryStream(long pos, long length) throws SQLException
95 {
96 throw new SQLException("TestBlob does not support getBinaryStream(long, long)");
97 }
98 }