Package org.nutz.dao.test.sqls

Source Code of org.nutz.dao.test.sqls.CallbackTest

package org.nutz.dao.test.sqls;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.sql.callback.FetchBooleanCallback;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.test.DaoCase;
import org.nutz.dao.test.meta.Pet;

public class CallbackTest extends DaoCase {

    @Test
    public void test_fetchBooleanCallback() {
        if (dao.meta().isOracle())
            return;
        pojos.initPet();
        dao.insert(Pet.create(4));

        Sql sql = Sqls.create("SELECT 'pet_02' IN (SELECT name FROM t_pet)");
        sql.setCallback(new FetchBooleanCallback());
        dao.execute(sql);
        boolean pet02IsExsit = sql.getBoolean();
        assertEquals(true, pet02IsExsit);

        sql = Sqls.create("SELECT 'pet_05' IN (SELECT name FROM t_pet)");
        sql.setCallback(new FetchBooleanCallback());
        dao.execute(sql);
        boolean pet05IsExsit = sql.getBoolean();
        assertEquals(false, pet05IsExsit);
    }
}
TOP

Related Classes of org.nutz.dao.test.sqls.CallbackTest

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.