01 package wodbupdate;
02
03 import java.sql.*;
04 import junit.framework.*;
05
06
07 public class UpdateTest extends TestCase {
08
09 public void testVersion() {
10 assertEquals("Test34", new UpdateTest34().version());
11 }
12
13 public void testPerformUpdate() throws SQLException {
14 Update update = new UpdateTest34();
15 MockDatabase mockDatabase = new MockDatabase();
16 update.setDatabase(mockDatabase);
17 update.performUpdate();
18 assertEquals("blah", mockDatabase.lastSQL);
19 }
20
21 class MockDatabase implements Databaseable {
22 String lastSQL;
23
24 public Statement executeSQL(String anSQLString) {
25 lastSQL = anSQLString;
26 return null;
27 }
28
29 public int currentVersionNumber() {
30 throw new RuntimeException();
31 }
32
33 public boolean tryToLock() {
34 throw new RuntimeException();
35 }
36
37 public void unlock() {
38 throw new RuntimeException();
39 }
40
41 public boolean isLocked() {
42 throw new RuntimeException();
43 }
44
45 public void setVersionNumber(int aVersionNumber) {
46 throw new RuntimeException();
47 }
48
49 public void close() {
50 throw new RuntimeException();
51 }
52
53 }
54
55 }
56
57 class UpdateTest34 extends Update {
58 protected void executeUpdate() throws SQLException {
59 executeSQL("blah");
60 }
61 }
|