Source Code Cross Referenced for AlterSequenceStatementTest.java in  » Database-Client » LiquiBase » liquibase » database » sql » 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.database.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package liquibase.database.sql;
002:
003:        import liquibase.database.*;
004:        import liquibase.database.structure.DatabaseSnapshot;
005:        import liquibase.exception.JDBCException;
006:        import liquibase.test.DatabaseTestTemplate;
007:        import liquibase.test.SqlStatementDatabaseTest;
008:        import liquibase.test.TestContext;
009:        import static org.junit.Assert.*;
010:        import org.junit.Test;
011:
012:        public class AlterSequenceStatementTest extends
013:                AbstractSqlStatementTest {
014:
015:            private static final String SEQ_NAME = "altertest_seq"
016:                    .toUpperCase();
017:
018:            protected void setupDatabase(Database database) throws Exception {
019:                dropAndCreateSequence(new CreateSequenceStatement(null,
020:                        SEQ_NAME), database);
021:                dropAndCreateSequence(new CreateSequenceStatement(
022:                        TestContext.ALT_SCHEMA, SEQ_NAME), database);
023:            }
024:
025:            protected SqlStatement generateTestStatement() {
026:                return new AlterSequenceStatement(null, null);
027:            }
028:
029:            @Test
030:            public void supportsDatabase() throws Exception {
031:                for (Database database : TestContext.getInstance()
032:                        .getAllDatabases()) {
033:                    if (database.supportsSequences()) {
034:                        assertTrue(generateTestStatement().supportsDatabase(
035:                                database));
036:                    } else {
037:                        assertFalse(generateTestStatement().supportsDatabase(
038:                                database));
039:                    }
040:                }
041:            }
042:
043:            @Test
044:            public void execute_incrementBy() throws Exception {
045:                new DatabaseTestTemplate()
046:                        .testOnAvailableDatabases(new SqlStatementDatabaseTest(
047:                                null,
048:                                new AlterSequenceStatement(null, SEQ_NAME)
049:                                        .setIncrementBy(5)) {
050:                            protected boolean expectedException(
051:                                    Database database, JDBCException exception) {
052:                                return database instanceof  FirebirdDatabase
053:                                        || database instanceof  HsqlDatabase;
054:                            }
055:
056:                            protected void preExecuteAssert(
057:                                    DatabaseSnapshot snapshot) {
058:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
059:                                //todo: assert increment by is 1
060:                            }
061:
062:                            protected void postExecuteAssert(
063:                                    DatabaseSnapshot snapshot) {
064:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
065:                                //todo: assert increment by value
066:                            }
067:                        });
068:            }
069:
070:            @Test
071:            public void execute_minValue() throws Exception {
072:                new DatabaseTestTemplate()
073:                        .testOnAvailableDatabases(new SqlStatementDatabaseTest(
074:                                null,
075:                                new AlterSequenceStatement(null, SEQ_NAME)
076:                                        .setMinValue(0)) {
077:                            protected void preExecuteAssert(
078:                                    DatabaseSnapshot snapshot) {
079:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
080:                                //todo; assert minValue is 1
081:                            }
082:
083:                            protected void postExecuteAssert(
084:                                    DatabaseSnapshot snapshot) {
085:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
086:                                //todo: assert min valuevalue
087:                            }
088:                        });
089:            }
090:
091:            @Test
092:            public void execute_maxValue() throws Exception {
093:                new DatabaseTestTemplate()
094:                        .testOnAvailableDatabases(new SqlStatementDatabaseTest(
095:                                null,
096:                                new AlterSequenceStatement(null, SEQ_NAME)
097:                                        .setMaxValue(50)) {
098:
099:                            protected boolean expectedException(
100:                                    Database database, JDBCException exception) {
101:                                return database instanceof  FirebirdDatabase
102:                                        || database instanceof  HsqlDatabase;
103:                            }
104:
105:                            protected void preExecuteAssert(
106:                                    DatabaseSnapshot snapshot) {
107:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
108:                                //todo: assert initial max value
109:                            }
110:
111:                            protected void postExecuteAssert(
112:                                    DatabaseSnapshot snapshot) {
113:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
114:                                //todo: assert max value
115:                            }
116:                        });
117:            }
118:
119:            @Test
120:            public void execute_order() throws Exception {
121:                new DatabaseTestTemplate()
122:                        .testOnAvailableDatabases(new SqlStatementDatabaseTest(
123:                                null,
124:                                new AlterSequenceStatement(null, SEQ_NAME)
125:                                        .setOrdered(true)) {
126:
127:                            protected boolean expectedException(
128:                                    Database database, JDBCException exception) {
129:                                return !(database instanceof  OracleDatabase || database instanceof  DB2Database);
130:                            }
131:
132:                            protected void preExecuteAssert(
133:                                    DatabaseSnapshot snapshot) {
134:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
135:                                //todo: assert order default
136:                            }
137:
138:                            protected void postExecuteAssert(
139:                                    DatabaseSnapshot snapshot) {
140:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
141:                                //todo: assert max value
142:                            }
143:                        });
144:            }
145:
146:            @Test
147:            public void execute_schemaSet() throws Exception {
148:                new DatabaseTestTemplate()
149:                        .testOnAvailableDatabases(new SqlStatementDatabaseTest(
150:                                TestContext.ALT_SCHEMA,
151:                                new AlterSequenceStatement(
152:                                        TestContext.ALT_SCHEMA, SEQ_NAME)
153:                                        .setIncrementBy(5)) {
154:                            protected boolean expectedException(
155:                                    Database database, JDBCException exception) {
156:                                return database instanceof  FirebirdDatabase
157:                                        || database instanceof  HsqlDatabase;
158:                            }
159:
160:                            protected void preExecuteAssert(
161:                                    DatabaseSnapshot snapshot) {
162:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
163:                                //todo: assert increment by is 1
164:                            }
165:
166:                            protected void postExecuteAssert(
167:                                    DatabaseSnapshot snapshot) {
168:                                assertNotNull(snapshot.getSequence(SEQ_NAME));
169:                                //todo: assert increment by value
170:                            }
171:                        });
172:            }
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.