Browse Source

Stabilise some tests

pull/6/head
Dave Syer 8 years ago
parent
commit
957e33207e
  1. 7
      spring-cloud-netflix-hystrix-contract/src/main/java/org/springframework/cloud/netflix/hystrix/contract/HystrixContractUtils.java
  2. 8
      spring-cloud-netflix-hystrix-stream/src/main/java/org/springframework/cloud/netflix/hystrix/stream/HystrixStreamTask.java

7
spring-cloud-netflix-hystrix-contract/src/main/java/org/springframework/cloud/netflix/hystrix/contract/HystrixContractUtils.java

@ -50,7 +50,14 @@ public class HystrixContractUtils { @@ -50,7 +50,14 @@ public class HystrixContractUtils {
}
public static void checkData(Map<String, Object> data, String group, String name) {
if (!data.get("type").equals("HystrixCommand")) {
assertThat(data.get("type")).isEqualTo("HystrixThreadPool");
return;
}
assertThat(data.get("type")).isEqualTo("HystrixCommand");
if (!data.get("name").equals(name)) {
return;
}
assertThat(data.get("name")).asString().isEqualTo(name);
assertThat(data.get("group")).isNotNull();
assertThat(data.get("group")).isEqualTo(group);

8
spring-cloud-netflix-hystrix-stream/src/main/java/org/springframework/cloud/netflix/hystrix/stream/HystrixStreamTask.java

@ -52,7 +52,7 @@ import org.springframework.scheduling.annotation.Scheduled; @@ -52,7 +52,7 @@ import org.springframework.scheduling.annotation.Scheduled;
* private class MetricsPoller)
*/
public class HystrixStreamTask implements ApplicationContextAware {
private static Log log = LogFactory.getLog(HystrixStreamTask.class);
private MessageChannel outboundChannel;
@ -68,7 +68,8 @@ public class HystrixStreamTask implements ApplicationContextAware { @@ -68,7 +68,8 @@ public class HystrixStreamTask implements ApplicationContextAware {
private final JsonFactory jsonFactory = new JsonFactory();
public HystrixStreamTask(MessageChannel outboundChannel, DiscoveryClient discoveryClient, HystrixStreamProperties properties) {
public HystrixStreamTask(MessageChannel outboundChannel,
DiscoveryClient discoveryClient, HystrixStreamProperties properties) {
this.outboundChannel = outboundChannel;
this.discoveryClient = discoveryClient;
this.properties = properties;
@ -94,7 +95,8 @@ public class HystrixStreamTask implements ApplicationContextAware { @@ -94,7 +95,8 @@ public class HystrixStreamTask implements ApplicationContextAware {
for (String json : metrics) {
// TODO: batch all metrics to one message
try {
// TODO: remove the explicit content type when s-c-stream can handle that for us
// TODO: remove the explicit content type when s-c-stream can handle
// that for us
this.outboundChannel.send(MessageBuilder.withPayload(json)
.setHeader(MessageHeaders.CONTENT_TYPE,
this.properties.getContentType())

Loading…
Cancel
Save