git-svn-id: http://code.alibabatech.com/svn/druid/trunk@3 b9813039-fb51-4c41-a8b9-e21c2acb5095

This commit is contained in:
wenshao
2011-05-11 02:19:03 +00:00
parent 0e60b7d988
commit 1848f924be
2 changed files with 21 additions and 842 deletions
@@ -1,810 +0,0 @@
/**
* Copyright 1999-2011 Alibaba.com All right reserved. This software is the confidential and proprietary information of
* Alibaba.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
* in accordance with the terms of the license agreement you entered into with Alibaba.com.
*/
package com.alibaba.druid.bvt.proxy.filter.encoding;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.Test;
import com.alibaba.druid.filter.FilterChain;
import com.alibaba.druid.filter.encoding.CharsetConvert;
import com.alibaba.druid.filter.encoding.CharsetParameter;
import com.alibaba.druid.filter.encoding.EncodingConvertFilter;
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
import com.alibaba.druid.proxy.jdbc.ClobProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;
/**
* @author gang.su
*/
public class EncodingConvertFilterTest extends TestCase {
private static final EncodingConvertFilter filter = new EncodingConvertFilter();
private static final HashMap<String, Object> attri = new HashMap<String, Object>();
private static final CharsetParameter param = new CharsetParameter();
private static CharsetConvert convert = null;
private static final String CLIENT_ENCODING = "gbk";
private static final String SERVER_ENCODING = "utf-8";
private static final String TEST_STRING = "你好";
private static final StringReader reader = new StringReader("");
private static final String TEST_STRING_STR = "";
private static final int TEST_POS = 1;
private static final int TEST_OFFSET = 1;
private static final int TEST_LEN = 1;
private static final int autoGeneratedKeys = 1;
private static final int columnIndex = 1;
private static final String sql = "";
private static final int parameterIndex = 1;
private static final int targetSqlType = 1;
private static final int scaleOrLength = 1;
private static final String x = "";
private static final Properties info = new Properties();
private static final String[] columnNames = {};
private static final int[] columnIndexes = {};
private static final String columnLabel = "";
private static final Map<String, Class<?>> map = new HashMap<String, Class<?>>();
private static IMocksControl control = EasyMock.createControl();
private static FilterChain chain = control.createMock(FilterChain.class);
private static ConnectionProxy conn = control.createMock(ConnectionProxy.class);
private static ClobProxy wrapper = control.createMock(ClobProxy.class);
private static StatementProxy statement = control.createMock(StatementProxy.class);
private static ResultSetProxy result = control.createMock(ResultSetProxy.class);
private static PreparedStatementProxy preparedStatement = control.createMock(PreparedStatementProxy.class);
private static CallableStatementProxy callableStatement = control.createMock(CallableStatementProxy.class);
@Override
protected void setUp() throws Exception {
super.setUp();
param.setClientEncoding(CLIENT_ENCODING);
param.setServerEncoding(SERVER_ENCODING);
convert = new CharsetConvert(param.getClientEncoding(), param.getServerEncoding());
attri.put(EncodingConvertFilter.ATTR_CHARSET_PARAMETER, param);
attri.put(EncodingConvertFilter.ATTR_CHARSET_CONVERTER,
new CharsetConvert(param.getClientEncoding(), param.getServerEncoding()));
param.setClientEncoding(info.getProperty(CharsetParameter.CLIENTENCODINGKEY));
param.setServerEncoding(info.getProperty(CharsetParameter.SERVERENCODINGKEY));
info.setProperty(CharsetParameter.CLIENTENCODINGKEY, CLIENT_ENCODING);
info.setProperty(CharsetParameter.SERVERENCODINGKEY, SERVER_ENCODING);
}
@Test
public void testCallableStatement_getObjectFilterChainCallableStatementWrapperInt() throws SQLException {
control.reset();
chain.callableStatement_getObject(callableStatement, 1);
EasyMock.expectLastCall().andReturn("");
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.callableStatement_getObject(chain, callableStatement, 1);
control.verify();
}
@Test
public void testCallableStatement_getObjectFilterChainCallableStatementWrapperIntMapOfStringClassOfQ()
throws SQLException {
control.reset();
chain.callableStatement_getObject(callableStatement, 1, map);
EasyMock.expectLastCall().andReturn("");
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.callableStatement_getObject(chain, callableStatement, 1, map);
control.verify();
}
@Test
public void testCallableStatement_getObjectFilterChainCallableStatementWrapperString() throws SQLException {
control.reset();
chain.callableStatement_getObject(callableStatement, "");
EasyMock.expectLastCall().andReturn("");
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.callableStatement_getObject(chain, callableStatement, "");
control.verify();
}
@Test
public void testCallableStatement_getObjectFilterChainCallableStatementWrapperStringMapOfStringClassOfQ()
throws SQLException {
control.reset();
chain.callableStatement_getObject(callableStatement, "", map);
EasyMock.expectLastCall().andReturn("");
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.callableStatement_getObject(chain, callableStatement, "", map);
control.verify();
}
@Test
public void testCallableStatement_getStringFilterChainCallableStatementWrapperInt() throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_getString(callableStatement, 1);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.callableStatement_getString(chain, callableStatement, 1);
control.verify();
}
@Test
public void testCallableStatement_getStringFilterChainCallableStatementWrapperString() throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_getString(callableStatement, "");
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.callableStatement_getString(chain, callableStatement, "");
control.verify();
}
@Test
public void testCallableStatement_setCharacterStreamFilterChainCallableStatementWrapperStringReader()
throws SQLException {
}
@Test
public void testCallableStatement_setCharacterStreamFilterChainCallableStatementWrapperStringReaderInt()
throws SQLException {
}
@Test
public void testCallableStatement_setCharacterStreamFilterChainCallableStatementWrapperStringReaderLong()
throws SQLException {
}
@Test
public void testCallableStatement_setObjectFilterChainCallableStatementWrapperStringObject() throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_setObject(callableStatement, "", "");
EasyMock.expectLastCall();
control.replay();
filter.callableStatement_setObject(chain, callableStatement, "", "");
control.verify();
}
@Test
public void testCallableStatement_setObjectFilterChainCallableStatementWrapperStringObjectInt() throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_setObject(callableStatement, "", "", targetSqlType);
EasyMock.expectLastCall();
control.replay();
filter.callableStatement_setObject(chain, callableStatement, "", "", targetSqlType);
control.verify();
}
@Test
public void testCallableStatement_setObjectFilterChainCallableStatementWrapperStringObjectIntInt()
throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_setObject(callableStatement, "", "", targetSqlType, 1);
EasyMock.expectLastCall();
control.replay();
filter.callableStatement_setObject(chain, callableStatement, "", "", targetSqlType, 1);
control.verify();
}
@Test
public void testCallableStatement_setString() throws SQLException {
control.reset();
callableStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.callableStatement_setString(callableStatement, "", x);
EasyMock.expectLastCall();
control.replay();
filter.callableStatement_setString(chain, callableStatement, "", x);
control.verify();
}
@Test
public void testConnection_connect() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_connect(info);
EasyMock.expectLastCall().andReturn(conn);
control.replay();
filter.connection_connect(chain, info);
control.verify();
}
@Test
public void testConnection_nativeSQL() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_nativeSQL(conn, sql);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_nativeSQL(chain, conn, sql);
control.verify();
}
@Test
public void testConnection_prepareCallFilterChainConnectionWrapperString() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareCall(conn, sql);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareCall(chain, conn, sql);
control.verify();
}
@Test
public void testConnection_prepareCallFilterChainConnectionWrapperStringIntInt() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareCall(conn, sql, 1, 1, 1);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareCall(chain, conn, sql, 1, 1, 1);
control.verify();
}
@Test
public void testConnection_prepareCallFilterChainConnectionWrapperStringIntIntInt() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperString() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperStringInt() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql, 1);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql, 1);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperStringIntInt() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql, 1, 1);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql, 1, 1);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperStringIntIntInt() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql, 1, 1, 1);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql, 1, 1, 1);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperStringIntArray() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql, columnIndexes);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql, columnIndexes);
control.verify();
}
@Test
public void testConnection_prepareStatementFilterChainConnectionWrapperStringStringArray() throws SQLException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.connection_prepareStatement(conn, sql, columnNames);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.connection_prepareStatement(chain, conn, sql, columnNames);
control.verify();
}
@Test
public void testPreparedStatement_setCharacterStreamFilterChainPreparedStatementWrapperIntReader()
throws SQLException {
}
@Test
public void testPreparedStatement_setCharacterStreamFilterChainPreparedStatementWrapperIntReaderInt()
throws SQLException {
}
@Test
public void testPreparedStatement_setCharacterStreamFilterChainPreparedStatementWrapperIntReaderLong()
throws SQLException {
}
@Test
public void testPreparedStatement_setObjectFilterChainPreparedStatementWrapperIntObject() throws SQLException {
control.reset();
preparedStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.preparedStatement_setObject(preparedStatement, parameterIndex, "");
EasyMock.expectLastCall();
control.replay();
filter.preparedStatement_setObject(chain, preparedStatement, parameterIndex, "");
control.verify();
}
@Test
public void testPreparedStatement_setObjectFilterChainPreparedStatementWrapperIntObjectInt() throws SQLException {
control.reset();
preparedStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.preparedStatement_setObject(preparedStatement, parameterIndex, "", targetSqlType);
EasyMock.expectLastCall();
control.replay();
filter.preparedStatement_setObject(chain, preparedStatement, parameterIndex, "", targetSqlType);
control.verify();
}
@Test
public void testPreparedStatement_setObjectFilterChainPreparedStatementWrapperIntObjectIntInt() throws SQLException {
control.reset();
preparedStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.preparedStatement_setObject(preparedStatement, parameterIndex, "", targetSqlType, scaleOrLength);
EasyMock.expectLastCall();
control.replay();
filter.preparedStatement_setObject(chain, preparedStatement, parameterIndex, "", targetSqlType, scaleOrLength);
control.verify();
}
@Test
public void testPreparedStatement_setString() throws SQLException {
control.reset();
preparedStatement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.preparedStatement_setString(preparedStatement, parameterIndex, x);
EasyMock.expectLastCall();
control.replay();
filter.preparedStatement_setString(chain, preparedStatement, parameterIndex, x);
control.verify();
}
@Test
public void testResultSet_getObjectFilterChainResultSetWrapperInt() throws SQLException {
control.reset();
chain.resultSet_getObject(result, columnIndex);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getObject(chain, result, columnIndex);
control.verify();
}
@Test
public void testResultSet_getObjectFilterChainResultSetWrapperIntMapOfStringClassOfQ() throws SQLException {
control.reset();
chain.resultSet_getObject(result, columnIndex, map);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getObject(chain, result, columnIndex, map);
control.verify();
}
@Test
public void testResultSet_getObjectFilterChainResultSetWrapperString() throws SQLException {
control.reset();
chain.resultSet_getObject(result, columnLabel);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getObject(chain, result, columnLabel);
control.verify();
}
@Test
public void testResultSet_getObjectFilterChainResultSetWrapperStringMapOfStringClassOfQ() throws SQLException {
control.reset();
chain.resultSet_getObject(result, columnLabel, map);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getObject(chain, result, columnLabel, map);
control.verify();
}
@Test
public void testResultSet_getStringFilterChainResultSetWrapperInt() throws SQLException {
control.reset();
chain.resultSet_getString(result, columnIndex);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getString(chain, result, columnIndex);
control.verify();
}
@Test
public void testResultSet_getStringFilterChainResultSetWrapperString() throws SQLException {
control.reset();
chain.resultSet_getString(result, columnLabel);
EasyMock.expectLastCall().andReturn("");
result.getStatementProxy();
EasyMock.expectLastCall().andReturn(statement);
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.resultSet_getString(chain, result, columnLabel);
control.verify();
}
@Test
public void testStatement_addBatch() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_addBatch(statement, sql);
EasyMock.expectLastCall();
control.replay();
filter.statement_addBatch(chain, statement, sql);
control.verify();
}
@Test
public void testStatement_executeFilterChainStatementWrapperString() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql);
control.verify();
}
@Test
public void testStatement_executeFilterChainStatementWrapperStringInt() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, autoGeneratedKeys);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, autoGeneratedKeys);
control.verify();
}
@Test
public void testStatement_executeFilterChainStatementWrapperStringIntArray() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, columnIndexes);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, columnIndexes);
control.verify();
}
@Test
public void testStatement_executeFilterChainStatementWrapperStringStringArray() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, columnNames);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, columnNames);
control.verify();
}
@Test
public void testStatement_executeQuery() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_executeQuery(statement, sql);
EasyMock.expectLastCall().andReturn(null);
control.replay();
filter.statement_executeQuery(chain, statement, sql);
control.verify();
}
@Test
public void testStatement_executeUpdateFilterChainStatementWrapperString() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql);
control.verify();
}
@Test
public void testStatement_executeUpdateFilterChainStatementWrapperStringInt() throws SQLException {
control.reset();
int autoGeneratedKeys = 0;
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, autoGeneratedKeys);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, autoGeneratedKeys);
control.verify();
}
@Test
public void testStatement_executeUpdateFilterChainStatementWrapperStringIntArray() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, columnIndexes);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, columnIndexes);
control.verify();
}
@Test
public void testStatement_executeUpdateFilterChainStatementWrapperStringStringArray() throws SQLException {
control.reset();
statement.getConnectionProxy();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.statement_execute(statement, sql, columnNames);
EasyMock.expectLastCall().andReturn(true);
control.replay();
filter.statement_execute(chain, statement, sql, columnNames);
control.verify();
}
@Test
public void testClob_getSubString() throws SQLException {
control.reset();
chain.clob_getSubString(wrapper, TEST_POS, TEST_LEN);
EasyMock.expectLastCall().andReturn("");
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.clob_getSubString(chain, wrapper, TEST_POS, TEST_LEN);
control.verify();
}
@Test
public void testClob_getCharacterStreamFilterChainClobWrapper() throws SQLException {
control.reset();
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.clob_getCharacterStream(wrapper);
EasyMock.expectLastCall().andReturn(reader);
control.replay();
filter.clob_getCharacterStream(chain, wrapper);
control.verify();
}
@Test
public void testClob_positionFilterChainClobWrapperStringLong() throws SQLException {
control.reset();
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
int start = 1;
String searchstr = "";
chain.clob_position(wrapper, searchstr, start);
EasyMock.expectLastCall().andReturn(1);
control.replay();
filter.clob_position(chain, wrapper, searchstr, start);
control.verify();
}
@Test
public void testClob_setStringFilterChainClobWrapperLongString() throws SQLException {
control.reset();
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.clob_setString(wrapper, TEST_POS, TEST_STRING_STR);
EasyMock.expectLastCall().andReturn(1);
control.replay();
filter.clob_setString(chain, wrapper, TEST_POS, TEST_STRING_STR);
control.verify();
}
@Test
public void testClob_setStringFilterChainClobWrapperLongStringIntInt() throws SQLException {
control.reset();
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
chain.clob_setString(wrapper, TEST_POS, TEST_STRING_STR, TEST_OFFSET, TEST_LEN);
EasyMock.expectLastCall().andReturn(1);
control.replay();
filter.clob_setString(chain, wrapper, TEST_POS, TEST_STRING_STR, TEST_OFFSET, TEST_LEN);
control.verify();
}
@Test
public void testClob_getCharacterStreamFilterChainClobWrapperLongLong() throws SQLException {
control.reset();
chain.clob_getCharacterStream(wrapper, TEST_POS, TEST_LEN);
EasyMock.expectLastCall().andReturn(reader);
wrapper.getConnectionWrapper();
EasyMock.expectLastCall().andReturn(conn);
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
filter.clob_getCharacterStream(chain, wrapper, TEST_POS, TEST_LEN);
control.verify();
}
@Test
public void testDecodeObject() throws SQLException, UnsupportedEncodingException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
String result = (String) filter.decodeObject(conn, TEST_STRING);
Assert.assertEquals(convert.decode(TEST_STRING), result);
control.verify();
}
@Test
public void testEncode() throws SQLException, UnsupportedEncodingException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
String result = filter.encode(conn, TEST_STRING);
Assert.assertEquals(convert.encode(TEST_STRING), result);
control.verify();
}
@Test
public void testDecode() throws SQLException, UnsupportedEncodingException {
control.reset();
conn.getAttributes();
EasyMock.expectLastCall().andReturn(attri);
control.replay();
String result = filter.decode(conn, TEST_STRING);
Assert.assertEquals(convert.decode(TEST_STRING), result);
control.verify();
}
}