Search in sources :

Example 1 with StubHandle

use of cn.cerc.jbean.rds.StubHandle in project summer-mis by cn-cerc.

the class SvrUserLoginTest method test_sendVerifyCode.

@Test
@Ignore(value = "此处用于测试在5分钟内不允许重复申请验证码,耗时很长")
public void test_sendVerifyCode() throws InterruptedException, DataValidateException {
    String corpNo = "911001";
    String userCode = "91100123";
    String deviceId = "TEST";
    try (StubHandle handle = new StubHandle(corpNo, userCode)) {
        // 清空缓存
        try (MemoryBuffer buff = new MemoryBuffer(BufferType.getObject, handle.getUserCode(), SvrUserLogin.class.getName(), "sendVerifyCode")) {
            buff.clear();
        }
        // 检查验证码是否存在
        SqlQuery ds = new SqlQuery(handle);
        ds.add("select * from %s", SystemTable.get(SystemTable.getDeviceVerify));
        ds.add("where CorpNo_='%s'", corpNo);
        ds.add("and UserCode_='%s'", userCode);
        ds.add("and MachineCode_='%s'", deviceId);
        ds.open();
        String msg = String.format("帐号 %s 验证码 %s 不存在,无法完成测试", userCode, deviceId);
        assertThat(msg, ds.eof(), is(false));
        SvrUserLogin app = new SvrUserLogin();
        app.init(handle);
        app.getDataIn().getHead().setField("deviceId", deviceId);
        assertThat(app.sendVerifyCode(), is(true));
        Thread.sleep(1000 * 30);
        try {
            app.sendVerifyCode();
            assertThat("此处不应该执行到", false, is(true));
        } catch (Exception e) {
            e.printStackTrace();
            assertThat(e.getMessage().indexOf("5 分钟") > 0, is(true));
        }
        Thread.sleep(1000 * 60 * SvrUserLogin.TimeOut);
        assertThat(app.sendVerifyCode(), is(true));
    }
}
Also used : MemoryBuffer(cn.cerc.jbean.other.MemoryBuffer) StubHandle(cn.cerc.jbean.rds.StubHandle) SqlQuery(cn.cerc.jdb.mysql.SqlQuery) DataValidateException(cn.cerc.jbean.core.DataValidateException) ServiceException(cn.cerc.jbean.core.ServiceException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with StubHandle

use of cn.cerc.jbean.rds.StubHandle in project summer-mis by cn-cerc.

the class SvrUserLoginTest method testCheck2.

@Test
@Ignore
public void testCheck2() throws SecurityCheckException {
    StubHandle handle = new StubHandle();
    String userCode = handle.getUserCode();
    SvrUserLogin app = new SvrUserLogin();
    app.init(handle);
    Record headIn = app.getDataIn().getHead();
    headIn.setField("Account_", userCode);
    boolean ok = app.Check();
    assertEquals(app.getMessage(), "您的登录密码错误,禁止登录!");
    assertThat(app.getDataOut().getJSON(), is("{\"head\":{\"errorNo\":0}}"));
    assertTrue(!ok);
}
Also used : StubHandle(cn.cerc.jbean.rds.StubHandle) Record(cn.cerc.jdb.core.Record) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with StubHandle

use of cn.cerc.jbean.rds.StubHandle in project summer-mis by cn-cerc.

the class PhoneVerifyTest method setUp.

@Before
public void setUp() throws Exception {
    handle = new StubHandle();
    obj = new PhoneVerify(handle, mobile);
}
Also used : PhoneVerify(cn.cerc.jmis.sms.PhoneVerify) StubHandle(cn.cerc.jbean.rds.StubHandle) Before(org.junit.Before)

Example 4 with StubHandle

use of cn.cerc.jbean.rds.StubHandle in project summer-mis by cn-cerc.

the class SvrUserLoginTest method testCheck3.

@Test
@Ignore
public void testCheck3() throws Exception {
    String corpNo = "911001";
    String userCode = "9110010001";
    StubHandle handle = new StubHandle(corpNo, userCode);
    SvrUserLogin app = new SvrUserLogin();
    app.init(handle);
    Record headIn = app.getDataIn().getHead();
    headIn.setField("Account_", userCode);
    boolean ok = app.Check();
    assertEquals(app.getMessage(), "您的登录密码错误,禁止登录!");
    assertThat(app.getDataOut().getJSON(), is("{\"head\":{\"errorNo\":0}}"));
    assertTrue(!ok);
}
Also used : StubHandle(cn.cerc.jbean.rds.StubHandle) Record(cn.cerc.jdb.core.Record) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with StubHandle

use of cn.cerc.jbean.rds.StubHandle in project summer-mis by cn-cerc.

the class SvrUserLoginTest method testCheck1.

// private static final Logger log = Logger.getLogger(TAppLoginTest.class);
// 测试帐号找不到时的提示
@Test(expected = ServiceException.class)
@Ignore
public void testCheck1() throws Exception {
    String corpNo = "911001";
    String userCode = "91100101";
    StubHandle handle = new StubHandle(corpNo, userCode);
    SvrUserLogin app = new SvrUserLogin();
    app.init(handle);
    Record headIn = app.getDataIn().getHead();
    headIn.setField("Account_", userCode);
    assertFalse(app.Check());
}
Also used : StubHandle(cn.cerc.jbean.rds.StubHandle) Record(cn.cerc.jdb.core.Record) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

StubHandle (cn.cerc.jbean.rds.StubHandle)8 Ignore (org.junit.Ignore)5 Test (org.junit.Test)5 Record (cn.cerc.jdb.core.Record)3 DataValidateException (cn.cerc.jbean.core.DataValidateException)1 ServiceException (cn.cerc.jbean.core.ServiceException)1 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)1 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)1 PhoneVerify (cn.cerc.jmis.sms.PhoneVerify)1 Calendar (java.util.Calendar)1 Before (org.junit.Before)1