11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2016 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.
@@ -50,7 +50,7 @@ public void splitSqlScriptDelimitedWithSemicolon() {
5050 String cleanedStatement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)" ;
5151 char delim = ';' ;
5252 String script = rawStatement1 + delim + rawStatement2 + delim + rawStatement3 + delim ;
53- List <String > statements = new ArrayList <String >();
53+ List <String > statements = new ArrayList <>();
5454 splitSqlScript (script , delim , statements );
5555 assertEquals ("wrong number of statements" , 3 , statements .size ());
5656 assertEquals ("statement 1 not split correctly" , cleanedStatement1 , statements .get (0 ));
@@ -65,7 +65,7 @@ public void splitSqlScriptDelimitedWithNewLine() {
6565 String statement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)" ;
6666 char delim = '\n' ;
6767 String script = statement1 + delim + statement2 + delim + statement3 + delim ;
68- List <String > statements = new ArrayList <String >();
68+ List <String > statements = new ArrayList <>();
6969 splitSqlScript (script , delim , statements );
7070 assertEquals ("wrong number of statements" , 3 , statements .size ());
7171 assertEquals ("statement 1 not split correctly" , statement1 , statements .get (0 ));
@@ -79,36 +79,30 @@ public void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() {
7979 String statement2 = "do something else" ;
8080 char delim = '\n' ;
8181 String script = statement1 + delim + statement2 + delim ;
82- List <String > statements = new ArrayList <String >();
82+ List <String > statements = new ArrayList <>();
8383 splitSqlScript (script , DEFAULT_STATEMENT_SEPARATOR , statements );
8484 assertEquals ("wrong number of statements" , 1 , statements .size ());
8585 assertEquals ("script should have been 'stripped' but not actually 'split'" , script .replace ('\n' , ' ' ),
8686 statements .get (0 ));
8787 }
8888
89- /**
90- * See <a href="https://jira.spring.io/browse/SPR-13218">SPR-13218</a>
91- */
92- @ Test
89+ @ Test // SPR-13218
9390 public void splitScriptWithSingleQuotesNestedInsideDoubleQuotes () throws Exception {
9491 String statement1 = "select '1' as \" Dogbert's owner's\" from dual" ;
9592 String statement2 = "select '2' as \" Dilbert's\" from dual" ;
9693 char delim = ';' ;
9794 String script = statement1 + delim + statement2 + delim ;
98- List <String > statements = new ArrayList <String >();
95+ List <String > statements = new ArrayList <>();
9996 splitSqlScript (script , ';' , statements );
10097 assertEquals ("wrong number of statements" , 2 , statements .size ());
10198 assertEquals ("statement 1 not split correctly" , statement1 , statements .get (0 ));
10299 assertEquals ("statement 2 not split correctly" , statement2 , statements .get (1 ));
103100 }
104101
105- /**
106- * See <a href="https://jira.spring.io/browse/SPR-11560">SPR-11560</a>
107- */
108- @ Test
102+ @ Test // SPR-11560
109103 public void readAndSplitScriptWithMultipleNewlinesAsSeparator () throws Exception {
110104 String script = readScript ("db-test-data-multi-newline.sql" );
111- List <String > statements = new ArrayList <String >();
105+ List <String > statements = new ArrayList <>();
112106 splitSqlScript (script , "\n \n " , statements );
113107
114108 String statement1 = "insert into T_TEST (NAME) values ('Keith')" ;
@@ -122,7 +116,7 @@ public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception
122116 @ Test
123117 public void readAndSplitScriptContainingComments () throws Exception {
124118 String script = readScript ("test-data-with-comments.sql" );
125- List <String > statements = new ArrayList <String >();
119+ List <String > statements = new ArrayList <>();
126120 splitSqlScript (script , ';' , statements );
127121
128122 String statement1 = "insert into customer (id, name) values (1, 'Rod; Johnson'), (2, 'Adrian Collier')" ;
@@ -138,13 +132,10 @@ public void readAndSplitScriptContainingComments() throws Exception {
138132 assertEquals ("statement 4 not split correctly" , statement4 , statements .get (3 ));
139133 }
140134
141- /**
142- * See <a href="https://jira.spring.io/browse/SPR-10330">SPR-10330</a>
143- */
144- @ Test
135+ @ Test // SPR-10330
145136 public void readAndSplitScriptContainingCommentsWithLeadingTabs () throws Exception {
146137 String script = readScript ("test-data-with-comments-and-leading-tabs.sql" );
147- List <String > statements = new ArrayList <String >();
138+ List <String > statements = new ArrayList <>();
148139 splitSqlScript (script , ';' , statements );
149140
150141 String statement1 = "insert into customer (id, name) values (1, 'Sam Brannen')" ;
@@ -157,13 +148,10 @@ public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Excepti
157148 assertEquals ("statement 3 not split correctly" , statement3 , statements .get (2 ));
158149 }
159150
160- /**
161- * See <a href="https://jira.spring.io/browse/SPR-9531">SPR-9531</a>
162- */
163- @ Test
151+ @ Test // SPR-9531
164152 public void readAndSplitScriptContainingMuliLineComments () throws Exception {
165153 String script = readScript ("test-data-with-multi-line-comments.sql" );
166- List <String > statements = new ArrayList <String >();
154+ List <String > statements = new ArrayList <>();
167155 splitSqlScript (script , ';' , statements );
168156
169157 String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')" ;
@@ -176,10 +164,12 @@ public void readAndSplitScriptContainingMuliLineComments() throws Exception {
176164
177165 @ Test
178166 public void containsDelimiters () {
179- assertTrue ("test with ';' is wrong" , !containsSqlScriptDelimiters ("select 1\n select ';'" , ";" ));
180- assertTrue ("test with delimiter ; is wrong" , containsSqlScriptDelimiters ("select 1; select 2" , ";" ));
181- assertTrue ("test with '\\ n' is wrong" , !containsSqlScriptDelimiters ("select 1; select '\\ n\n ';" , "\n " ));
182- assertTrue ("test with delimiter \\ n is wrong" , containsSqlScriptDelimiters ("select 1\n select 2" , "\n " ));
167+ assertFalse (containsSqlScriptDelimiters ("select 1\n select ';'" , ";" ));
168+ assertTrue (containsSqlScriptDelimiters ("select 1; select 2" , ";" ));
169+ assertFalse (containsSqlScriptDelimiters ("select 1; select '\\ n\n ';" , "\n " ));
170+ assertTrue (containsSqlScriptDelimiters ("select 1\n select 2" , "\n " ));
171+ assertFalse (containsSqlScriptDelimiters ("select 1\n select 2" , "\n \n " ));
172+ assertTrue (containsSqlScriptDelimiters ("select 1\n \n select 2" , "\n \n " ));
183173 }
184174
185175 private String readScript (String path ) throws Exception {
0 commit comments