/** * Creates a new proxy <code>Driver</code> object. * @param handler The handler that intercepts/overrides method calls. * @return proxied Driver */ public Driver createDriver(InvocationHandler handler) { return newProxyInstance(Driver.class, handler); }
/** * Create a <code>MockResultSet</code> proxy object. This is equivalent to: * <pre> * ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows)); * </pre> * * @param metaData * @param rows A null value indicates an empty <code>ResultSet</code>. */ public static ResultSet create(ResultSetMetaData metaData, Object[][] rows) { return ProxyFactory.instance().createResultSet( new MockResultSet(metaData, rows)); }
/** * Create a <code>MockResultSetMetaData</code> proxy object. This is * equivalent to: * <pre> * ProxyFactory.instance().createResultSetMetaData(new MockResultSetMetaData(columnNames)); * </pre> * * @param columnNames * @return the proxy object */ public static ResultSetMetaData create(String[] columnNames) { return ProxyFactory.instance().createResultSetMetaData( new MockResultSetMetaData(columnNames)); }
/** * Wraps the <code>ResultSet</code> in an instance of this class. This is * equivalent to: * <pre> * ProxyFactory.instance().createResultSet(new SqlNullCheckedResultSet(rs)); * </pre> * * @param rs The <code>ResultSet</code> to wrap. * @return wrapped ResultSet */ public static ResultSet wrap(ResultSet rs) { return factory.createResultSet(new SqlNullCheckedResultSet(rs)); }
public void testCreateStatement() { assertNotNull(ProxyFactory.instance().createStatement(stub)); }
public void testCreateDriver() { assertNotNull(ProxyFactory.instance().createDriver(stub)); }
public void testCreateCallableStatement() { assertNotNull(ProxyFactory.instance().createCallableStatement(stub)); }
public void testCreateConnection() { assertNotNull(ProxyFactory.instance().createConnection(stub)); }
public void testCreatePreparedStatement() { assertNotNull(ProxyFactory.instance().createPreparedStatement(stub)); }
public void testCreateResultSet() { assertNotNull(ProxyFactory.instance().createResultSet(stub)); }
public void testCreateResultSetMetaData() { assertNotNull(ProxyFactory.instance().createResultSetMetaData(stub)); }
/** * Wraps the <code>ResultSet</code> in an instance of this class. This is * equivalent to: * <pre> * ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs)); * </pre> * * @param rs The <code>ResultSet</code> to wrap. * @return wrapped ResultSet */ public static ResultSet wrap(ResultSet rs) { return factory.createResultSet(new StringTrimmedResultSet(rs)); }
/** * Sets up instance variables required by this test case. */ @Override public void setUp() throws Exception { super.setUp(); rs2 = new SqlNullCheckedResultSet( ProxyFactory.instance().createResultSet( new SqlNullUncheckedMockResultSet())); rs = ProxyFactory.instance().createResultSet(rs2); // Override superclass field }
public void testMapColumnToProperties() throws Exception { String[] columnNames = { "test", "test", "three" }; String[] columnLabels = { "one", "two", null }; ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( new MockResultSetMetaData(columnNames, columnLabels)); PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); int[] columns = beanProc.mapColumnsToProperties(rsmd, props); for (int i = 1; i < columns.length; i++) { assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND); } }
/** * Creates a new proxy <code>PreparedStatement</code> object. * @param handler The handler that intercepts/overrides method calls. * @return proxied PreparedStatement */ public PreparedStatement createPreparedStatement(InvocationHandler handler) { return newProxyInstance(PreparedStatement.class, handler); }
/** * Make sure 2 wrappers work together. * @throws SQLException if a database access error occurs */ public void testMultipleWrappers() throws Exception { // Create a ResultSet with data Object[][] rows = new Object[][] { { null } }; ResultSet rs = MockResultSet.create(metaData, rows); // Wrap the ResultSet with a null checked version SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs); ncrs.setNullString(" trim this "); rs = ProxyFactory.instance().createResultSet(ncrs); // Wrap the wrapper with a string trimmed version rs = StringTrimmedResultSet.wrap(rs); rs.next(); assertEquals("trim this", rs.getString(1)); }
public void testMapColumnToPropertiesWithOverrides() throws Exception { Map<String, String> columnToPropertyOverrides = new HashMap<String, String>(); columnToPropertyOverrides.put("five", "four"); BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides); String[] columnNames = { "test", "test", "three", "five" }; String[] columnLabels = { "one", "two", null, null }; ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( new MockResultSetMetaData(columnNames, columnLabels)); PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); int[] columns = beanProc.mapColumnsToProperties(rsmd, props); for (int i = 1; i < columns.length; i++) { assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND); } } }
/** * Creates a new proxy <code>ResultSet</code> object. * @param handler The handler that intercepts/overrides method calls. * @return proxied ResultSet */ public ResultSet createResultSet(InvocationHandler handler) { return newProxyInstance(ResultSet.class, handler); }
/** * Creates a new proxy <code>CallableStatement</code> object. * @param handler The handler that intercepts/overrides method calls. * @return proxied CallableStatement */ public CallableStatement createCallableStatement(InvocationHandler handler) { return newProxyInstance(CallableStatement.class, handler); }
/** * Creates a new proxy <code>Connection</code> object. * @param handler The handler that intercepts/overrides method calls. * @return proxied Connection */ public Connection createConnection(InvocationHandler handler) { return newProxyInstance(Connection.class, handler); }