View Javadoc

1   package liquibase.database.core;
2   
3   import liquibase.Liquibase;
4   import liquibase.change.Change;
5   import liquibase.changelog.ChangeSet;
6   import liquibase.changelog.DatabaseChangeLog;
7   import liquibase.changelog.RanChangeSet;
8   import liquibase.database.Database;
9   import liquibase.database.DatabaseConnection;
10  import liquibase.database.structure.DatabaseObject;
11  import liquibase.diff.DiffStatusListener;
12  import liquibase.exception.*;
13  import liquibase.lockservice.DatabaseChangeLogLock;
14  import liquibase.snapshot.DatabaseSnapshotGenerator;
15  import liquibase.sql.visitor.SqlVisitor;
16  import liquibase.statement.SqlStatement;
17  import liquibase.statement.DatabaseFunction;
18  
19  import java.io.IOException;
20  import java.io.Writer;
21  import java.sql.Connection;
22  import java.sql.Time;
23  import java.sql.Timestamp;
24  import java.util.Date;
25  import java.util.List;
26  import java.util.Set;
27  
28  public class MockDatabase implements Database {
29  
30      public int getPriority() {
31          return PRIORITY_DEFAULT;
32      }
33  
34      public DatabaseObject[] getContainingObjects() {
35          return null;
36      }
37  
38      public void setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo) {
39          //
40      }
41  
42      public boolean requiresUsername() {
43          return false;
44      }
45  
46      public boolean requiresPassword() {
47          return false;
48      }
49  
50      public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
51          return false;
52      }
53  
54      public String getDefaultDriver(String url) {
55          return null;
56      }
57  
58      public DatabaseConnection getConnection() {
59          return null;
60      }
61  
62      public void setConnection(Connection conn) {
63      }
64  
65      public void setConnection(DatabaseConnection conn) {
66      }
67  
68      public boolean getAutoCommitMode() {
69          return false;
70      }
71  
72      public boolean isAutoCommit() throws DatabaseException {
73          return false;
74      }
75  
76      public void setAutoCommit(boolean b) throws DatabaseException {
77  
78      }
79  
80      public boolean supportsDDLInTransaction() {
81          return false;
82      }
83  
84      public String getDatabaseProductName() {
85          return null;
86      }
87  
88      public String getDatabaseProductVersion() throws DatabaseException {
89          return null;
90      }
91  
92  
93      public int getDatabaseMajorVersion() throws DatabaseException {
94          return 0;
95      }
96  
97      public int getDatabaseMinorVersion() throws DatabaseException {
98          return 0;
99      }
100 
101     public String getTypeName() {
102         return null;
103     }
104 
105     public String getDriverName() throws DatabaseException {
106         return null;
107     }
108 
109     public String getConnectionURL() throws DatabaseException {
110         return null;
111     }
112 
113     public String getConnectionUsername() throws DatabaseException {
114         return null;
115     }
116 
117     public String getDefaultCatalogName() throws DatabaseException {
118         return null;
119     }
120 
121     public String getDefaultSchemaName()  {
122         return null;
123     }
124 
125     public void setDefaultSchemaName(String schemaName) throws DatabaseException {
126         
127     }
128 
129     public boolean supportsInitiallyDeferrableColumns() {
130         return false;
131     }
132 
133     public boolean supportsSequences() {
134         return true;
135     }
136 
137     public boolean supportsDropTableCascadeConstraints() {
138         return false;
139     }
140 
141     public boolean supportsAutoIncrement() {
142         return true;
143     }
144 
145     public String getDateLiteral(String isoDate) {
146         return isoDate;
147     }
148 
149 
150     public String getDateLiteral(java.sql.Date date) {
151         return date.toString();
152     }
153 
154     public String getTimeLiteral(Time time) {
155         return time.toString();
156     }
157 
158     public String getDateTimeLiteral(Timestamp timeStamp) {
159         return timeStamp.toString();
160     }
161 
162     public String getCurrentDateTimeFunction() {
163         return "DATETIME()";
164     }
165 
166     public void setCurrentDateTimeFunction(String function) {
167     }
168 
169     public String getLineComment() {
170         return null;
171     }
172 
173     public String getAutoIncrementClause() {
174         return "AUTO_INCREMENT_CLAUSE";
175     }
176 
177     public SqlStatement getCommitSQL() {
178         return null;
179     }
180 
181     /**
182      * @see liquibase.database.Database#getDatabaseChangeLogTableName()
183      */
184     public String getDatabaseChangeLogTableName() {
185         return "DATABASECHANGELOG";
186     }
187 
188     /**
189      * @see liquibase.database.Database#getDatabaseChangeLogLockTableName()
190      */
191     public String getDatabaseChangeLogLockTableName() {
192         return "DATABASECHANGELOGLOCK";
193     }
194     
195     /**
196      * Does nothing
197      * 
198      * @see liquibase.database.Database#setDatabaseChangeLogLockTableName(java.lang.String)
199      */
200     public void setDatabaseChangeLogLockTableName(String tableName) {
201     }
202 
203 	/**
204 	 * Does nothing
205 	 * 
206      * @see liquibase.database.Database#setDatabaseChangeLogTableName(java.lang.String)
207      */
208     public void setDatabaseChangeLogTableName(String tableName) {
209     }
210 
211 	public String getConcatSql(String... values) {
212         return null;
213     }
214 
215     public boolean acquireLock(Liquibase liquibase) throws LockException {
216         return false;
217     }
218 
219     public void releaseLock() throws LockException {
220     }
221 
222     public DatabaseChangeLogLock[] listLocks() throws LockException {
223         return new DatabaseChangeLogLock[0];
224     }
225 
226     public boolean hasDatabaseChangeLogTable() {
227         return false;
228     }
229 
230     public boolean hasDatabaseChangeLogLockTable() {
231         return false;
232     }
233 
234     public void checkDatabaseChangeLogTable(Liquibase liquibase) throws DatabaseException, IOException {
235     }
236 
237     public void checkDatabaseChangeLogLockTable(Liquibase liquibase) throws DatabaseException, IOException {
238     }
239 
240     public void dropDatabaseObjects(String schema) throws DatabaseException {
241     }
242 
243     public void tag(String tagString) throws DatabaseException {
244     }
245 
246     public boolean doesTagExist(String tag) throws DatabaseException {
247         return false;
248     }
249 
250     public boolean isSystemTable(String catalogName, String schemaName, String tableName) {
251         return false;
252     }
253 
254 
255     public boolean isSystemView(String catalogName, String schemaName, String name) {
256         return false;
257     }
258 
259     public boolean isLiquibaseTable(String tableName) {
260         return false;
261     }
262 
263     public boolean shouldQuoteValue(String value) {
264         return true;
265     }
266 
267     public boolean supportsTablespaces() {
268         return false;
269     }
270 
271     public String getViewDefinition(String schemaName, String name) throws DatabaseException {
272         return null;
273     }
274 
275     public String getDatabaseProductName(DatabaseConnection conn) throws DatabaseException {
276         return "Mock Database";
277     }
278 
279     public String getDateLiteral(Date defaultDateValue) {
280         return defaultDateValue.toString();
281     }
282 
283     public String escapeTableName(String schemaName, String tableName) {
284         if (schemaName == null) {
285             return tableName;
286         } else {
287             return schemaName+"."+tableName;
288         }
289     }
290 
291     public String escapeIndexName(String schemaName, String indexName) {
292         return escapeTableName(schemaName, indexName);
293     }
294 
295     public String escapeColumnName(String schemaName, String tableName, String columnName) {
296         return columnName;
297     }
298 
299     public String escapeColumnNameList(String columnNames) {
300         return columnNames;
301     }
302 
303     public String escapeSequenceName(String schemaName, String sequenceName) {
304         if (sequenceName == null) {
305             return sequenceName;
306         } else {
307             return schemaName+"."+sequenceName;
308         }
309     }
310 
311     public String convertRequestedSchemaToSchema(String requestedSchema) throws DatabaseException {
312         return requestedSchema;
313     }
314 
315     public String convertRequestedSchemaToCatalog(String requestedSchema) throws DatabaseException {
316         return null;
317     }
318 
319     public boolean supportsSchemas() {
320         return true;
321     }
322 
323     public String generatePrimaryKeyName(String tableName) {
324         return "PK_"+tableName;
325     }
326 
327     public String escapeViewName(String schemaName, String viewName) {
328         return escapeTableName(schemaName, viewName);
329     }
330 
331     public boolean acquireLock() throws LockException {
332         return false;
333     }
334 
335     public void checkDatabaseChangeLogTable(boolean updateExistingNullChecksums, DatabaseChangeLog databaseChangeLog, String[] contexts) throws DatabaseException {
336         ;
337     }
338 
339     public void checkDatabaseChangeLogLockTable() throws DatabaseException {
340         ;
341     }
342 
343     public ChangeSet.RunStatus getRunStatus(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException {
344         return null;
345     }
346 
347     public RanChangeSet getRanChangeSet(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException {
348         return null;
349     }
350 
351     public void markChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType) throws DatabaseException {
352         ;
353     }
354 
355     public List<RanChangeSet> getRanChangeSetList() throws DatabaseException {
356         return null;
357     }
358 
359     public Date getRanDate(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException {
360         return null;
361     }
362 
363     public void removeRanStatus(ChangeSet changeSet) throws DatabaseException {
364         ;
365     }
366 
367     public void commit() {
368         ;
369     }
370 
371     public void rollback() {
372         ;
373     }
374 
375     public SqlStatement getSelectChangeLogLockSQL() throws DatabaseException {
376         return null;
377     }
378 
379     public String escapeStringForDatabase(String string) {
380         return string;
381     }
382 
383     public void close() throws DatabaseException {
384         ;
385     }
386 
387     public DatabaseSnapshotGenerator createDatabaseSnapshot(String schema, Set<DiffStatusListener> statusListeners) throws DatabaseException {
388         return null;
389     }
390 
391     public boolean supportsRestrictForeignKeys() {
392         return true;
393     }
394 
395     public String escapeConstraintName(String constraintName) {
396         return constraintName;
397     }
398     
399     public boolean isLocalDatabase() throws DatabaseException {
400     	return true;
401     }
402 
403     public String escapeDatabaseObject(String objectName) {
404         return objectName;
405     }
406 
407     public void executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) throws LiquibaseException, UnsupportedChangeException {
408         ;
409     }
410 
411     public void execute(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) throws LiquibaseException {
412         ;
413     }
414 
415     public void saveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, UnsupportedChangeException, StatementNotSupportedOnDatabaseException, LiquibaseException {
416         ;
417     }
418 
419     public void executeRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) throws LiquibaseException, UnsupportedChangeException, RollbackImpossibleException {
420         ;
421     }
422 
423     public void saveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, UnsupportedChangeException, RollbackImpossibleException, StatementNotSupportedOnDatabaseException, LiquibaseException {
424         ;
425     }
426 
427 	public String getLiquibaseSchemaName(){
428 		return null;
429 	}
430 
431     public int getNextChangeSetSequenceValue() throws LiquibaseException {
432         return 1;
433     }
434 
435     public Date parseDate(String dateAsString) throws DateParseException {
436         return new Date();
437     }
438 
439 	public List<DatabaseFunction> getDatabaseFunctions() {
440 		return null;
441 	}
442 
443     public void reset() {
444         
445     }
446     
447         public boolean supportsForeignKeyDisable() {
448         return false;
449     }
450 
451     public boolean disableForeignKeyChecks() throws DatabaseException {
452         return false;
453     }
454 
455     public void enableForeignKeyChecks() throws DatabaseException {
456         
457     }
458 
459     public void updateChecksum(ChangeSet changeSet) throws DatabaseException {
460         
461     }
462 
463     public boolean isReservedWord(String string) {
464         return false;
465     }
466 }