Skip to content

Commit 35628fb

Browse files
authored
Merge pull request #1232 from kazuki43zoo/gh-1230_fix-ScriptRunnerTest
Fix to refer the line separator from system property on ScriptRunnerTest #1230
2 parents 2f15fcd + 9e9d968 commit 35628fb

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 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.
@@ -41,6 +41,8 @@
4141

4242
public class ScriptRunnerTest extends BaseDataTest {
4343

44+
private static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");
45+
4446
@Test
4547
@Ignore("This fails with HSQLDB 2.0 due to the create index statements in the schema script")
4648
public void shouldRunScriptsBySendingFullScriptAtOnce() throws Exception {
@@ -198,9 +200,9 @@ public void testLogging() throws Exception {
198200
conn.close();
199201

200202
assertEquals(
201-
"select userid from account where userid = 'j2ee'" + System.getProperty("line.separator")
202-
+ System.getProperty("line.separator") + "USERID\t" + System.getProperty("line.separator")
203-
+ "j2ee\t" + System.getProperty("line.separator"), sw.toString());
203+
"select userid from account where userid = 'j2ee'" + LINE_SEPARATOR
204+
+ LINE_SEPARATOR + "USERID\t" + LINE_SEPARATOR
205+
+ "j2ee\t" + LINE_SEPARATOR, sw.toString());
204206
}
205207

206208
@Test
@@ -221,9 +223,9 @@ public void testLoggingFullScipt() throws Exception {
221223
conn.close();
222224

223225
assertEquals(
224-
"select userid from account where userid = 'j2ee';" + System.getProperty("line.separator")
225-
+ System.getProperty("line.separator") + "USERID\t" + System.getProperty("line.separator")
226-
+ "j2ee\t" + System.getProperty("line.separator"), sw.toString());
226+
"select userid from account where userid = 'j2ee';" + LINE_SEPARATOR
227+
+ LINE_SEPARATOR + "USERID\t" + LINE_SEPARATOR
228+
+ "j2ee\t" + LINE_SEPARATOR, sw.toString());
227229
}
228230

229231
private void runJPetStoreScripts(ScriptRunner runner) throws IOException, SQLException {
@@ -264,10 +266,10 @@ public void shouldAcceptDelimiterVariations() throws Exception {
264266
Reader reader = new StringReader(sql);
265267
runner.runScript(reader);
266268

267-
verify(stmt, Mockito.times(1)).execute(eq("line 1;\n" + "line 2;\n\n"));
268-
verify(stmt, Mockito.times(1)).execute(eq("line 3\n"));
269-
verify(stmt, Mockito.times(1)).execute(eq("line 4\n"));
270-
verify(stmt, Mockito.times(1)).execute(eq("line 5\n"));
269+
verify(stmt, Mockito.times(1)).execute(eq("line 1;" + LINE_SEPARATOR + "line 2;" + LINE_SEPARATOR + LINE_SEPARATOR));
270+
verify(stmt, Mockito.times(1)).execute(eq("line 3" + LINE_SEPARATOR));
271+
verify(stmt, Mockito.times(1)).execute(eq("line 4" + LINE_SEPARATOR));
272+
verify(stmt, Mockito.times(1)).execute(eq("line 5" + LINE_SEPARATOR));
271273
}
272274

273275
@Test
@@ -298,7 +300,7 @@ public void shouldAcceptMultiCharDelimiter() throws Exception {
298300
Reader reader = new StringReader(sql);
299301
runner.runScript(reader);
300302

301-
verify(stmt, Mockito.times(1)).execute(eq("line 1;\n" + "line 2;\n\n"));
302-
verify(stmt, Mockito.times(1)).execute(eq("line 3\n"));
303+
verify(stmt, Mockito.times(1)).execute(eq("line 1;" + LINE_SEPARATOR + "line 2;" + LINE_SEPARATOR + LINE_SEPARATOR));
304+
verify(stmt, Mockito.times(1)).execute(eq("line 3" + LINE_SEPARATOR));
303305
}
304306
}

0 commit comments

Comments
 (0)