1 24 25 package org.objectweb.cjdbc.scenario.tools.testlet; 26 27 import java.sql.Connection ; 28 import java.sql.ResultSet ; 29 30 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 31 32 39 public class CreateTableTestLet extends AbstractConnectionTestLet 40 { 41 42 47 public CreateTableTestLet(Connection con) 48 { 49 super(con); 50 config.put(TABLE_NAME, "newtable" + System.currentTimeMillis()); 51 config.put(IGNORE_CASE, "true"); 52 config.put(TABLE_METADATA_COLUMNS, new String []{"TABLE"}); 53 config.put(ITERATION, "" + 1); 54 } 55 56 59 public void execute() throws Exception 60 { 61 String myTableName = (String ) config.get(TABLE_NAME); 62 VirtualDatabase mainVdb = (VirtualDatabase) config.get(VIRTUAL_DATABASE); 63 if (mainVdb == null) 64 throw new TestLetException("No virtual database defined"); 65 66 int iteration = Integer.parseInt((String ) config.get(ITERATION)); 67 68 for (int i = 0; i < iteration; i++) 69 { 70 String tableName = myTableName + i; 71 String createQuery = "CREATE TABLE " + tableName 72 + "(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(255),COST DECIMAL)"; 73 74 jdbcConnection.createStatement().executeUpdate(createQuery); 75 ResultSet set = jdbcConnection.getMetaData().getTables(null, "%", tableName, 76 (String []) config.get(TABLE_METADATA_COLUMNS)); 77 assertTrue("No results after create table", set.next()); 78 String table = set.getString(3); 79 if (ignoreCase()) 80 assertTrue(table.equalsIgnoreCase(tableName)); 81 else 82 assertTrue(table.equals(tableName)); 83 } 84 } 85 } | Popular Tags |