#516 - DdlParser for seed and init sql is not ignoring sql comment lines (starting with --)

This commit is contained in:
Robin Bygrave
2016-01-07 14:03:17 +13:00
parent c7300a1707
commit 0351a15067
2 changed files with 63 additions and 0 deletions
@@ -0,0 +1,58 @@
package com.avaje.ebean.dbmigration;
import org.junit.Test;
import java.io.StringReader;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class DdlParserTest {
DdlParser parser = new DdlParser();
@Test
public void parse_ignoresEmptyLines() throws Exception {
List<String> stmts = parser.parse(new StringReader("\n\none;\n\ntwo;\n\n"));
assertThat(stmts).hasSize(2);
assertThat(stmts).contains("one;","two;");
}
@Test
public void parse_ignoresComments_whenFirst() throws Exception {
List<String> stmts = parser.parse(new StringReader("-- comment\ntwo;"));
assertThat(stmts).hasSize(1);
assertThat(stmts).contains("two;");
}
@Test
public void parse_ignoresEmptyLines_whenFirst() throws Exception {
List<String> stmts = parser.parse(new StringReader("\n\n-- comment\ntwo;\n\n"));
assertThat(stmts).hasSize(1);
assertThat(stmts).contains("two;");
}
@Test
public void parse_inlineEmptyLines_replacedWithSpace() throws Exception {
List<String> stmts = parser.parse(new StringReader("\n\n-- comment\none\ntwo;\n\n"));
assertThat(stmts).hasSize(1);
assertThat(stmts).contains("one two;");
}
@Test
public void parse_ignoresComments() throws Exception {
List<String> stmts = parser.parse(new StringReader("one;\n-- comment\ntwo;"));
assertThat(stmts).hasSize(2);
assertThat(stmts).contains("one;","two;");
}
}