11/*
2- * Copyright 2002-2013 the original author or authors.
2+ * Copyright 2002-2014 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2626import java .sql .SQLException ;
2727
2828import org .junit .Test ;
29+
2930import org .springframework .jdbc .support .lob .DefaultLobHandler ;
3031import org .springframework .jdbc .support .lob .LobCreator ;
3132import org .springframework .jdbc .support .lob .LobHandler ;
3940public class DefaultLobHandlerTests {
4041
4142 private ResultSet rs = mock (ResultSet .class );
43+
4244 private PreparedStatement ps = mock (PreparedStatement .class );
45+
4346 private LobHandler lobHandler = new DefaultLobHandler ();
47+
4448 private LobCreator lobCreator = lobHandler .getLobCreator ();
4549
50+
4651 @ Test
4752 public void testGetBlobAsBytes () throws SQLException {
4853 lobHandler .getBlobAsBytes (rs , 1 );
@@ -82,12 +87,18 @@ public void testSetBlobAsBytes() throws SQLException {
8287
8388 @ Test
8489 public void testSetBlobAsBinaryStream () throws SQLException , IOException {
85-
8690 InputStream bis = new ByteArrayInputStream ("testContent" .getBytes ());
8791 lobCreator .setBlobAsBinaryStream (ps , 1 , bis , 11 );
8892 verify (ps ).setBinaryStream (1 , bis , 11 );
8993 }
9094
95+ @ Test
96+ public void testSetBlobAsBinaryStreamWithoutLength () throws SQLException , IOException {
97+ InputStream bis = new ByteArrayInputStream ("testContent" .getBytes ());
98+ lobCreator .setBlobAsBinaryStream (ps , 1 , bis , -1 );
99+ verify (ps ).setBinaryStream (1 , bis );
100+ }
101+
91102 @ Test
92103 public void testSetClobAsString () throws SQLException , IOException {
93104 String content = "testContent" ;
@@ -102,11 +113,25 @@ public void testSetClobAsAsciiStream() throws SQLException, IOException {
102113 verify (ps ).setAsciiStream (1 , bis , 11 );
103114 }
104115
116+ @ Test
117+ public void testSetClobAsAsciiStreamWithoutLength () throws SQLException , IOException {
118+ InputStream bis = new ByteArrayInputStream ("testContent" .getBytes ());
119+ lobCreator .setClobAsAsciiStream (ps , 1 , bis , -1 );
120+ verify (ps ).setAsciiStream (1 , bis );
121+ }
122+
105123 @ Test
106124 public void testSetClobAsCharacterStream () throws SQLException , IOException {
107125 Reader str = new StringReader ("testContent" );
108126 lobCreator .setClobAsCharacterStream (ps , 1 , str , 11 );
109127 verify (ps ).setCharacterStream (1 , str , 11 );
110128 }
111129
130+ @ Test
131+ public void testSetClobAsCharacterStreamWithoutLength () throws SQLException , IOException {
132+ Reader str = new StringReader ("testContent" );
133+ lobCreator .setClobAsCharacterStream (ps , 1 , str , -1 );
134+ verify (ps ).setCharacterStream (1 , str );
135+ }
136+
112137}
0 commit comments