Skip to content

Commit

Permalink
Eliminate unnecessary use of GenericXmlApplicationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeams committed May 11, 2020
1 parent af5554f commit aee06a9
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import bisq.price.mining.FeeRate;
import bisq.price.mining.FeeRateProvider;

import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.web.client.RestClientException;

import java.time.Instant;
Expand All @@ -36,10 +37,11 @@
*/
public class MempoolFeeRateProviderTest {

private static final Environment env = new StandardEnvironment();

@Test
public void doGet_successfulCall() {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
MempoolFeeRateProvider feeRateProvider = new MempoolFeeRateProvider.First(ctx.getEnvironment());
MempoolFeeRateProvider feeRateProvider = new MempoolFeeRateProvider.First(env);

// Make a call to the API, retrieve the recommended fee rate
// If the API call fails, or the response body cannot be parsed, the test will
Expand All @@ -55,8 +57,7 @@ public void doGet_successfulCall() {
* Simulates a reachable provider, which successfully returns an API response
*/
public static FeeRateProvider buildDummyReachableMempoolFeeRateProvider(long feeRate) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
MempoolFeeRateProvider dummyProvider = new MempoolFeeRateProvider.First(ctx.getEnvironment()) {
MempoolFeeRateProvider dummyProvider = new MempoolFeeRateProvider.First(env) {
@Override
protected FeeRate doGet() {
return new FeeRate("BTC", feeRate, Instant.now().getEpochSecond());
Expand All @@ -76,8 +77,7 @@ protected FeeRate doGet() {
* timeout, connection cannot be established (expired certificate), etc.
*/
public static FeeRateProvider buildDummyUnreachableMempoolFeeRateProvider() throws RestClientException {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
MempoolFeeRateProvider dummyProvider = new MempoolFeeRateProvider.First(ctx.getEnvironment()) {
MempoolFeeRateProvider dummyProvider = new MempoolFeeRateProvider.First(env) {
@Override
protected FeeRate doGet() {
throw new RestClientException("Simulating connection error when trying to reach API endpoint");
Expand Down

0 comments on commit aee06a9

Please sign in to comment.