package com.kwan.springbootkwan; import com.kwan.springbootkwan.utils.SensitiveWordUtil; 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.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ContextConfiguration(classes = AppApplication.class) public class SensitiveTest { @Autowired private SensitiveWordUtil sensitiveWordUtil; @Test public void test() { String result = sensitiveWordUtil.replace("国家 哇 nnd 复活 马化腾"); System.out.println(result); } }