我有一个非常奇怪的问题与surefire插件,因为即使我已经添加surefire插件到我的春季启动项目当我尝试运行这个强大的项目,恰好由父模块和另外两个在intellij的帮助下组成.然后测试通过,一切似乎都没问题但是当我尝试用circleci运行这个项目时,会导致这个错误
[INFO] sfg-pet-clinic ..................................... SUCCESS [ 0.578 s]
[INFO] pet-clinic-data .................................... FAILURE [ 1.233 s]
[INFO] pet-clinic-web ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.038 s
[INFO] Finished at: 2018-11-12T20:13:34Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.0:test (default-test) on project pet-clinic-data: There are test failures.
[ERROR]
[ERROR] Please refer to /home/circleci/repo/pet-clinic-data/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] The forked VM terminated …
Run Code Online (Sandbox Code Playgroud) 我正在尝试运行简单的单元测试,Keycloak 以正确的方式配置(我测试了它并且我的 mvc 应用程序正在连接并且用户已通过身份验证_但现在我尝试测试我的控制器,即使我使用了 spring slices keycloak 适配器被调用和给我错误。适配器配置主要来自 keycloak 文档
@WebMvcTest(UserController.class)
class UserControllerTest {
@MockBean
UserService userService;
@Autowired
MockMvc mockMvc;
@BeforeEach
void setUp() {
}
@AfterEach
void tearDown() {
reset(userService);
}
@Test
void logout() throws Exception {
mockMvc.perform(get("/logout"))
.andExpect(status().isOk());
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行它时出现错误,堆栈跟踪:
java.lang.NullPointerException
at org.keycloak.adapters.KeycloakDeploymentBuilder.internalBuild(KeycloakDeploymentBuilder.java:57)
at org.keycloak.adapters.KeycloakDeploymentBuilder.build(KeycloakDeploymentBuilder.java:205)
at org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver.resolve(KeycloakSpringBootConfigResolver.java:37)
at org.keycloak.adapters.springsecurity.config.KeycloakSpringConfigResolverWrapper.resolve(KeycloakSpringConfigResolverWrapper.java:40)
at org.keycloak.adapters.AdapterDeploymentContext.resolveDeployment(AdapterDeploymentContext.java:89)
at org.keycloak.adapters.springsecurity.filter.KeycloakPreAuthActionsFilter.doFilter(KeycloakPreAuthActionsFilter.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:133)
at …
Run Code Online (Sandbox Code Playgroud) 我正在使用弹簧靴,我的 POM 如下所示:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
但仅当我正在测试但测试正在工作时,所以这不会影响测试,但这是不寻常的,当我通常运行 spring 应用程序时,一切都很好
public class CategoryControllerTest {
WebTestClient webTestClient;
CategoryRepository categoryRepository;
CategoryController categoryController;
@Before
public void setUp() throws Exception {
categoryRepository = Mockito.mock(CategoryRepository.class);
categoryController = new CategoryController(categoryRepository);
webTestClient = WebTestClient.bindToController(categoryController).build();
}
@Test
public void list() …
Run Code Online (Sandbox Code Playgroud) 我已经在 docker 中登录到虚拟机,但我找不到 standalone.sh 它不在 /bin 中。我也不知道如何编写设置 -Djboss.socket.binding.port-offset=100 的 dockerfile