package com.ylz.jcpt.report.service;
import com.ylz.ybkf.fjjcpt.FjjcptApplication;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@SpringBootTest(classes = FjjcptApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@ActiveProfiles("default")
public class TestCache {
@Cacheable("aaa")
public String get() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "aaa";
}
@Test
public void testGet(){
log.info("start");
log.info("value={}",get());
log.info("value={}",get());
log.info("value={}",get());
}
}
spring boot 测试用例,配置profile和指定随机端口
最新推荐文章于 2024-07-09 12:08:02 发布