From: Christian T. <ch...@sm...> - 2002-04-15 17:37:53
|
Hi mockobjects community, in one of my projects I use java.sql.ResutSetMetaData. Because I test-first my java classes ;-) and it dosn't exists a suck mock object I write a very rudimentary mock resultset meta data ... It works, and I think this is a usefull class for the com.mockobjects.sql package ... Chris --- CODE SNIPLET --- package com.mockobjects.sql; import com.mockobjects.*; import java.sql.*; import java.sql.SQLException; public class MockResultSetMetaData extends MockObject implements ResultSetMetaData { private String[] names = null; private Object[] values = null; public MockResultSetMetaData(String[] names, Object[] values) { super(); this.names = names; this.values = values; } /** * @see ResultSetMetaData#getColumnCount() */ public int getColumnCount() throws SQLException { return names.length; } /** * @see ResultSetMetaData#isAutoIncrement(int) */ public boolean isAutoIncrement(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isCaseSensitive(int) */ public boolean isCaseSensitive(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isSearchable(int) */ public boolean isSearchable(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isCurrency(int) */ public boolean isCurrency(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isNullable(int) */ public int isNullable(int arg0) throws SQLException { return 0; } /** * @see ResultSetMetaData#isSigned(int) */ public boolean isSigned(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#getColumnDisplaySize(int) */ public int getColumnDisplaySize(int arg0) throws SQLException { return 0; } /** * @see ResultSetMetaData#getColumnLabel(int) */ public String getColumnLabel(int arg0) throws SQLException { return null; } /** * @see ResultSetMetaData#getColumnName(int) */ public String getColumnName(int arg0) throws SQLException { return names[arg0 - 1]; } /** * @see ResultSetMetaData#getSchemaName(int) */ public String getSchemaName(int arg0) throws SQLException { return null; } /** * @see ResultSetMetaData#getPrecision(int) */ public int getPrecision(int arg0) throws SQLException { return 0; } /** * @see ResultSetMetaData#getScale(int) */ public int getScale(int arg0) throws SQLException { return 0; } /** * @see ResultSetMetaData#getTableName(int) */ public String getTableName(int arg0) throws SQLException { return null; } /** * @see ResultSetMetaData#getCatalogName(int) */ public String getCatalogName(int arg0) throws SQLException { return null; } /** * @see ResultSetMetaData#getColumnType(int) */ public int getColumnType(int arg0) throws SQLException { return 0; } /** * @see ResultSetMetaData#getColumnTypeName(int) */ public String getColumnTypeName(int arg0) throws SQLException { return null; } /** * @see ResultSetMetaData#isReadOnly(int) */ public boolean isReadOnly(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isWritable(int) */ public boolean isWritable(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#isDefinitelyWritable(int) */ public boolean isDefinitelyWritable(int arg0) throws SQLException { return false; } /** * @see ResultSetMetaData#getColumnClassName(int) */ public String getColumnClassName(int arg0) throws SQLException { return null; } } |