Skip to content

Commit

Permalink
Gh 3409 turbine stream test (#3665)
Browse files Browse the repository at this point in the history
* Add stream-test-support.

* Fix condition.

* Remove outdated workaround.

(cherry picked from commit 24f5e0b)
  • Loading branch information
OlgaMaciaszek committed Sep 26, 2019
1 parent d162986 commit 2133840
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
5 changes: 5 additions & 0 deletions spring-cloud-netflix-turbine-stream/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,10 @@
<artifactId>spring-cloud-netflix-hystrix-contract</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.contract.stubrunner.StubTrigger;
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties.StubsMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
Expand All @@ -63,12 +58,13 @@
* @author Daniel Lavoie
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TurbineStreamTests.Application.class, webEnvironment = RANDOM_PORT, properties = {
// TODO: we don't need this if we harmonize the turbine and hystrix destinations
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = {
// TODO: we don't need this if we harmonize the turbine and hystrix
// destinations
// https://github.com/spring-cloud/spring-cloud-netflix/issues/1948
"spring.cloud.stream.bindings.turbineStreamInput.destination=hystrixStreamOutput",
"spring.jmx.enabled=true", "stubrunner.workOffline=true",
"stubrunner.ids=org.springframework.cloud:spring-cloud-netflix-hystrix-stream:${projectVersion:2.0.0.BUILD-SNAPSHOT}:stubs" })
"stubrunner.ids=org.springframework.cloud:spring-cloud-netflix-hystrix-stream:${projectVersion:2.1.3.BUILD-SNAPSHOT}:stubs" })
@AutoConfigureStubRunner(stubsMode = StubsMode.LOCAL)
public class TurbineStreamTests {

Expand Down Expand Up @@ -106,7 +102,7 @@ public void contextLoads() throws Exception {
}

private boolean containsMetrics(String line) {
return line.startsWith("data:") && !line.contains("Ping");
return line.startsWith("data:") && !line.contains("ping");
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -145,28 +141,8 @@ private ResponseEntity<String> extract(ClientHttpResponse response)

@EnableAutoConfiguration
@EnableTurbineStream
public static class Application {

// Workaround for stub runner lowercasing id somewhere
@Bean
BeanDefinitionRegistryPostProcessor myBeanDefinitionRegistryPostProcessor() {
return new BeanDefinitionRegistryPostProcessor() {
@Override
public void postProcessBeanDefinitionRegistry(
BeanDefinitionRegistry registry) throws BeansException {
BeanDefinition beanDefinition = registry
.getBeanDefinition(TurbineStreamClient.INPUT);
registry.registerBeanDefinition(
TurbineStreamClient.INPUT.toLowerCase(), beanDefinition);
}

@Override
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory)
throws BeansException {
}
};
}
@Configuration
public static class TestConfig {

}

Expand Down

0 comments on commit 2133840

Please sign in to comment.