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);
        }
    }
  • 相关阅读:
    poj 2391 Ombrophobic Bovines
    混合欧拉回路poj 1637 Sightseeing tour
    POJ1149-PIGS
    C
    B
    A
    C
    B
    A
    O
  • 原文地址:https://www.cnblogs.com/beixiaoyi/p/14117074.html
Copyright © 2011-2022 走看看