database.setDefaultSchemaName("myschema");
assertEquals("myschema", database.getDefaultSchemaName());
}
private Database getADatabaseWithCollation( final String collation ) throws DatabaseException, SQLException {
Database database = getDatabase();
JdbcConnection connection = createMock(JdbcConnection.class);
expect(connection.getConnectionUserName()).andReturn("user").anyTimes();
expect(connection.getURL()).andReturn("URL").anyTimes();
expect(connection.getAutoCommit()).andReturn(getDatabase().getAutoCommitMode()).anyTimes();
Connection sqlConnection = createMock(Connection.class);
Statement statement = createMock(Statement.class);
ResultSet resultSet = createMock(ResultSet.class);
ResultSetMetaData metadata = createMock(ResultSetMetaData.class);
expect(connection.getUnderlyingConnection()).andReturn(sqlConnection).anyTimes();
expect( sqlConnection.createStatement()).andReturn(statement);
expect( statement.executeQuery("SELECT CONVERT(varchar(100), SERVERPROPERTY('COLLATION'))")).andReturn(resultSet);
expect( resultSet.next() ).andReturn(true);
expect( resultSet.getMetaData() ).andReturn(metadata);
expect( metadata.getColumnCount() ).andReturn(1);
expect( resultSet.getString(1)).andReturn(collation);
expect( resultSet.next() ).andReturn(false);
connection.attached(database);
replay(connection, sqlConnection, statement, resultSet, metadata);
database.setConnection(connection);
return database;
}