Skip to content

Commit

Permalink
Merge pull request #4782 from bigscoop/wiremock-upgrade
Browse files Browse the repository at this point in the history
[general] Wiremock upgrade
  • Loading branch information
timmolter authored Dec 1, 2023
2 parents 444a6d0 + f58fbcc commit 410506f
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 60 deletions.
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<version.slf4j>2.0.6</version.slf4j>
<version.crypto>5.0.0</version.crypto>
<version.java-jwt>4.4.0</version.java-jwt>
<version.wiremock>3.2.0</version.wiremock>

<skipIntegrationTests>true</skipIntegrationTests>
</properties>
Expand Down Expand Up @@ -320,9 +321,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.35.0</version>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${version.wiremock}</version>
<scope>test</scope>
</dependency>

Expand Down
6 changes: 4 additions & 2 deletions xchange-binance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.knowm.xchange.binance;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -8,7 +10,7 @@

public class AbstractResilienceTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

public static int READ_TIMEOUT_MS = 1000;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.knowm.xchange.binance;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
Expand All @@ -16,7 +17,7 @@

public class BinanceExchangeIntegration {
protected static BinanceExchange exchange;
@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

@BeforeClass
public static void beforeClass() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

Expand All @@ -21,7 +22,7 @@

public class AccountServiceTest {

@Rule public final WireMockRule wireMockRule = new WireMockRule();
@Rule public final WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

@Test(timeout = 2000)
public void withdrawSuccess() throws Exception {
Expand Down
5 changes: 3 additions & 2 deletions xchange-bittrex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.knowm.xchange.bittrex.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
Expand All @@ -10,7 +12,7 @@
/** @author walec51 */
public class BaseWiremockTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
public static final String WIREMOCK_FILES_PATH = "__files";

public Exchange createExchange() {
Expand Down
6 changes: 4 additions & 2 deletions xchange-blockchain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package org.knowm.xchange.blockchain.service;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.APPLICATION;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.CONTENT_TYPE;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.ClassRule;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.blockchain.BlockchainExchange;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.APPLICATION;
import static org.knowm.xchange.blockchain.service.utils.BlockchainConstants.CONTENT_TYPE;

public class BlockchainBaseTest {

@ClassRule
public static WireMockRule wireMockRule = new WireMockRule();
public static WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

protected static BlockchainExchange createExchange() {
BlockchainExchange exchange =
Expand Down
5 changes: 3 additions & 2 deletions xchange-bybit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.knowm.xchange.bybit.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.io.IOException;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.bybit.BybitExchange;

import java.io.IOException;

public class BaseWiremockTest {

@Rule
public WireMockRule wireMockRule = new WireMockRule();
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

public Exchange createExchange() throws IOException {
Exchange exchange =
Expand Down
5 changes: 3 additions & 2 deletions xchange-coinbasepro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.knowm.xchange.coinbasepro.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
Expand All @@ -9,7 +11,7 @@

public class BaseWiremockTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
public static final String WIREMOCK_FILES_PATH = "__files";

public Exchange createExchange() {
Expand Down
6 changes: 3 additions & 3 deletions xchange-gateio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
6 changes: 4 additions & 2 deletions xchange-gemini/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
<artifactId>xchange-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.knowm.xchange.gemini.v1.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
Expand All @@ -9,7 +11,7 @@

public class BaseWiremockTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

public Exchange createExchange() {
Exchange exchange =
Expand Down
7 changes: 4 additions & 3 deletions xchange-kraken/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package org.knowm.xchange.kraken.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.google.common.collect.*;
import com.google.common.collect.ImmutableMap;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.kraken.*;
import org.knowm.xchange.kraken.dto.marketdata.*;
import org.knowm.xchange.kraken.KrakenExchange;
import org.knowm.xchange.kraken.KrakenUtils;
import org.knowm.xchange.kraken.dto.marketdata.KrakenAsset;
import org.knowm.xchange.kraken.dto.marketdata.KrakenAssetPair;

public class BaseWiremockTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

public Exchange createExchange() {
KrakenUtils.setKrakenAssets(ASSETS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
package org.knowm.xchange.krakenfutures;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import java.io.IOException;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.derivative.FuturesContract;
import org.knowm.xchange.dto.marketdata.*;
import org.knowm.xchange.dto.marketdata.FundingRate;
import org.knowm.xchange.dto.marketdata.FundingRates;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.dto.meta.InstrumentMetaData;
import org.knowm.xchange.instrument.Instrument;

import java.io.IOException;
import java.util.Map;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

public class KrakenFuturesPublicDataTest {

Exchange exchange = ExchangeFactory.INSTANCE.createExchange(KrakenFuturesExchange.class);
Instrument instrument = new FuturesContract("BTC/USD/PERP");

@Test
@Ignore
public void checkInstrumentsMetaData() {
Map<Instrument, InstrumentMetaData> instrumentInstrumentMetaDataMap = exchange.getExchangeMetaData().getInstruments();
System.out.println(instrumentInstrumentMetaDataMap.toString());
Expand Down Expand Up @@ -64,6 +69,7 @@ public void checkFundingRates() throws IOException {
}

@Test
@Ignore
public void checkFundingRate() throws IOException {
FundingRate fundingRate = exchange.getMarketDataService().getFundingRate(instrument);
assertThat(fundingRate.getInstrument().toString()).isEqualTo("PF_XBT/USD/PERP");
Expand Down
7 changes: 4 additions & 3 deletions xchange-livecoin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.knowm.xchange.livecoin.service;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Rule;
import org.knowm.xchange.Exchange;
Expand All @@ -10,7 +12,7 @@
/** @author walec51 */
public class BaseMockedIntegrationTest {

@Rule public WireMockRule wireMockRule = new WireMockRule();
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

public Exchange createExchange() {
Exchange exchange =
Expand Down
5 changes: 3 additions & 2 deletions xchange-mexc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Loading

0 comments on commit 410506f

Please sign in to comment.