From 9e9d968f030de1b74a27cd329e0690b064e4a8d0 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 25 Mar 2018 14:15:27 +0900 Subject: [PATCH] Fix to refer the line separator from system property on ScriptRunnerTest #1230 --- .../apache/ibatis/jdbc/ScriptRunnerTest.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java b/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java index 017981b230b..2df2cf16b07 100644 --- a/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java +++ b/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java @@ -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. @@ -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 { @@ -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 @@ -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 { @@ -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 @@ -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)); } }