2017-08-11 1 views
2

Ich habe eine Anwendung, die Spring Webflux über Spring Boot 2.0.0.M3 verwendet.Fehler beim Starten des Spring Boot-Integrationstests beim Festlegen des Anwendungstyps als reaktiv

Die Anwendung wird als REACTIVE Typ bei der Ausführung festgelegt.

Die reaktive App funktioniert gut, wenn die Hauptanwendung ausgeführt wird. Aber ich habe diese App in meinem Spring-Boot-Integrationstest nicht gestartet.

ich den Test, wie unten erklärt,

@RunWith(SpringRunner.class) 
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, 
    properties = {"spring.main.webApplicationType=reactive"}) 
@ActiveProfiles("integTest") 
public class NoteHandlerTest { 

@Autowired 
private WebTestClient webClient; 

@Test 
public void testGetNoteNotFound() throws Exception { 
    this.webClient.get().uri("/note/request/{id}", "nosuchid").accept(MediaType.APPLICATION_JSON_UTF8) 
      .exchange().expectStatus().isOk(); 
} 

} 

ich unten Fehler bekam bei dem Testfall ausgeführt wird,

java.lang.IllegalStateException: Fehler Application

bei laden org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext (DefaultCacheAwareContextLoaderDelegate.java:125) unter org.springframework.test.context.support.DefaultTestContext.getApplicationContext (DefaultTestContext.java:107) bei org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:117) bei org.springframework .test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance (DependencyInjectionTestExecutionListener.java:83) bei org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance (SpringBootDependencyInjectionTestExecutionListener.java:44) bei org.springframework.test.context .TestContextManager.prepareTestInstance (TestContextManager.java:242) bei org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest (SpringJUnit4ClassRunner.java:227) bei org.springframework.test.context.junit4.SpringJUnit4ClassRunner $ 1.runReflectiveCall (SpringJUnit4ClassRunner.java:289) bei org .junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java:12) bei org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock (SpringJUnit4ClassRunner.java:291) bei org.springframework.test .context.junit4.SpringJUnit4ClassRunner.runChild (SpringJUnit4ClassRunner.java:246) um org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (SpringJUnit4ClassRunner.java:97) bei org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:290) um org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java:71) um org.junit.runners.ParentRunner.runChildren (ParentRunner.java:288) um ​​ org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:58) um ​​ org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:268) um ​​ org.springframework. test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate (RunBeforeTestClassCallbacks.java:61) bei org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate (RunAfterTestClassCallbacks.java:70) bei org.junit.runners .ParentRunner.run (ParentRunner.java:363) um org.springframework.test.context. junit4.SpringJUnit4ClassRunner.run (SpringJUnit4ClassRunner.java:190) bei org.junit.runner.JUnitCore.run (JUnitCore.java: 137) bei com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs (JUnit4IdeaTestRunner.java:68) bei com.intellij.rt.execution.junit.IdeaTestRunner $ Repeater.startRunnerWithArgs (IdeaTestRunner.java:51) bei com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart (JUnitStarter.java:242) bei com.intellij.rt.execution.junit.JUnitStarter.main (JUnitStarter.java:70) verursacht durch: org.springframework .context.ApplicationContextException: Kann reaktiven Webserver nicht starten; verschachtelte Ausnahme ist org.springframework.context.ApplicationContextException: Kann nicht auf ReactiveWebApplicationContext aufgrund fehlender ReactiveWebServerFactory Bean starten. bei org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh (ReactiveWebServerApplicationContext.java:64) bei org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543) bei org. springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh (ReactiveWebServerApplicationContext.java:49) bei org.springframework.boot.SpringApplication.refresh (SpringApplication.java:750) bei org.springframework.boot.SpringApplication. refreshContext (SpringApplication.java:386) um org.springframework.boot.SpringApplication.run (SpringApplication.java:327) bei org.springframework.boot.builder.SpringApplicationBuilder.run (SpringApplicationBuilder.java:136) bei org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext (BootstrapApplicationListener.java:177) bei org.springframework.cloud .bootstrap.BootstrapApplicationListener.onApplicationEvent (BootstrapApplicationListener.java:99) bei org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent (BootstrapApplicationListener.java:65) bei org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener (SimpleApplicationEventMulticaster .java: 167) unter o rg.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:139) bei org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:127) bei org.springframework.boot.context. event.EventPublishingRunListener.environmentPrepared (EventPublishingRunListener.java:73) bei org.springframework.boot.SpringApplicationRunListeners.environmentPrepared (SpringApplicationRunListeners.java:54) bei org.springframework.boot.SpringApplication.prepareEnvironment (SpringApplication.java:349) um org.springframework.boot.SpringApplication.run (SpringApplication.java:317) bei org.springframework.boot.test.context.SpringBootContextLoader.loadContext (SpringBootContextLoader.java:138) bei org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal (DefaultCacheAwareContextLoaderDelegate.java:99) bei org .springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext (DefaultCacheAwareContextLoaderDelegate.java:117) ... 25 weitere verursacht durch: org.springframework.context.ApplicationContextException: Können Start ReactiveWebApplicationContext aufgrund fehlender ReactiveWebServerFactory Bohne. bei org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.getWebServerFactory (ReactiveWebServerApplicationContext.java:103) bei org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer (ReactiveWebServerApplicationContext.java:87) bei org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh (ReactiveWebServerApplicationContext.java:61) ... 44 weiteren

es jedes Konfigurationsproblem Frühjahr Boot Integrationstest mit laufen müssen Hat webflux?

Sie können auf das vollständige Demo-Projekt von here zugreifen.

+0

zu Ich schlage diesen Fehler verwenden. Hast du Fortschritte gemacht? – ttiurani

+0

Es stellte sich heraus, dass es durch die Abhängigkeiten von 'spring cloud' verursacht wurde, die immer noch mit der Integration in Frühling 5 funktioniert. Siehe [diese Ausgabe] (https://github.com/spring-projects/spring-boot/issues/10017) für Details. – Kane

+0

Danke für die Info! Am Ende habe ich @SpringBootTest überhaupt nicht benutzt, weil ich beim Start sowieso noch andere Sachen verdrahten musste. – ttiurani

Antwort

0

Ist das nicht nur ein Tippfehler in Ihrer Konfigurationseigenschaft?

"spring.main.web-application-type=reactive"

0

Ich hatte diese auch Ausnahme, wenn

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 

statt

@SpringBootTest() 
Verwandte Themen