Replace ClassImposteriser with ByteBuddyClassImposteriser.

This may avoid problems with ClassImposteriser when using Java 11. See
https://github.com/jmock-developers/jmock-library/releases/tag/2.10.0
This commit is contained in:
akwizgran
2021-09-02 14:39:27 +01:00
parent 3ff7349b40
commit 7aa1073bf5
16 changed files with 24 additions and 26 deletions

View File

@@ -53,7 +53,7 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version" testImplementation "org.jmock:jmock-imposters:$jmock_version"
} }
def torBinariesDir = 'src/main/res/raw' def torBinariesDir = 'src/main/res/raw'

View File

@@ -9,7 +9,7 @@ import org.briarproject.bramble.api.db.DatabaseConfig;
import org.briarproject.bramble.api.identity.IdentityManager; import org.briarproject.bramble.api.identity.IdentityManager;
import org.briarproject.bramble.test.BrambleMockTestCase; import org.briarproject.bramble.test.BrambleMockTestCase;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -44,7 +44,7 @@ public class AndroidAccountManagerTest extends BrambleMockTestCase {
private AndroidAccountManager accountManager; private AndroidAccountManager accountManager;
public AndroidAccountManagerTest() { public AndroidAccountManagerTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
app = context.mock(Application.class); app = context.mock(Application.class);
applicationInfo = new ApplicationInfo(); applicationInfo = new ApplicationInfo();
applicationInfo.dataDir = testDir.getAbsolutePath(); applicationInfo.dataDir = testDir.getAbsolutePath();

View File

@@ -13,7 +13,6 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version"
signature 'org.codehaus.mojo.signature:java16:1.1@signature' signature 'org.codehaus.mojo.signature:java16:1.1@signature'
} }

View File

@@ -25,7 +25,7 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version" testImplementation "org.jmock:jmock-imposters:$jmock_version"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"

View File

@@ -13,7 +13,7 @@ import org.briarproject.bramble.api.sync.Message;
import org.briarproject.bramble.api.sync.MessageContext; import org.briarproject.bramble.api.sync.MessageContext;
import org.briarproject.bramble.test.ValidatorTestCase; import org.briarproject.bramble.test.ValidatorTestCase;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Test; import org.junit.Test;
import static org.briarproject.bramble.api.transport.TransportConstants.MAX_CLOCK_DIFFERENCE; import static org.briarproject.bramble.api.transport.TransportConstants.MAX_CLOCK_DIFFERENCE;
@@ -38,7 +38,7 @@ public class BdfMessageValidatorTest extends ValidatorTestCase {
private final Metadata meta = new Metadata(); private final Metadata meta = new Metadata();
public BdfMessageValidatorTest() { public BdfMessageValidatorTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
} }
@Test(expected = InvalidMessageException.class) @Test(expected = InvalidMessageException.class)

View File

@@ -11,9 +11,9 @@ import org.briarproject.bramble.api.keyagreement.PayloadEncoder;
import org.briarproject.bramble.test.BrambleTestCase; import org.briarproject.bramble.test.BrambleTestCase;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.auto.Mock; import org.jmock.auto.Mock;
import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.jmock.integration.junit4.JUnitRuleMockery; import org.jmock.integration.junit4.JUnitRuleMockery;
import org.jmock.lib.concurrent.Synchroniser; import org.jmock.lib.concurrent.Synchroniser;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@@ -35,7 +35,7 @@ public class KeyAgreementProtocolTest extends BrambleTestCase {
@Rule @Rule
public JUnitRuleMockery context = new JUnitRuleMockery() {{ public JUnitRuleMockery context = new JUnitRuleMockery() {{
// So we can mock concrete classes like KeyAgreementTransport // So we can mock concrete classes like KeyAgreementTransport
setImposteriser(ClassImposteriser.INSTANCE); setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
setThreadingPolicy(new Synchroniser()); setThreadingPolicy(new Synchroniser());
}}; }};

View File

@@ -14,7 +14,7 @@ import org.briarproject.bramble.api.record.RecordWriterFactory;
import org.briarproject.bramble.test.BrambleMockTestCase; import org.briarproject.bramble.test.BrambleMockTestCase;
import org.briarproject.bramble.test.CaptureArgumentAction; import org.briarproject.bramble.test.CaptureArgumentAction;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Test; import org.junit.Test;
import java.io.InputStream; import java.io.InputStream;
@@ -58,7 +58,7 @@ public class KeyAgreementTransportTest extends BrambleMockTestCase {
private KeyAgreementTransport kat; private KeyAgreementTransport kat;
public KeyAgreementTransportTest() { public KeyAgreementTransportTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
inputStream = context.mock(InputStream.class); inputStream = context.mock(InputStream.class);
outputStream = context.mock(OutputStream.class); outputStream = context.mock(OutputStream.class);
} }

View File

@@ -25,7 +25,7 @@ import org.briarproject.bramble.test.BrambleMockTestCase;
import org.briarproject.bramble.test.ImmediateExecutor; import org.briarproject.bramble.test.ImmediateExecutor;
import org.briarproject.bramble.test.RunAction; import org.briarproject.bramble.test.RunAction;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -69,7 +69,7 @@ public class PollerImplTest extends BrambleMockTestCase {
private PollerImpl poller; private PollerImpl poller;
public PollerImplTest() { public PollerImplTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
random = context.mock(SecureRandom.class); random = context.mock(SecureRandom.class);
} }

View File

@@ -27,7 +27,6 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
} }

