1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
26
26
import java .sql .SQLException ;
27
27
28
28
import org .junit .Test ;
29
+
29
30
import org .springframework .jdbc .support .lob .DefaultLobHandler ;
30
31
import org .springframework .jdbc .support .lob .LobCreator ;
31
32
import org .springframework .jdbc .support .lob .LobHandler ;
39
40
public class DefaultLobHandlerTests {
40
41
41
42
private ResultSet rs = mock (ResultSet .class );
43
+
42
44
private PreparedStatement ps = mock (PreparedStatement .class );
45
+
43
46
private LobHandler lobHandler = new DefaultLobHandler ();
47
+
44
48
private LobCreator lobCreator = lobHandler .getLobCreator ();
45
49
50
+
46
51
@ Test
47
52
public void testGetBlobAsBytes () throws SQLException {
48
53
lobHandler .getBlobAsBytes (rs , 1 );
@@ -82,12 +87,18 @@ public void testSetBlobAsBytes() throws SQLException {
82
87
83
88
@ Test
84
89
public void testSetBlobAsBinaryStream () throws SQLException , IOException {
85
-
86
90
InputStream bis = new ByteArrayInputStream ("testContent" .getBytes ());
87
91
lobCreator .setBlobAsBinaryStream (ps , 1 , bis , 11 );
88
92
verify (ps ).setBinaryStream (1 , bis , 11 );
89
93
}
90
94
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
+
91
102
@ Test
92
103
public void testSetClobAsString () throws SQLException , IOException {
93
104
String content = "testContent" ;
@@ -102,11 +113,25 @@ public void testSetClobAsAsciiStream() throws SQLException, IOException {
102
113
verify (ps ).setAsciiStream (1 , bis , 11 );
103
114
}
104
115
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
+
105
123
@ Test
106
124
public void testSetClobAsCharacterStream () throws SQLException , IOException {
107
125
Reader str = new StringReader ("testContent" );
108
126
lobCreator .setClobAsCharacterStream (ps , 1 , str , 11 );
109
127
verify (ps ).setCharacterStream (1 , str , 11 );
110
128
}
111
129
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
+
112
137
}
0 commit comments