-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash bug at startup when no
retryConfigurations
in config (#13)
- Loading branch information
Showing
11 changed files
with
311 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 0 additions & 198 deletions
198
src/test/java/com/homeaway/dropwizard/bundle/resilience4j/Resilience4jBundleTest.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/test/java/com/homeaway/dropwizard/bundle/resilience4j/ResourceTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.homeaway.dropwizard.bundle.resilience4j; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
import java.net.URL; | ||
|
||
import com.google.common.io.Resources; | ||
|
||
public class ResourceTestUtil { | ||
|
||
/** | ||
* Method to translate resource string into URL | ||
* | ||
* @param resourcePath path to a resource | ||
* @return URL for the resource | ||
*/ | ||
private static File resource(String resourcePath) { | ||
try { | ||
URL resource = Resources.getResource(ResourceTestUtil.class, resourcePath); | ||
URI uri = resource.toURI(); | ||
return new File(uri); | ||
} catch (Exception ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
|
||
public static String resourceAbsolutePath(String resourcePath) { | ||
return resource(resourcePath).getAbsolutePath(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/com/homeaway/dropwizard/bundle/resilience4j/TestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.homeaway.dropwizard.bundle.resilience4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import io.dropwizard.Application; | ||
import io.dropwizard.setup.Bootstrap; | ||
import io.dropwizard.setup.Environment; | ||
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; | ||
import io.github.resilience4j.retry.RetryConfig; | ||
|
||
public class TestApplication extends Application<TestConfiguration> { | ||
|
||
private List<Pair<String, CircuitBreakerConfig.Builder>> breakersSeenInConfiguration = new ArrayList<>(); | ||
|
||
private List<Pair<String, RetryConfig.Builder>> retryersSeenInConfiguration = new ArrayList<>(); | ||
|
||
@Override | ||
public void initialize(Bootstrap<TestConfiguration> bootstrap) { | ||
Resilience4jBundle<TestConfiguration> bundle = | ||
new Resilience4jBundle<>(TestConfiguration::getResilience4j, | ||
this::addBreakerConfigurationToTestList, | ||
this::addRetryConfigurationToTestList); | ||
|
||
bootstrap.addBundle(bundle); | ||
} | ||
|
||
@Override | ||
public void run(TestConfiguration configuration, Environment environment) { | ||
} | ||
|
||
private void addBreakerConfigurationToTestList(String key, CircuitBreakerConfig.Builder builder) { | ||
breakersSeenInConfiguration.add(Pair.of(key, builder)); | ||
} | ||
|
||
private void addRetryConfigurationToTestList(String key, RetryConfig.Builder builder) { | ||
retryersSeenInConfiguration.add(Pair.of(key, builder)); | ||
} | ||
|
||
public List<Pair<String, CircuitBreakerConfig.Builder>> getBreakersSeenInConfiguration() { | ||
return breakersSeenInConfiguration; | ||
} | ||
|
||
public List<Pair<String, RetryConfig.Builder>> getRetryersSeenInConfiguration() { | ||
return retryersSeenInConfiguration; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/java/com/homeaway/dropwizard/bundle/resilience4j/TestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.homeaway.dropwizard.bundle.resilience4j; | ||
|
||
import com.homeaway.dropwizard.bundle.resilience4j.configuration.Resilience4jConfiguration; | ||
|
||
import io.dropwizard.Configuration; | ||
|
||
public class TestConfiguration extends Configuration { | ||
|
||
private Resilience4jConfiguration resilience4j; | ||
|
||
public Resilience4jConfiguration getResilience4j() { | ||
return resilience4j; | ||
} | ||
} |
Oops, something went wrong.