View File

@@ -141,7 +141,7 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version" testImplementation "org.jmock:jmock-imposters:$jmock_version"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput') androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput')

View File

@@ -9,7 +9,7 @@ import org.briarproject.bramble.test.BrambleMockTestCase;
import org.briarproject.bramble.test.ImmediateExecutor; import org.briarproject.bramble.test.ImmediateExecutor;
import org.briarproject.briar.android.account.SetupViewModel.State; import org.briarproject.briar.android.account.SetupViewModel.State;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@@ -36,7 +36,7 @@ public class SetupViewModelTest extends BrambleMockTestCase {
private final DozeHelper dozeHelper; private final DozeHelper dozeHelper;
public SetupViewModelTest() { public SetupViewModelTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
app = context.mock(Application.class); app = context.mock(Application.class);
appContext = context.mock(Context.class); appContext = context.mock(Context.class);
accountManager = context.mock(AccountManager.class); accountManager = context.mock(AccountManager.class);

View File

@@ -11,7 +11,7 @@ import org.briarproject.briar.api.attachment.Attachment;
import org.briarproject.briar.api.attachment.AttachmentHeader; import org.briarproject.briar.api.attachment.AttachmentHeader;
import org.briarproject.briar.api.attachment.AttachmentReader; import org.briarproject.briar.api.attachment.AttachmentReader;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Test; import org.junit.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -36,7 +36,7 @@ public class AttachmentRetrieverTest extends BrambleMockTestCase {
private final AttachmentRetriever retriever; private final AttachmentRetriever retriever;
public AttachmentRetrieverTest() { public AttachmentRetrieverTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
AttachmentReader attachmentReader = AttachmentReader attachmentReader =
context.mock(AttachmentReader.class); context.mock(AttachmentReader.class);
imageSizeCalculator = context.mock(ImageSizeCalculator.class); imageSizeCalculator = context.mock(ImageSizeCalculator.class);

View File

@@ -26,7 +26,7 @@ import org.briarproject.briar.api.privategroup.event.GroupDissolvedEvent;
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationItem; import org.briarproject.briar.api.privategroup.invitation.GroupInvitationItem;
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager; import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@@ -95,7 +95,7 @@ public class GroupListViewModelTest extends BrambleMockTestCase {
new GroupItem(privateGroup2, authorInfo2, groupCount2, false); new GroupItem(privateGroup2, authorInfo2, groupCount2, false);
public GroupListViewModelTest() { public GroupListViewModelTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
Application app = context.mock(Application.class); Application app = context.mock(Application.class);
context.checking(new Expectations() {{ context.checking(new Expectations() {{
oneOf(eventBus).addListener(with(any(EventListener.class))); oneOf(eventBus).addListener(with(any(EventListener.class)));

View File

@@ -6,7 +6,7 @@ import android.content.res.Resources;
import org.briarproject.bramble.test.BrambleMockTestCase; import org.briarproject.bramble.test.BrambleMockTestCase;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Test; import org.junit.Test;
import static java.util.concurrent.TimeUnit.DAYS; import static java.util.concurrent.TimeUnit.DAYS;
@@ -24,7 +24,7 @@ public class UiUtilsFormatDurationTest extends BrambleMockTestCase {
private final int strDays = R.plurals.duration_days; private final int strDays = R.plurals.duration_days;
public UiUtilsFormatDurationTest() { public UiUtilsFormatDurationTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
ctx = context.mock(Context.class); ctx = context.mock(Context.class);
r = context.mock(Resources.class); r = context.mock(Resources.class);
} }

View File

@@ -25,7 +25,7 @@ dependencies {
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.jmock:jmock:$jmock_version" testImplementation "org.jmock:jmock:$jmock_version"
testImplementation "org.jmock:jmock-junit4:$jmock_version" testImplementation "org.jmock:jmock-junit4:$jmock_version"
testImplementation "org.jmock:jmock-legacy:$jmock_version" testImplementation "org.jmock:jmock-imposters:$jmock_version"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"

View File

@@ -34,7 +34,7 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse; import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse;
import org.jmock.AbstractExpectations; import org.jmock.AbstractExpectations;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.lib.legacy.ClassImposteriser; import org.jmock.imposters.ByteBuddyClassImposteriser;
import org.junit.Test; import org.junit.Test;
import java.util.Collection; import java.util.Collection;
@@ -122,7 +122,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
public GroupInvitationManagerImplTest() { public GroupInvitationManagerImplTest() {
context.setImposteriser(ClassImposteriser.INSTANCE); context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE);
creatorEngine = context.mock(CreatorProtocolEngine.class); creatorEngine = context.mock(CreatorProtocolEngine.class);
inviteeEngine = context.mock(InviteeProtocolEngine.class); inviteeEngine = context.mock(InviteeProtocolEngine.class);
peerEngine = context.mock(PeerProtocolEngine.class); peerEngine = context.mock(PeerProtocolEngine.class);