Source Code Cross Referenced for AbstractSQLChangeTest.java in  » Database-Client » LiquiBase » liquibase » change » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » LiquiBase » liquibase.change 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package liquibase.change;
002:
003:        import liquibase.database.MSSQLDatabase;
004:        import liquibase.database.OracleDatabase;
005:        import liquibase.database.sql.SqlStatement;
006:        import liquibase.exception.StatementNotSupportedOnDatabaseException;
007:        import liquibase.exception.UnsupportedChangeException;
008:        import liquibase.util.XMLUtil;
009:        import static org.junit.Assert.*;
010:        import org.junit.Before;
011:        import org.junit.Test;
012:        import org.w3c.dom.Element;
013:
014:        import javax.xml.parsers.DocumentBuilderFactory;
015:
016:        public class AbstractSQLChangeTest extends AbstractChangeTest {
017:
018:            private RawSQLChange refactoring;
019:
020:            @Before
021:            public void setUp() throws Exception {
022:                refactoring = new RawSQLChange();
023:            }
024:
025:            @Test
026:            public void getRefactoringName() throws Exception {
027:                assertEquals("Custom SQL", new RawSQLChange().getChangeName());
028:            }
029:
030:            @Test
031:            public void generateStatement() throws Exception {
032:                refactoring.setSql("SQL STATEMENT HERE");
033:                OracleDatabase database = new OracleDatabase();
034:                assertEquals("SQL STATEMENT HERE", refactoring
035:                        .generateStatements(database)[0]
036:                        .getSqlStatement(database));
037:            }
038:
039:            @Test
040:            public void getConfirmationMessage() throws Exception {
041:                assertEquals("Custom SQL executed", refactoring
042:                        .getConfirmationMessage());
043:            }
044:
045:            @Test
046:            public void createNode() throws Exception {
047:                refactoring.setSql("SOME SQL HERE");
048:
049:                Element element = refactoring.createNode(DocumentBuilderFactory
050:                        .newInstance().newDocumentBuilder().newDocument());
051:                assertEquals("sql", element.getTagName());
052:
053:                assertEquals("SOME SQL HERE", XMLUtil.getTextContent(element));
054:            }
055:
056:            @Test
057:            public void multiLineSQLFileSemiColon() throws Exception {
058:                SQLFileChange change2 = new SQLFileChange();
059:                change2.setSql("SELECT * FROM customer;\n"
060:                        + "SELECT * from table;");
061:                OracleDatabase database = new OracleDatabase();
062:                SqlStatement[] statements = change2
063:                        .generateStatements(database);
064:
065:                assertEquals(2, statements.length);
066:                assertEquals("SELECT * FROM customer", statements[0]
067:                        .getSqlStatement(database));
068:                assertEquals("SELECT * from table", statements[1]
069:                        .getSqlStatement(database));
070:            }
071:
072:            @Test
073:            public void singleLineEndInSemiColon() throws Exception {
074:                SQLFileChange change2 = new SQLFileChange();
075:                change2.setSql("SELECT * FROM customer;");
076:                OracleDatabase database = new OracleDatabase();
077:                SqlStatement[] statements = change2
078:                        .generateStatements(database);
079:                assertEquals(1, statements.length);
080:                assertEquals("SELECT * FROM customer", statements[0]
081:                        .getSqlStatement(database));
082:            }
083:
084:            @Test
085:            public void singleLineEndGo() throws Exception {
086:                SQLFileChange change2 = new SQLFileChange();
087:                change2.setSql("SELECT * FROM customer\ngo");
088:                MSSQLDatabase database = new MSSQLDatabase();
089:                SqlStatement[] statements = change2
090:                        .generateStatements(database);
091:                assertEquals(1, statements.length);
092:                assertEquals("SELECT * FROM customer", statements[0]
093:                        .getSqlStatement(database));
094:            }
095:
096:            @Test
097:            public void singleLineBeginGo() throws Exception {
098:                SQLFileChange change2 = new SQLFileChange();
099:                change2.setSql("goSELECT * FROM customer\ngo");
100:                MSSQLDatabase database = new MSSQLDatabase();
101:                SqlStatement[] statements = change2
102:                        .generateStatements(database);
103:                assertEquals(1, statements.length);
104:                assertEquals("goSELECT * FROM customer", statements[0]
105:                        .getSqlStatement(database));
106:            }
107:
108:            @Test
109:            public void multiLineSQLFileGoShouldFind() throws Exception {
110:                SQLFileChange change2 = new SQLFileChange();
111:                change2.setSql("SELECT * FROM customer\ngo\n"
112:                        + "SELECT * from table\ngo");
113:                MSSQLDatabase database = new MSSQLDatabase();
114:                SqlStatement[] statements = change2
115:                        .generateStatements(database);
116:                assertEquals(2, statements.length);
117:                assertEquals("SELECT * FROM customer", statements[0]
118:                        .getSqlStatement(database));
119:                assertEquals("SELECT * from table", statements[1]
120:                        .getSqlStatement(database));
121:            }
122:
123:            @Test
124:            public void multiLineSQLFileGoShouldNotFind() throws Exception {
125:                SQLFileChange change2 = new SQLFileChange();
126:                change2.setSql("SELECT * FROM go\ngo\n"
127:                        + "SELECT * from gogo\ngo\n");
128:                MSSQLDatabase database = new MSSQLDatabase();
129:                SqlStatement[] statements = change2
130:                        .generateStatements(database);
131:
132:                assertEquals(2, statements.length);
133:                assertEquals("SELECT * FROM go", statements[0]
134:                        .getSqlStatement(database));
135:                assertEquals("SELECT * from gogo", statements[1]
136:                        .getSqlStatement(database));
137:            }
138:
139:            @Test
140:            public void stripComments() throws UnsupportedChangeException,
141:                    StatementNotSupportedOnDatabaseException {
142:                SQLFileChange change2 = new SQLFileChange();
143:                change2.setSql("SELECT * FROM x\n -- A comment");
144:                change2.setStripComments(true);
145:                MSSQLDatabase database = new MSSQLDatabase();
146:                SqlStatement[] statements = change2
147:                        .generateStatements(database);
148:
149:                assertEquals(1, statements.length);
150:                assertEquals("SELECT * FROM x\n", statements[0]
151:                        .getSqlStatement(database));
152:            }
153:
154:            @Test
155:            public void turnOffSplitting() throws UnsupportedChangeException,
156:                    StatementNotSupportedOnDatabaseException {
157:                SQLFileChange change2 = new SQLFileChange();
158:                change2.setSql("SELECT * FROM x;SELECT * FROM x;");
159:                change2.setSplitStatements(false);
160:                MSSQLDatabase database = new MSSQLDatabase();
161:                SqlStatement[] statements = change2
162:                        .generateStatements(database);
163:
164:                assertEquals(1, statements.length);
165:                assertEquals("SELECT * FROM x;SELECT * FROM x;", statements[0]
166:                        .getSqlStatement(database));
167:            }
168:
169:            @Test
170:            public void defaultSplittingAndNoStripping() throws Exception {
171:                SQLFileChange change2 = new SQLFileChange();
172:                change2
173:                        .setSql("SELECT * FROM x;\n/*A Comment*/SELECT * FROM x;");
174:
175:                MSSQLDatabase database = new MSSQLDatabase();
176:                SqlStatement[] statements = change2
177:                        .generateStatements(database);
178:
179:                assertEquals(2, statements.length);
180:                assertEquals("SELECT * FROM x", statements[0]
181:                        .getSqlStatement(database));
182:                assertEquals("/*A Comment*/SELECT * FROM x", statements[1]
183:                        .getSqlStatement(database));
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.