首页 > 编程语言 > 详细

springboot 使用socket组件 时对其他方法进行单元测试踩过的坑

时间:2020-12-10 21:44:16      阅读:34      评论:0      收藏:0      [点我收藏+]
package org.atgpcm.system.service;

import org.atgpcm.system.domain.SysAppletsConfig;
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;

/**
* @Description:
* @Author: ldg
* @Date: 2020/12/10
 *
 *          <dependency>
*               <groupId>org.springframework.boot</groupId>
 * *             <artifactId>spring-boot-starter-test</artifactId>
 * *         </dependency>
 *
 *
 * 如果项目中引入了websocket
 * @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 *
 * 原因 用@SpringBootTest(classes= {Pcm*******Application.class})
 * 会报  Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not availabl 错
*/
@RunWith(SpringRunner.class)
//@SpringBootTest(classes= {PcmServiceAdminApplication.class})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SysFunctionServiceTest {

    @Autowired
    private SysFunctionService sysFunctionService;

    @Test
    public void getAppletsConfig() {
        SysAppletsConfig sysAppletsConfig = new SysAppletsConfig();
        sysAppletsConfig.setId(1);
        sysFunctionService.getAppletsConfig(sysAppletsConfig);
    }
}

 

springboot 使用socket组件 时对其他方法进行单元测试踩过的坑

原文:https://www.cnblogs.com/beixiaoyi/p/14117074.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!