Package com.alibaba.druid.mock

Examples of com.alibaba.druid.mock.MockPreparedStatement


        String sql = "select 1";
        Statement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE,
                                               ResultSet.CLOSE_CURSORS_AT_COMMIT);

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

        Assert.assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, mockStmt.getResultSetType());
        Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
        Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());

        stmt.close();

        conn.close();
    }
View Full Code Here


        if (stmt instanceof NewProxyPreparedStatement) {
            Field field = NewProxyPreparedStatement.class.getDeclaredField("inner");
            field.setAccessible(true);
            return (MockPreparedStatement) field.get(stmt);
        }
        MockPreparedStatement mockStmt = stmt.unwrap(MockPreparedStatement.class);
        return mockStmt;
    }
View Full Code Here

        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();
View Full Code Here

        Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
    }

    public void test_removeAbandoned() throws Exception {

        MockPreparedStatement raw;
        {
            Connection conn = dataSource.getConnection();
            PreparedStatement stmt = conn.prepareStatement("SELECT ?");
            raw = stmt.unwrap(MockPreparedStatement.class);
            stmt.execute();
View Full Code Here

        DruidDataSource dataSource = new DruidDataSource();
        MockConnection conn = new MockConnection();
        PreparedStatementKey k1 = new PreparedStatementKey("x1", "c1", MethodType.M1);

        PreparedStatementPool pool = new PreparedStatementPool(new DruidConnectionHolder(dataSource, conn));
        MockPreparedStatement raw = new MockPreparedStatement(null, null);
        pool.put(new PreparedStatementHolder(k1, raw));

        Assert.assertTrue(pool.get(k1) != null);
        Assert.assertTrue(pool.get(k1) != null);
    }
View Full Code Here

        dataSource.setUrl("jdbc:mock:xxx");
        dataSource.setMaxPoolPreparedStatementPerConnectionSize(30);

        String sql = "SELECT 1";

        MockPreparedStatement mockStmt = null;
        {
            Connection conn = dataSource.getConnection();

            PreparedStatement stmt = conn.prepareStatement(sql);
            mockStmt = stmt.unwrap(MockPreparedStatement.class);
View Full Code Here

    protected void tearDown() throws Exception {
        JdbcUtils.close(dataSource);
    }

    public void test_0() throws Exception {
        MockPreparedStatement mockStmt = null;
        {
            Connection conn = dataSource.getConnection();
            PreparedStatement ps = conn.prepareStatement("select 1");
            mockStmt = ps.unwrap(MockPreparedStatement.class);
            ps.execute();
View Full Code Here

                }
            } else if (expr instanceof SQLVariantRefExpr) {
                SQLVariantRefExpr varExpr = (SQLVariantRefExpr) expr;
                int varIndex = varExpr.getIndex();
                if (statement instanceof MockPreparedStatement) {
                    MockPreparedStatement mockPstmt = (MockPreparedStatement) statement;
                    row[i] = mockPstmt.getParameters().get(varIndex);
                } else {
                    row[i] = null;
                }
            } else {
                row[i] = null;
View Full Code Here

                }
            } else if (expr instanceof SQLVariantRefExpr) {
                SQLVariantRefExpr varExpr = (SQLVariantRefExpr) expr;
                int varIndex = varExpr.getIndex();
                if (statement instanceof MockPreparedStatement) {
                    MockPreparedStatement mockPstmt = (MockPreparedStatement) statement;
                    row[i] = mockPstmt.getParameters().get(varIndex);
                } else {
                    row[i] = null;
                }
            } else {
                row[i] = null;
View Full Code Here

                }
            } else if (expr instanceof SQLVariantRefExpr) {
                SQLVariantRefExpr varExpr = (SQLVariantRefExpr) expr;
                int varIndex = varExpr.getIndex();
                if (statement instanceof MockPreparedStatement) {
                    MockPreparedStatement mockPstmt = (MockPreparedStatement) statement;
                    row[i] = mockPstmt.getParameters().get(varIndex);
                } else {
                    row[i] = null;
                }
            } else {
                row[i] = null;
View Full Code Here

TOP

Related Classes of com.alibaba.druid.mock.MockPreparedStatement

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.