From 83ae0b2fc18679afb5d9a11309b51dbc8f7bed9c Mon Sep 17 00:00:00 2001 From: rajuGT Date: Mon, 14 Aug 2017 03:03:26 +0530 Subject: [PATCH] PR#4: Test coverage for public constructors. --- .../zapodot/hystrix/bundle/HystrixBundle.java | 4 +--- .../hystrix/bundle/HystrixBundleTest.java | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/zapodot/hystrix/bundle/HystrixBundle.java b/src/main/java/org/zapodot/hystrix/bundle/HystrixBundle.java index 5e9530e..b7a953d 100755 --- a/src/main/java/org/zapodot/hystrix/bundle/HystrixBundle.java +++ b/src/main/java/org/zapodot/hystrix/bundle/HystrixBundle.java @@ -31,9 +31,7 @@ public class HystrixBundle implements ConfiguredBundle< private final boolean publishHystrixMetrics; public HystrixBundle() { - this.adminStreamPath = DEFAULT_STREAM_PATH; - this.applicationStreamUri = null; - this.publishHystrixMetrics = DEFAULT_PUBLISH_HYSTRIX_METRICS; + this(DEFAULT_STREAM_PATH, null, DEFAULT_PUBLISH_HYSTRIX_METRICS); } /** diff --git a/src/test/java/org/zapodot/hystrix/bundle/HystrixBundleTest.java b/src/test/java/org/zapodot/hystrix/bundle/HystrixBundleTest.java index 1c79422..bffe24e 100755 --- a/src/test/java/org/zapodot/hystrix/bundle/HystrixBundleTest.java +++ b/src/test/java/org/zapodot/hystrix/bundle/HystrixBundleTest.java @@ -43,8 +43,8 @@ public void setUp() throws Exception { } @Test - public void testWithDefaults() throws Exception { - final HystrixBundle hystrixBundle = HystrixBundle.withDefaultSettings(); + public void testWithDefaultsUsingConstructor() throws Exception { + final HystrixBundle hystrixBundle = new HystrixBundle(); hystrixBundle.initialize(bootstrap); hystrixBundle.run(configuration, environment); assertNotNull(environment.getAdminContext() @@ -57,6 +57,21 @@ public void testWithDefaults() throws Exception { verifyZeroInteractions(bootstrap); } + @Test + public void testWithDefaultsUsingBuilder() throws Exception { + final HystrixBundle hystrixBundle = HystrixBundle.withDefaultSettings(); + hystrixBundle.initialize(bootstrap); + hystrixBundle.run(configuration, environment); + assertNotNull(environment.getAdminContext() + .getServletContext() + .getServletRegistration(HystrixBundle.SERVLET_NAME)); + assertNull(environment.getApplicationContext() + .getServletContext() + .getServletRegistration(HystrixBundle.SERVLET_NAME)); + assertTrue(HystrixPlugins.getInstance().getMetricsPublisher() instanceof HystrixCodaHaleMetricsPublisher); + verifyZeroInteractions(bootstrap); + } + @Test public void testAddToApplicationContext() throws Exception { final HystrixBundle hystrixBundle = HystrixBundle.builder().withApplicationStreamPath(HystrixBundle.DEFAULT_STREAM_PATH).disableStreamServletInAdminContext().build();