Skip to content

Commit

Permalink
Merge pull request mybatis#1232 from kazuki43zoo/gh-1230_fix-ScriptRu…
Browse files Browse the repository at this point in the history
…nnerTest

Fix to refer the line separator from system property on ScriptRunnerTest mybatis#1230
  • Loading branch information
kazuki43zoo committed Mar 25, 2018
2 parents 2f15fcd + 9e9d968 commit 35628fb
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,6 +41,8 @@

public class ScriptRunnerTest extends BaseDataTest {

private static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");

@Test
@Ignore("This fails with HSQLDB 2.0 due to the create index statements in the schema script")
public void shouldRunScriptsBySendingFullScriptAtOnce() throws Exception {
Expand Down Expand Up @@ -198,9 +200,9 @@ public void testLogging() throws Exception {
conn.close();

assertEquals(
"select userid from account where userid = 'j2ee'" + System.getProperty("line.separator")
+ System.getProperty("line.separator") + "USERID\t" + System.getProperty("line.separator")
+ "j2ee\t" + System.getProperty("line.separator"), sw.toString());
"select userid from account where userid = 'j2ee'" + LINE_SEPARATOR
+ LINE_SEPARATOR + "USERID\t" + LINE_SEPARATOR
+ "j2ee\t" + LINE_SEPARATOR, sw.toString());
}

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

assertEquals(
"select userid from account where userid = 'j2ee';" + System.getProperty("line.separator")
+ System.getProperty("line.separator") + "USERID\t" + System.getProperty("line.separator")
+ "j2ee\t" + System.getProperty("line.separator"), sw.toString());
"select userid from account where userid = 'j2ee';" + LINE_SEPARATOR
+ LINE_SEPARATOR + "USERID\t" + LINE_SEPARATOR
+ "j2ee\t" + LINE_SEPARATOR, sw.toString());
}

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

verify(stmt, Mockito.times(1)).execute(eq("line 1;\n" + "line 2;\n\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 3\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 4\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 5\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 1;" + LINE_SEPARATOR + "line 2;" + LINE_SEPARATOR + LINE_SEPARATOR));
verify(stmt, Mockito.times(1)).execute(eq("line 3" + LINE_SEPARATOR));
verify(stmt, Mockito.times(1)).execute(eq("line 4" + LINE_SEPARATOR));
verify(stmt, Mockito.times(1)).execute(eq("line 5" + LINE_SEPARATOR));
}

@Test
Expand Down Expand Up @@ -298,7 +300,7 @@ public void shouldAcceptMultiCharDelimiter() throws Exception {
Reader reader = new StringReader(sql);
runner.runScript(reader);

verify(stmt, Mockito.times(1)).execute(eq("line 1;\n" + "line 2;\n\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 3\n"));
verify(stmt, Mockito.times(1)).execute(eq("line 1;" + LINE_SEPARATOR + "line 2;" + LINE_SEPARATOR + LINE_SEPARATOR));
verify(stmt, Mockito.times(1)).execute(eq("line 3" + LINE_SEPARATOR));
}
}

0 comments on commit 35628fb

Please sign in to comment.