01: package liquibase.change;
02:
03: import liquibase.database.OracleDatabase;
04: import liquibase.util.XMLUtil;
05: import static org.junit.Assert.*;
06: import org.junit.Before;
07: import org.junit.Test;
08: import org.w3c.dom.Element;
09:
10: import javax.xml.parsers.DocumentBuilderFactory;
11:
12: /**
13: * Tests for {@link RawSQLChange}
14: */
15: public class RawSQLChangeTest extends AbstractChangeTest {
16:
17: private RawSQLChange refactoring;
18:
19: @Before
20: public void setUp() throws Exception {
21: refactoring = new RawSQLChange();
22: }
23:
24: @Test
25: public void getRefactoringName() throws Exception {
26: assertEquals("Custom SQL", new RawSQLChange().getChangeName());
27: }
28:
29: @Test
30: public void generateStatement() throws Exception {
31: refactoring.setSql("SQL STATEMENT HERE");
32: OracleDatabase database = new OracleDatabase();
33: assertEquals("SQL STATEMENT HERE", refactoring
34: .generateStatements(database)[0]
35: .getSqlStatement(database));
36: }
37:
38: @Test
39: public void getConfirmationMessage() throws Exception {
40: assertEquals("Custom SQL executed", refactoring
41: .getConfirmationMessage());
42: }
43:
44: @Test
45: public void createNode() throws Exception {
46: refactoring.setSql("SOME SQL HERE");
47:
48: Element element = refactoring.createNode(DocumentBuilderFactory
49: .newInstance().newDocumentBuilder().newDocument());
50: assertEquals("sql", element.getTagName());
51:
52: assertEquals("SOME SQL HERE", XMLUtil.getTextContent(element));
53: }
54: }
|