@@ -48,6 +48,7 @@ public class JdbcTestUtilsTests {
48
48
@ Mock
49
49
private JdbcTemplate jdbcTemplate ;
50
50
51
+
51
52
@ Test
52
53
public void containsDelimiters () {
53
54
assertTrue ("test with ';' is wrong" , !JdbcTestUtils .containsSqlScriptDelimiters ("select 1\n select ';'" , ';' ));
@@ -117,6 +118,33 @@ public void readAndSplitScriptContainingComments() throws Exception {
117
118
assertEquals ("statement 4 not split correctly" , statement4 , statements .get (3 ));
118
119
}
119
120
121
+ /**
122
+ * See <a href="https://jira.springsource.org/browse/SPR-10330">SPR-10330</a>
123
+ * @since 4.0
124
+ */
125
+ @ Test
126
+ public void readAndSplitScriptContainingCommentsWithLeadingTabs () throws Exception {
127
+
128
+ EncodedResource resource = new EncodedResource (new ClassPathResource (
129
+ "test-data-with-comments-and-leading-tabs.sql" , getClass ()));
130
+ LineNumberReader lineNumberReader = new LineNumberReader (resource .getReader ());
131
+
132
+ String script = JdbcTestUtils .readScript (lineNumberReader );
133
+
134
+ char delim = ';' ;
135
+ List <String > statements = new ArrayList <String >();
136
+ JdbcTestUtils .splitSqlScript (script , delim , statements );
137
+
138
+ String statement1 = "insert into customer (id, name) values (1, 'Sam Brannen')" ;
139
+ String statement2 = "insert into orders(id, order_date, customer_id) values (1, '2013-06-08', 1)" ;
140
+ String statement3 = "insert into orders(id, order_date, customer_id) values (2, '2013-06-08', 1)" ;
141
+
142
+ assertEquals ("wrong number of statements" , 3 , statements .size ());
143
+ assertEquals ("statement 1 not split correctly" , statement1 , statements .get (0 ));
144
+ assertEquals ("statement 2 not split correctly" , statement2 , statements .get (1 ));
145
+ assertEquals ("statement 3 not split correctly" , statement3 , statements .get (2 ));
146
+ }
147
+
120
148
@ Test
121
149
public void deleteWithoutWhereClause () throws Exception {
122
150
given (jdbcTemplate .update ("DELETE FROM person" )).willReturn (10 );
0 commit comments