Skip to content

Commit 904a42c

Browse files
committed
added testcase related to migrations http://code.google.com/p/mybatis/issues/detail?id=561
1 parent 1bac47f commit 904a42c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--
2+
-- Copyright 2009-2012 The MyBatis Team
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
--
16+
17+
ALTER TABLE product ALTER COLUMN name varchar(80); -- that should not make the ScriptRunner failing

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ public void shouldReturnWarningIfEndOfLineTerminatorNotFound() throws Exception
101101
}
102102
}
103103

104+
@Test
105+
public void commentAferStatementDelimiterShouldNotCauseRunnerFail() throws Exception {
106+
DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
107+
Connection conn = ds.getConnection();
108+
ScriptRunner runner = new ScriptRunner(conn);
109+
runner.setAutoCommit(true);
110+
runner.setStopOnError(true);
111+
112+
String resource = "org/apache/ibatis/jdbc/ScriptCommentAfterEOLTerminator.sql";
113+
Reader reader = Resources.getResourceAsReader(resource);
114+
115+
try {
116+
runner.runScript(reader);
117+
} catch (Exception e) {
118+
e.printStackTrace();
119+
fail(e.getMessage());
120+
}
121+
}
122+
104123
private void runJPetStoreScripts(ScriptRunner runner) throws IOException, SQLException {
105124
runScript(runner, JPETSTORE_DDL);
106125
runScript(runner, JPETSTORE_DATA);

0 commit comments

Comments
 (0)