Examples of Follower


Examples of com.alibaba.cobar.client.entities.Follower

    }

    public void testInsertOnCobarSqlMapClientTemplateWithSingleEntityNormally() {

        String name = "Darren"; // shard standard
        Follower f = new Follower(name);
        getSqlMapClientTemplate().insert(insertSQLAction, f);

        String sql = "select name from followers where name='" + name + "'";
        verifyEntityNonExistenceOnSpecificDataSource(sql, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(sql, jt1s);
        verifyEntityExistenceOnSpecificDataSource(sql, jt2m);
        verifyEntityNonExistenceOnSpecificDataSource(sql, jt2s);

        name = "Aaron";
        f = new Follower(name);
        getSqlMapClientTemplate().insert(insertSQLAction, f);

        sql = "select name from followers where name='" + name + "'";
        verifyEntityExistenceOnSpecificDataSource(sql, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(sql, jt2m);
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

    public void testInsertOnCobarSqlMapClientTemplateWithMultipleEntities() {
        String[] names = { "Aaron", "Amily", "Aragon", "Darren", "Darwin" };

        List<Follower> followers = new ArrayList<Follower>();
        for (String name : names) {
            followers.add(new Follower(name));
        }
        /**
         * NOTE: if the sqlmap is drafted with invalid format, data access
         * exception will be raised, usually, the information of exception
         * doesn't tell too much.
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

     * if no rule is found for current data access request, the data access
     * request will be performed on default data source, that's, partition1.
     */
    public void testInsertWithoutFindingRuleOnCobarSqlMapClientTemplate() {
        String nameStartsWithS = "Sara";
        Follower follower = new Follower(nameStartsWithS);
        getSqlMapClientTemplate().insert(insertSQLAction, follower);

        String confirmSQL = "select name from followers where name='" + nameStartsWithS + "'";
        verifyEntityExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);
    }

    public void testDeleteOnCobarSqlMapClientTemplate() {
        Follower f = new Follower("Darren");
        getSqlMapClientTemplate().insert("com.alibaba.cobar.client.entities.Follower.create", f);

        String confirmSQL = "select name from followers where name='Darren'";
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

    /**
     * MARK!!!
     */
    public void testDeleteWithExpectedResultSizeOnCobarSqlMapClientTemplate() {
        Follower f = new Follower("Darren");
        getSqlMapClientTemplate().insert("com.alibaba.cobar.client.entities.Follower.create", f);

        String confirmSQL = "select name from followers where name='Darren'";
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
        verifyEntityExistenceOnSpecificDataSource(confirmSQL, jt2m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);

        try {
            getSqlMapClientTemplate().delete("com.alibaba.cobar.client.entities.Follower.deleteByName",
                    f, 2);
            fail("only one row will be affected in fact.");
        } catch (DataAccessException e) {
            assertTrue(e instanceof JdbcUpdateAffectedIncorrectNumberOfRowsException);
            JdbcUpdateAffectedIncorrectNumberOfRowsException ex = (JdbcUpdateAffectedIncorrectNumberOfRowsException) e;
            assertEquals(1, ex.getActualRowsAffected());
        }
        // although JdbcUpdateAffectedIncorrectNumberOfRowsException is raised, but the delete does performed successfully.
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);

        try {
            getSqlMapClientTemplate().delete("com.alibaba.cobar.client.entities.Follower.deleteByName",
                    f, 0);
        } catch (DataAccessException e) {
            fail();
        }

        f = new Follower("Amanda");
        try {
            getSqlMapClientTemplate().delete("com.alibaba.cobar.client.entities.Follower.deleteByName",
                    f, 0);
        } catch (DataAccessException e) {
            fail();
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

        String[] names = { "Aaron", "Amily", "Aragon", "Darren", "Darwin" };
        batchInsertMultipleFollowersAsFixture(names);

        // 2. assertion.
        for (String name : names) {
            Follower follower = (Follower) getSqlMapClientTemplate().queryForObject(
                    "com.alibaba.cobar.client.entities.Follower.finaByName", name);
            if (name.startsWith("A")) {
                assertNotNull(follower);
            } else {
                assertNull(follower);
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

        batchInsertMultipleFollowersAsFixture(names);

        String nameSuffix = "Wang";
        for (String name : names) {
            if (name.startsWith("A")) {
                Follower follower = (Follower) getSqlMapClientTemplate().queryForObject(
                        "com.alibaba.cobar.client.entities.Follower.finaByName", name);
                assertNotNull(follower);
                follower.setName(follower.getName() + nameSuffix);
                getSqlMapClientTemplate().update(
                        "com.alibaba.cobar.client.entities.Follower.update", follower);

                Long id = follower.getId();

                follower = null;
                follower = (Follower) getSqlMapClientTemplate().queryForObject(
                        "com.alibaba.cobar.client.entities.Follower.finaByName", name);
                assertNull(follower);

                follower = (Follower) getSqlMapClientTemplate().queryForObject(
                        "com.alibaba.cobar.client.entities.Follower.load", id);
                assertNotNull(follower);
                assertEquals(name + nameSuffix, follower.getName());
            } else {
                String sql = "select * from followers where name=?";
                RowMapper rowMapper = new RowMapper() {
                    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                        Follower f = new Follower();
                        f.setId(rs.getLong(1));
                        f.setName(rs.getString(2));
                        return f;
                    }
                };
                Follower follower = (Follower) jt2m.queryForObject(sql, new Object[] { name },
                        rowMapper);
                assertNotNull(follower);
                follower.setName(follower.getName() + nameSuffix);
                getSqlMapClientTemplate().update(
                        "com.alibaba.cobar.client.entities.Follower.update", follower);

                Long id = follower.getId();

                follower = null;
                try {
                    follower = (Follower) jt2m
                            .queryForObject(sql, new Object[] { name }, rowMapper);
                    fail();
                } catch (DataAccessException e) {
                    assertTrue(e instanceof EmptyResultDataAccessException);
                }

                follower = (Follower) jt2m.queryForObject("select * from followers where id=?",
                        new Object[] { id }, rowMapper);
                assertNotNull(follower);
                assertEquals(name + nameSuffix, follower.getName());
            }
        }
    }
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

     */
    public void testExecutePrefixMethodsOnCobarSqlMapClientTemplate() {

        getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
            public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
                Follower f = new Follower("fname");
                return executor.insert("com.alibaba.cobar.client.entities.Follower.create", f);
            }
        });

        String confirmSQL = "select name from followers where name='fname'";
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

        verifyEntityExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt2s);

        Follower f = new Follower("fname");
         getSqlMapClientTemplate().insert("com.alibaba.cobar.client.entities.Follower.create", f);

        confirmSQL = "select name from followers where name='fname'";
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
View Full Code Here

Examples of com.alibaba.cobar.client.entities.Follower

            verifyEntityNonExistenceOnSpecificDataSource(sql, jt2s);
        }
    }

    public void testDeleteOnCobarSqlMapClientTemplate() {
        Follower f = new Follower("fname");
         getSqlMapClientTemplate().insert("com.alibaba.cobar.client.entities.Follower.create", f);

        String confirmSQL = "select name from followers where name='fname'";
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1m);
        verifyEntityNonExistenceOnSpecificDataSource(confirmSQL, jt1s);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.