RedisServiceTest.java 1.3 KB
package com.sy.service;

import com.alibaba.fastjson.JSON;
import com.sy.model.LandBusinessTypeList;
import org.junit.jupiter.api.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.junit.jupiter.api.Assertions.*;

@RunWith(SpringRunner.class)
@SpringBootTest
class RedisServiceTest {

    @Autowired
    RedisService redisService;

    @Test
    void expire() {
    }

    @Test
    void hasKey() {
    }

    @Test
    void del() {
    }

    @Test
    void deleteBatchByKeys() {
    }

    @Test
    void get() {
    }

    @Test
    void set() {
        LandBusinessTypeList list = new LandBusinessTypeList();
        list.setTrailerFrameNo("豫A61CR7");
        list.setBarcode("123-3132");
        list.setAislewt(2022.22);
        list.setId("020201");
        list.setStartsatation("西货站");
        list.setEndstation("北货站");

        redisService.set(list.getTrailerFrameNo(), JSON.toJSONString(list),60*30);

        String userJson = redisService.get(list.getTrailerFrameNo());
        System.out.println("userJson = " + userJson);
        LandBusinessTypeList u = JSON.parseObject(userJson,LandBusinessTypeList.class);

    }

    @Test
    void testSet() {
    }
}