Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build on jdk11 and jdk12. remove powermock and jmockit #3081

Merged
merged 10 commits into from
Aug 14, 2019
Merged
28 changes: 4 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if(JavaVersion.current() != JavaVersion.VERSION_1_10){
// feel free to delete this if you know what you are doing
throw new GradleException("This build must be run with java 10. see docs/build.md")
}
buildscript {
repositories {
jcenter()
Expand Down Expand Up @@ -34,14 +30,12 @@ configure(subprojects) {
bcVersion = '1.56'
codecVersion = '1.9'
easyVersion = '4.0.1'
jmockitVersion = '1.42'
joptVersion = '5.0.3'
langVersion = '3.4'
bitcoinjVersion = 'a88d36d'
logbackVersion = '1.1.10'
lombokVersion = '1.18.2'
mockitoVersion = '2.21.0'
powermockVersion = '2.0.0-beta.5'
mockitoVersion = '3.0.0'
protobufVersion = '3.5.1'
slf4jVersion = '1.7.22'
sparkVersion = '2.5.2'
Expand Down Expand Up @@ -212,9 +206,10 @@ configure(project(':p2p')) {
compile 'org.fxmisc.easybind:easybind:1.0.3'
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompile 'org.jmockit:jmockit:1.30' // must not use current $jmockitVersion
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompile("org.mockito:mockito-core:$mockitoVersion")

}
}

Expand Down Expand Up @@ -249,12 +244,7 @@ configure(project(':core')) {
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"

testCompile "org.jmockit:jmockit:$jmockitVersion"
testCompile("org.mockito:mockito-core:$mockitoVersion") {
exclude(module: 'objenesis')
}
testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
testCompile "org.powermock:powermock-api-mockito2:$powermockVersion"
testCompile("org.mockito:mockito-core:$mockitoVersion")
testCompile "org.springframework:spring-test:$springVersion"
testCompile "com.natpryce:make-it-easy:$easyVersion"
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
Expand All @@ -264,9 +254,6 @@ configure(project(':core')) {

test {
systemProperty 'jdk.attach.allowAttachSelf', true

def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath
jvmArgs "-javaagent:$jmockit"
}
}

Expand Down Expand Up @@ -307,12 +294,8 @@ configure(project(':desktop')) {
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"

testCompile "org.jmockit:jmockit:$jmockitVersion"
testCompile("org.mockito:mockito-core:$mockitoVersion") {
exclude(module: 'objenesis')
}
testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
testCompile "org.powermock:powermock-api-mockito2:$powermockVersion"
testCompile "org.springframework:spring-test:$springVersion"
testCompile "com.natpryce:make-it-easy:$easyVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
Expand All @@ -321,9 +304,6 @@ configure(project(':desktop')) {

test {
systemProperty 'jdk.attach.allowAttachSelf', true

def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath
jvmArgs "-javaagent:$jmockit"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@

import bisq.network.p2p.NodeAddress;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.security.Security;

import java.util.ArrayList;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
Expand All @@ -42,9 +32,6 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

@RunWith(PowerMockRunner.class)
@PrepareForTest({User.class, ArbitratorService.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ArbitratorManagerTest {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

import java.util.List;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;

import org.junit.Ignore;
import org.junit.Test;

Expand All @@ -36,8 +33,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@PrepareForTest(BtcWalletService.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class TxFeeEstimationServiceTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@

import java.util.List;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.btc.nodes.BtcNodes.BitcoinNodesOption.CUSTOM;
import static bisq.core.btc.nodes.BtcNodes.BitcoinNodesOption.PUBLIC;
Expand All @@ -36,9 +31,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest(Preferences.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class BtcNodesSetupPreferencesTest {
@Test
public void testSelectPreferredNodesWhenPublicOption() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest({PeriodService.class, ProposalPayload.class, ProposalValidatorProvider.class})
public class BallotListServiceTest {
@Test
@SuppressWarnings("unchecked")
Expand Down
47 changes: 7 additions & 40 deletions core/src/test/java/bisq/core/dao/node/full/BlockParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,10 @@

package bisq.core.dao.node.full;

import bisq.core.dao.node.parser.BlockParser;
import bisq.core.dao.node.parser.TxParser;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.TxInput;
import bisq.core.dao.state.model.blockchain.TxOutputKey;

import bisq.common.proto.persistable.PersistenceProtoResolver;

import org.bitcoinj.core.Coin;

import com.neemre.btcdcli4j.core.domain.RawBlock;
import com.neemre.btcdcli4j.core.domain.RawTransaction;

import com.google.common.collect.ImmutableList;

import java.io.File;

import java.math.BigDecimal;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import mockit.Expectations;
import mockit.Injectable;
import mockit.Tested;

import org.junit.Ignore;
import org.junit.Test;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


// not converting this test because it is already ignored.
// Intro to jmockit can be found at http://jmockit.github.io/tutorial/Mocking.html
@Ignore
//@Ignore
/*
public class BlockParserTest {
// @Tested classes are instantiated automatically when needed in a test case,
// using injection where possible, see http://jmockit.github.io/tutorial/Mocking.html#tested
Expand Down Expand Up @@ -213,7 +179,7 @@ public void testParseBlocks() {
});
*/

// Verify that the genesis tx has been added to the bsq blockchain with the correct issuance amount
// Verify that the genesis tx has been added to the bsq blockchain with the correct issuance amount
/* assertTrue(daoStateService.getGenesisTx().get() == genesisTx);
assertTrue(daoStateService.getGenesisTotalSupply().getValue() == issuance.getValue());

Expand All @@ -232,7 +198,8 @@ public void testParseBlocks() {
assertTrue(bsqOut2.getValue() == bsqTx1Value2);
assertFalse(daoStateService.isTxOutputSpendable(genesisTxId, 0));
assertTrue(daoStateService.isTxOutputSpendable(bsqTx1Id, 0));
assertTrue(daoStateService.isTxOutputSpendable(bsqTx1Id, 1));*/
assertTrue(daoStateService.isTxOutputSpendable(bsqTx1Id, 1));

}
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@
import bisq.core.dao.governance.period.CycleService;
import bisq.core.dao.monitoring.DaoStateMonitoringService;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.mockito.Mockito.mock;

@RunWith(PowerMockRunner.class)
@PrepareForTest({DaoStateService.class, GenesisTxInfo.class, CycleService.class, DaoStateStorageService.class, DaoStateMonitoringService.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class DaoStateSnapshotServiceTest {

private DaoStateSnapshotService daoStateSnapshotService;
Expand Down
8 changes: 0 additions & 8 deletions core/src/test/java/bisq/core/offer/OfferTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@

package bisq.core.offer;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest(OfferPayload.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class OfferTest {

@Test
Expand Down
8 changes: 0 additions & 8 deletions core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@

import java.util.concurrent.atomic.AtomicBoolean;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static bisq.core.offer.OfferMaker.btcUsdOffer;
import static com.natpryce.makeiteasy.MakeItEasy.make;
import static junit.framework.TestCase.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

@RunWith(PowerMockRunner.class)
@PrepareForTest({P2PService.class, PeerManager.class, OfferBookService.class, Storage.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class OpenOfferManagerTest {

@Test
Expand Down
8 changes: 0 additions & 8 deletions core/src/test/java/bisq/core/payment/PaymentAccountsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
import java.util.Set;
import java.util.function.BiFunction;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand All @@ -42,9 +37,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest({PaymentAccount.class, AccountAgeWitness.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class PaymentAccountsTest {
@Test
public void testGetOldestPaymentAccountForOfferWhenNoValidAccounts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@

import com.google.common.collect.Lists;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest({NationalBankAccount.class, SepaAccount.class, SepaInstantAccount.class, PaymentMethod.class, SameBankAccount.class, SpecificBanksAccount.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ReceiptPredicatesTest {
private final ReceiptPredicates predicates = new ReceiptPredicates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,15 @@
import bisq.core.offer.Offer;
import bisq.core.payment.payload.PaymentMethod;

import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest({SpecificBanksAccount.class, SameBankAccount.class, NationalBankAccount.class,
MoneyGramAccount.class, WesternUnionAccount.class, CashDepositAccount.class, PaymentMethod.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ReceiptValidatorTest {
private ReceiptValidator validator;
private PaymentAccount account;
Expand Down
Loading