Column newCol = new Column( "defaulted", Types.INTEGER, 11, true, false, false, "50" );
Column newCol = new Column("defaulted", "defaulted", Types.INTEGER, "11", true, false, false, "50");
    public void XtestEverything()        throws Exception    {        // TODO: Reinsert test after env has been configured        String tableName = "test_table";        Integer testId = new Integer(1);        String testName = "UniqueName";        Database db = getDatabase( "test-start" );        assertEquals( "Correct version", "1.0", db.getVersion() );        updateDatabase( db, true );        Table table = db.findTable( tableName );        DynaSql dynaSql = new DynaSql( dataSource, db );        DynaBean test = dynaSql.newInstance(tableName);        assertTrue("Test not null", test != null);        test.set("id", testId);        test.set("name", testName);        dynaSql.insert(test);        //test inserted        //test default value        Iterator iter = dynaSql.query( "select * from " + tableName + " where id = 1" );        assertTrue("Found at least one row", iter.hasNext());        test = (DynaBean) iter.next();        assertTrue("Found a dynaBean row", test != null);        assertEquals( "bean has correct id", testId, test.get("id") );        assertEquals( "bean has correct name", testName, test.get("name") );//dynasql forces null into column//        assertEquals( "bean has correct default number", new Integer(25), test.get("number") );        //test unique index        test = dynaSql.newInstance(tableName);        test.set("id", new Integer(2));        test.set("name", testName);        boolean insertError = false;        try {            dynaSql.insert(test);        } catch ( SQLException e ) {            insertError = true;        }        assertTrue( "Unique index violation on insert", insertError );        //test pk        test = dynaSql.newInstance(tableName);        test.set("id", testId);        test.set("name", "another name");        insertError = false;        try {            dynaSql.insert(test);        } catch ( SQLException e ) {            insertError = true;        }        assertTrue( "PK violation on insert", insertError );        //check adding column with default        Column newCol = new Column( "defaulted", Types.INTEGER, 11, true, false, false, "50" );        table.addColumn( newCol );        updateDatabase( db, false );        iter = dynaSql.query( "select * from " + tableName + " where id = 1" );        assertTrue("Found at least one row", iter.hasNext());        test = (DynaBean) iter.next();        assertTrue("Found a dynaBean row", test != null);        assertEquals( "bean has correct id", testId, test.get("id") );        assertEquals( "bean has correct name", testName, test.get("name") );        assertEquals( "bean has correct default number", new Integer(50), test.get("defaulted") );        //change column type        table.getColumns().remove( newCol );        newCol.setTypeCode( Types.VARCHAR );        table.addColumn( newCol );        updateDatabase( db, false );        iter = dynaSql.query( "select * from " + tableName + " where id = 1" );        assertTrue("Found at least one row", iter.hasNext());        test = (DynaBean) iter.next();        assertTrue("Found a dynaBean row", test != null);        assertEquals( "bean has correct id", testId, test.get("id") );        assertEquals( "bean has correct name", testName, test.get("name") );        //the following statement does fail with new Integer(50) as the expected value, so type check is right        assertEquals( "bean has correct type", "50", test.get("defaulted") );        //try drop column        table.getColumns().remove( newCol );        updateDatabase( db, false );        iter = dynaSql.query( "select * from " + tableName + " where id = 1" );        assertTrue("Found at least one row", iter.hasNext());        test = (DynaBean) iter.next();        assertTrue("Found a dynaBean row", test != null);        assertEquals( "bean has correct id", testId, test.get("id") );        assertEquals( "bean has correct name", testName, test.get("name") );        assertTrue( "bean has no property", test.getDynaClass().getDynaProperty("defaulted") == null );        //try drop index        table.getIndexes().clear();        assertEquals( "No table indexes", 0, table.getIndexes().size() );        updateDatabase( db, false );//org.apache.commons.sql.io.DatabaseWriter writer = new org.apache.commons.sql.io.DatabaseWriter(System.err);//writer.write(db);        test = dynaSql.newInstance(tableName);        test.set("id", new Integer(5));        test.set("name", testName);        insertError = false;        try {            dynaSql.insert(test);        } catch ( SQLException e ) {            e.printStackTrace();            insertError = true;        }        assertFalse( "No Unique index violation on insert", insertError );        //try drop table        db.getTables().remove(table);        updateDatabase( db, false );        boolean error = false;        try {            iter = dynaSql.query( "select * from " + tableName + " where id = 1" );        } catch ( SQLException e ) {            error = true;        }        assertTrue( "Had no table error", error );    }