Commit 9a6dad11 by Ryan Baxter

Fixing test failures

parent f511c267
...@@ -91,9 +91,7 @@ public class HystrixStreamTests { ...@@ -91,9 +91,7 @@ public class HystrixStreamTests {
assertThat(this.registration.getServiceId()).isEqualTo("mytestapp"); assertThat(this.registration.getServiceId()).isEqualTo("mytestapp");
this.task.gatherMetrics(); this.task.gatherMetrics();
Message<?> message = this.collector.forChannel(output).take(); Message<?> message = this.collector.forChannel(output).take();
// TODO: possible regression with Edgware? JsonNode tree = mapper.readTree((String)message.getPayload());
assertThat(message.getPayload()).isInstanceOf(byte[].class);
JsonNode tree = mapper.readTree(new String((byte[]) message.getPayload()));
assertThat(tree.hasNonNull("origin")); assertThat(tree.hasNonNull("origin"));
assertThat(tree.hasNonNull("data")); assertThat(tree.hasNonNull("data"));
} }
......
...@@ -155,8 +155,7 @@ public abstract class StreamSourceTestBase { ...@@ -155,8 +155,7 @@ public abstract class StreamSourceTestBase {
if (message == null) { if (message == null) {
return message; return message;
} }
Object fromMessage = converter().fromMessage(message, String.class); return MessageBuilder.createMessage(message.getPayload(), message.getHeaders());
return MessageBuilder.createMessage(fromMessage, message.getHeaders());
} }
catch (Exception e) { catch (Exception e) {
log.error("Exception occurred while trying to read a message from " log.error("Exception occurred while trying to read a message from "
......
...@@ -32,10 +32,13 @@ import com.netflix.zuul.exception.ZuulException; ...@@ -32,10 +32,13 @@ import com.netflix.zuul.exception.ZuulException;
import com.netflix.zuul.monitoring.CounterFactory; import com.netflix.zuul.monitoring.CounterFactory;
import com.netflix.zuul.monitoring.TracerFactory; import com.netflix.zuul.monitoring.TracerFactory;
import static io.micrometer.core.instrument.MockClock.clock;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.simple.SimpleConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
...@@ -68,6 +71,7 @@ public class ZuulMetricsApplicationTests { ...@@ -68,6 +71,7 @@ public class ZuulMetricsApplicationTests {
new ZuulException("any", 500, "cause"); new ZuulException("any", 500, "cause");
new ZuulException("any", 500, "cause"); new ZuulException("any", 500, "cause");
clock(meterRegistry).add(SimpleConfig.DEFAULT_STEP);
Double count = meterRegistry.counter("ZUUL::EXCEPTION:cause:500").count(); Double count = meterRegistry.counter("ZUUL::EXCEPTION:cause:500").count();
assertEquals(count.longValue(), 2L); assertEquals(count.longValue(), 2L);
...@@ -75,6 +79,7 @@ public class ZuulMetricsApplicationTests { ...@@ -75,6 +79,7 @@ public class ZuulMetricsApplicationTests {
new ZuulException("any", 404, "cause2"); new ZuulException("any", 404, "cause2");
new ZuulException("any", 404, "cause2"); new ZuulException("any", 404, "cause2");
clock(meterRegistry).add(SimpleConfig.DEFAULT_STEP);
count = meterRegistry.counter("ZUUL::EXCEPTION:cause2:404").count(); count = meterRegistry.counter("ZUUL::EXCEPTION:cause2:404").count();
assertEquals(count.longValue(), 3L); assertEquals(count.longValue(), 3L);
} }
...@@ -92,7 +97,7 @@ public class ZuulMetricsApplicationTests { ...@@ -92,7 +97,7 @@ public class ZuulMetricsApplicationTests {
@Bean @Bean
public MeterRegistry meterRegistry() { public MeterRegistry meterRegistry() {
return new SimpleMeterRegistry(); return new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment