zoukankan      html  css  js  c++  java
  • springboot 使用socket组件 时对其他方法进行单元测试踩过的坑

    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);
        }
    }
  • 相关阅读:
    八卦——朋友的老公有外遇
    吃,玩——幸福的上海一天
    婚礼——金茂群楼豪华婚礼
    吃狂吃大喜九
    玩——苏州粗体验
    XCF之原形
    快速类型判定
    ReaderWriterLockSlim使用注意事项
    WCF服务端基于配置的实现——路由
    Opera使用心得
  • 原文地址:https://www.cnblogs.com/beixiaoyi/p/14117074.html
Copyright © 2011-2022 走看看