1 5 package org.h2.test.synth; 6 7 import java.sql.SQLException ; 8 import java.util.ArrayList ; 9 10 public class DbState implements DbInterface { 11 12 private TestSynth config; 13 private ArrayList tables = new ArrayList (); 14 private ArrayList indexes = new ArrayList (); 15 boolean connected; 16 boolean autoCommit; 17 18 DbState(TestSynth config) { 19 this.config = config; 20 } 21 22 public void reset() throws SQLException { 23 tables = new ArrayList (); 24 indexes = new ArrayList (); 25 } 26 27 public void connect() throws SQLException { 28 connected = true; 29 } 30 31 public void disconnect() throws SQLException { 32 connected = false; 33 } 34 35 public void createTable(Table table) throws SQLException { 36 tables.add(table); 37 } 38 39 public void dropTable(Table table) throws SQLException { 40 tables.remove(table); 41 } 42 43 public void createIndex(Index index) throws SQLException { 44 indexes.add(index); 45 } 46 47 public void dropIndex(Index index) throws SQLException { 48 indexes.remove(index); 49 } 50 51 public Result insert(Table table, Column[] c, Value[] v) throws SQLException { 52 return null; 53 } 54 55 public Result select(String sql) throws SQLException { 56 return null; 57 } 58 59 public Result delete(Table table, String condition) throws SQLException { 60 return null; 61 } 62 63 public Result update(Table table, Column[] columns, Value[] values, String condition) { 64 return null; 65 } 66 67 public void setAutoCommit(boolean b) throws SQLException { 68 autoCommit = b; 69 } 70 71 public void commit() throws SQLException { 72 } 73 74 public void rollback() throws SQLException { 75 } 76 77 public Table randomTable() { 78 if(tables.size() == 0) { 79 return null; 80 } 81 int i = config.random().getInt(tables.size()); 82 return (Table) tables.get(i); 83 } 84 85 public void end() throws SQLException { 86 } 87 88 } 89 | Popular Tags |