|
|
|
@ -65,6 +65,15 @@ class SqlBinaryValueTests { |
|
|
|
verify(ps).setBinaryStream(1, content, 3L); |
|
|
|
verify(ps).setBinaryStream(1, content, 3L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withInputStreamUndeterminedLength() throws SQLException { |
|
|
|
|
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
|
|
|
|
SqlBinaryValue value = new SqlBinaryValue(content, -1); |
|
|
|
|
|
|
|
PreparedStatement ps = mock(); |
|
|
|
|
|
|
|
value.setTypeValue(ps, 1, JdbcUtils.TYPE_UNKNOWN, null); |
|
|
|
|
|
|
|
verify(ps).setBinaryStream(1, content); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void withInputStreamForBlob() throws SQLException { |
|
|
|
void withInputStreamForBlob() throws SQLException { |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
@ -74,6 +83,15 @@ class SqlBinaryValueTests { |
|
|
|
verify(ps).setBlob(1, content, 3L); |
|
|
|
verify(ps).setBlob(1, content, 3L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withInputStreamForBlobUndeterminedLength() throws SQLException { |
|
|
|
|
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
|
|
|
|
SqlBinaryValue value = new SqlBinaryValue(content, -1); |
|
|
|
|
|
|
|
PreparedStatement ps = mock(); |
|
|
|
|
|
|
|
value.setTypeValue(ps, 1, Types.BLOB, null); |
|
|
|
|
|
|
|
verify(ps).setBlob(1, content); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void withInputStreamSource() throws SQLException { |
|
|
|
void withInputStreamSource() throws SQLException { |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
@ -83,6 +101,15 @@ class SqlBinaryValueTests { |
|
|
|
verify(ps).setBinaryStream(1, content, 3L); |
|
|
|
verify(ps).setBinaryStream(1, content, 3L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withInputStreamSourceUndeterminedLength() throws SQLException { |
|
|
|
|
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
|
|
|
|
SqlBinaryValue value = new SqlBinaryValue(() -> content, -1); |
|
|
|
|
|
|
|
PreparedStatement ps = mock(); |
|
|
|
|
|
|
|
value.setTypeValue(ps, 1, JdbcUtils.TYPE_UNKNOWN, null); |
|
|
|
|
|
|
|
verify(ps).setBinaryStream(1, content); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void withInputStreamSourceForBlob() throws SQLException { |
|
|
|
void withInputStreamSourceForBlob() throws SQLException { |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
@ -92,6 +119,15 @@ class SqlBinaryValueTests { |
|
|
|
verify(ps).setBlob(1, content, 3L); |
|
|
|
verify(ps).setBlob(1, content, 3L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withInputStreamSourceForBlobUndeterminedLength() throws SQLException { |
|
|
|
|
|
|
|
InputStream content = new ByteArrayInputStream(new byte[] {0, 1, 2}); |
|
|
|
|
|
|
|
SqlBinaryValue value = new SqlBinaryValue(() -> content, -1); |
|
|
|
|
|
|
|
PreparedStatement ps = mock(); |
|
|
|
|
|
|
|
value.setTypeValue(ps, 1, Types.BLOB, null); |
|
|
|
|
|
|
|
verify(ps).setBlob(1, content); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void withResource() throws SQLException { |
|
|
|
void withResource() throws SQLException { |
|
|
|
byte[] content = new byte[] {0, 1, 2}; |
|
|
|
byte[] content = new byte[] {0, 1, 2}; |
|
|
|
|