spring测试类方式

本文通过SpringBoot集成Redis实现消息发送的功能测试,包括消息审核、停止消息和完成消息等操作,验证了Redis在消息管理系统中的应用效果。
import com.tourism.sms.contact.message.Example;
import com.tourism.sms.contact.message.entity.SendMsg;
import com.tourism.sms.contact.message.service.impl.RedisImpl;
import com.tourism.sms.contact.message.util.RedisClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Example.class)//你的启动类名称
public class redisImplTest {

    @Autowired
    private RedisImpl redisImpl;

    @Test
    public void shouldBeReturnTrueWhenPassExamineOrExcute() throws Exception {
        String smsId = "SMS1143794821643759617";
        boolean status = redisImpl.passExamineOrExcute(smsId);
        SendMsg sendMsg =(SendMsg) RedisClient.get(smsId);
        assertThat(sendMsg.getPeriod(),is("16:27:30-18:27:30"));
        assertThat(sendMsg.getStartTime(),is(1143037104302133249L));
        assertThat(status,is(true));
    }

    @Test
    public void shouldBeReturnTrueStopMessage(){
        String smsId = "SMS1143794821643759617";
        boolean status = redisImpl.stopMessage(smsId);
        assertThat(status,is(true));
    }

    @Test
    public void shouldBeReturnTrueWhenComplishMessage() throws Exception {
        String smsId = "SMS1143794821643759617";
        boolean status = redisImpl.complishMessage(smsId);
        assertThat(status,is(true));
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值