@Test public void test3() throws SQLException { SqlLobValue lob = new SqlLobValue(new InputStreamReader(new ByteArrayInputStream("Bla".getBytes())), 12); thrown.expect(IllegalArgumentException.class); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); }
lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); fail("IllegalArgumentException should have been thrown"); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); fail("IllegalArgumentException should have been thrown");
@Test public void test7() throws SQLException { SqlLobValue lob = new SqlLobValue("bla".getBytes()); thrown.expect(IllegalArgumentException.class); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); }
@Test public void test5() throws Exception { byte[] testContent = "Bla".getBytes(); SqlLobValue lob = new SqlLobValue(new ByteArrayInputStream(testContent), 3, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); verify(creator).setClobAsAsciiStream(eq(preparedStatement), eq(1), inputStreamCaptor.capture(), eq(3)); byte[] bytes = new byte[3]; inputStreamCaptor.getValue().read(bytes); assertThat(bytes, equalTo(testContent)); }
@Test public void test2() throws SQLException { String testString = "Bla"; SqlLobValue lob = new SqlLobValue(testString, handler); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); verify(creator).setBlobAsBytes(preparedStatement, 1, testString.getBytes()); }
@Test public void test1() throws SQLException { byte[] testBytes = "Bla".getBytes(); SqlLobValue lob = new SqlLobValue(testBytes, handler); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); verify(creator).setBlobAsBytes(preparedStatement, 1, testBytes); }
@Test public void testOtherSqlType() throws SQLException { SqlLobValue lob = new SqlLobValue("Bla", handler); thrown.expect(IllegalArgumentException.class); lob.setTypeValue(preparedStatement, 1, Types.SMALLINT, "test"); }
@Test public void test6() throws SQLException { byte[] testContent = "Bla".getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(testContent); InputStreamReader reader = new InputStreamReader(bais); SqlLobValue lob = new SqlLobValue(reader, 3, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); verify(creator).setClobAsCharacterStream(eq(preparedStatement), eq(1), eq(reader), eq(3)); }
@Test public void test4() throws SQLException { String testContent = "Bla"; SqlLobValue lob = new SqlLobValue(testContent, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); verify(creator).setClobAsString(preparedStatement, 1, testContent); }
@Test public void testCorrectCleanup() throws SQLException { SqlLobValue lob = new SqlLobValue("Bla", handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); lob.cleanup(); verify(creator).setClobAsString(preparedStatement, 1, "Bla"); verify(creator).close(); }