Package com.alibaba.druid.filter.encoding

Examples of com.alibaba.druid.filter.encoding.EncodingConvertFilter


    public void test_stat() throws Exception {

        Assert.assertTrue(dataSource.isInited());
       
        EncodingConvertFilter filter = (EncodingConvertFilter) dataSource.getProxyFilters().get(0);

        DruidPooledConnection conn = dataSource.getConnection();

        final String PARAM_VALUE = "中国";
        PreparedStatement stmt = conn.prepareStatement("select ?");
        stmt.setString(1, PARAM_VALUE);

        MockPreparedStatement raw = stmt.unwrap(MockPreparedStatement.class);

        String param1 = (String) raw.getParameters().get(0);

        Assert.assertEquals(PARAM_VALUE, new String(param1.getBytes(SERVER_ENCODING), CLIENT_ENCODING));
        Assert.assertFalse(param1.equals(PARAM_VALUE));

        ResultSet rs = stmt.executeQuery();
       
        MyResultSet rawRs = rs.unwrap(MyResultSet.class);
        rawRs.setValue(filter.encode((ConnectionProxy) conn.getConnection(), text));
       
        rs.next();

         Assert.assertEquals(text, rs.getString(1));
View Full Code Here


    public void test_stat() throws Exception {

        Assert.assertTrue(dataSource.isInited());

        EncodingConvertFilter filter = (EncodingConvertFilter) dataSource.getProxyFilters().get(0);

        DruidPooledConnection conn = dataSource.getConnection();

        final String PARAM_VALUE = "中国";
        CallableStatement stmt = conn.prepareCall("select ?");
        stmt.setString(1, PARAM_VALUE);

        MockCallableStatement raw = stmt.unwrap(MockCallableStatement.class);

        stmt.execute();
        String param1 = (String) raw.getParameters().get(0);

        String C_TEXT = new String(param1.getBytes(SERVER_ENCODING), CLIENT_ENCODING);
        Assert.assertEquals(PARAM_VALUE, C_TEXT);
        Assert.assertFalse(param1.equals(PARAM_VALUE));

        MyResultSet rawRs = new MyResultSet(raw);

        rawRs.setValue(filter.encode((ConnectionProxy) conn.getConnection(), text));

        raw.getOutParameters().add(rawRs);

        ResultSet rs = (ResultSet) stmt.getObject(1);
View Full Code Here

TOP

Related Classes of com.alibaba.druid.filter.encoding.EncodingConvertFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.