Skip to content

Commit

Permalink
[tests] Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hazendaz committed Dec 2, 2023
1 parent 9d5291c commit 08ec6f9
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 65 deletions.
2 changes: 1 addition & 1 deletion main/src/test/java/mockit/CascadingFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public void cascadingInstanceAccessedFromDelegateMethod() {
new Expectations() {
{
foo.getIntValue();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int delegate() {
return foo.getBar().doSomething();
Expand Down
1 change: 1 addition & 0 deletions main/src/test/java/mockit/CascadingParametersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public void recordAndVerifyExpectationsOnCascadedMocks(@Mocked Socket anySocket,
InetAddress adr1 = sk.getInetAddress();
InetAddress adr2 = sk.getLocalAddress();
assertNotSame(adr1, adr2);
sk.close();

new Verifications() {
{
Expand Down
2 changes: 1 addition & 1 deletion main/src/test/java/mockit/CascadingWithGenericsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ Outer<String>.Inner doSomething() {
*/
@Test
public void cascadeFromMethodReturningInnerInstanceOfGenericClass(@Mocked final Client mock) {
final Outer<?>.Inner innerInstance = new Outer().new Inner();
final Outer<?>.Inner innerInstance = new Outer<Object>().new Inner();

new Expectations() {
{
Expand Down
2 changes: 1 addition & 1 deletion main/src/test/java/mockit/ClassInitializationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,6 @@ public abstract static class AbstractImpl implements InterfaceWithStaticInitiali
*/
@Test // failed on JDK 9+ only
public void mockAbstractClassImplementingInterfaceWithStaticInitializer(@Mocked AbstractImpl mock2) {
assertEquals("test", mock2.CONSTANT);
assertEquals("test", InterfaceWithStaticInitializer.CONSTANT);
}
}
32 changes: 16 additions & 16 deletions main/src/test/java/mockit/DelegateInvocationProceedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void proceedFromDelegateMethodOnRegularMockedClass(@Mocked final ClassToB
new Expectations() {
{
mocked.methodToBeMocked();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
boolean delegate(Invocation inv) {
return inv.proceed();
Expand All @@ -174,7 +174,7 @@ public void proceedFromDelegateMethodOnInjectableMockedClass(@Injectable final C
new Expectations() {
{
mocked.methodToBeMocked();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
boolean delegate(Invocation inv) {
return inv.proceed();
Expand All @@ -199,7 +199,7 @@ public void proceedFromDelegateMethodWithParameters() throws Exception {
new Expectations(mocked) {
{
mocked.methodToBeMocked(anyInt);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int delegate(Invocation inv, int i) {
Integer j = inv.proceed();
Expand All @@ -209,7 +209,7 @@ int delegate(Invocation inv, int i) {

mocked.methodToBeMocked(anyInt, (Object[]) any);
maxTimes = 1;
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
Integer delegate(Invocation inv, int i, Object... args) {
args[2] = "mock";
Expand All @@ -234,7 +234,7 @@ public void proceedConditionallyFromDelegateMethod() {
new Expectations(mocked) {
{
mocked.anotherMethodToBeMocked(anyString, anyBoolean, null);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
String delegate(Invocation inv, String s, boolean b, List<Number> ints) {
if (!b) {
Expand Down Expand Up @@ -272,15 +272,15 @@ public void proceedFromDelegateMethodIntoRealMethodWithModifiedArguments() throw
new Expectations(mocked) {
{
mocked.methodToBeMocked(anyInt);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
Integer delegate1(Invocation invocation, int i) {
return invocation.proceed(i + 2);
}
};

mocked.methodToBeMocked(anyInt, (Object[]) any);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
Integer delegate2(Invocation inv, int i, Object... args) {
Object[] newArgs = { 2, "3" };
Expand All @@ -305,7 +305,7 @@ public void proceedFromDelegateMethodIntoConstructor(@Mocked ClassToBeMocked moc
new Expectations() {
{
new ClassToBeMocked();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void init(Invocation inv) {
assertNotNull(inv.getInvokedInstance());
Expand All @@ -330,7 +330,7 @@ public void proceedConditionallyFromDelegateMethodIntoConstructor(@Mocked ClassT
new Expectations() {
{
new ClassToBeMocked(anyString);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void init(Invocation inv, String name) {
assertNotNull(inv.getInvokedInstance());
Expand Down Expand Up @@ -358,15 +358,15 @@ public void proceedFromDelegateMethodIntoJREConstructor(@Mocked ProcessBuilder m
new Expectations() {
{
ProcessBuilder pb = new ProcessBuilder((String[]) any);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void init(Invocation inv) {
inv.proceed();
}
};

pb.command();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
List<String> delegate(Invocation inv) {
return inv.proceed();
Expand All @@ -392,7 +392,7 @@ public void proceedFromDelegateMethodIntoMethodInheritedFromBaseClass() {
new Expectations(obj) {
{
obj.baseMethod(anyInt);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int baseMethod(Invocation inv, int i) {
return inv.proceed(i + 1);
Expand All @@ -419,7 +419,7 @@ public void proceedFromDelegateMethodIntoOverridingMethodWhichCallsSuper(@Mocked
new Expectations() {
{
mocked.methodToBeMocked(1);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int delegate(Invocation inv) {
return inv.proceed();
Expand Down Expand Up @@ -448,7 +448,7 @@ public void proceedFromDelegateMethodIntoOverridingMethodThatCallsSuperWhichAlso
new Expectations() {
{
mockedBase.methodToBeMocked(1);
result = new Delegate() {
result = new Delegate<Object>() {
// Will not execute when calling on subclass instance.
@Mock
int delegate(Invocation inv) {
Expand All @@ -458,7 +458,7 @@ int delegate(Invocation inv) {
};

mocked.methodToBeMocked(1);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int delegate(Invocation inv) {
return inv.proceed();
Expand Down Expand Up @@ -488,7 +488,7 @@ public void throwExceptionFromProceedIntoJREMethod(@Injectable final AbstractExe
new Expectations() {
{
c1.submit((Runnable) any);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void delegate(Invocation inv) {
inv.proceed();
Expand Down
22 changes: 11 additions & 11 deletions main/src/test/java/mockit/DelegateInvocationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void delegateWithContextObject(@Mocked Collaborator unused) {
new Expectations() {
{
Collaborator.staticMethod();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
boolean staticMethod(Invocation context) {
assertNull(context.getInvokedInstance());
Expand Down Expand Up @@ -178,7 +178,7 @@ public void delegateReceivingNullArguments(@Mocked final Collaborator mock) {
new Expectations() {
{
mock.doSomething(true, null, null);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void doSomething(Invocation invocation, Boolean b, int[] i, String s) {
Collaborator instance = invocation.getInvokedInstance();
Expand Down Expand Up @@ -211,7 +211,7 @@ public void delegateWithAnotherMethodOnTheDelegateClass(@Mocked final Collaborat
new Expectations() {
{
mock.getValue();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
int getValue(Invocation context) {
return context.getInvocationCount();
Expand Down Expand Up @@ -240,7 +240,7 @@ public void delegateClassWithMultipleMethodsAndInexactButValidMatch(@Mocked Coll
new Expectations() {
{
Collaborator.staticMethod(1);
result = new Delegate() {
result = new Delegate<Object>() {
@SuppressWarnings("unused")
private void otherMethod(int i) {
fail();
Expand Down Expand Up @@ -268,7 +268,7 @@ public void delegateMethodWithNoParametersForExpectationWithParameters(@Mocked f
new Expectations() {
{
mock.publicMethod(true);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
long nonMatchingDelegate() {
return 123L;
Expand All @@ -291,7 +291,7 @@ public void delegateWithDifferentMethodName(@Mocked final Collaborator mock) {
new Expectations() {
{
mock.publicMethod(anyBoolean);
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
long differentName(Invocation invocation, boolean b) {
assertEquals(1, invocation.getInvocationCount());
Expand All @@ -317,18 +317,18 @@ public void consecutiveDelegatesForTheSameExpectation(@Mocked final Collaborator
new Expectations() {
{
mock.getValue();
returns(new Delegate() {
returns(new Delegate<Object>() {
@Mock
int delegate(Invocation invocation) {
assertSame(mock, invocation.getInvokedInstance());
return invocation.getInvocationCount();
}
}, new Delegate() {
}, new Delegate<Object>() {
@Mock
int delegate(Invocation invocation) {
return invocation.getInvocationCount();
}
}, new Delegate() {
}, new Delegate<Object>() {
@Mock
int delegate(Invocation invocation) {
assertEquals(3, invocation.getInvocationCount());
Expand Down Expand Up @@ -363,7 +363,7 @@ public void delegateMethodWithInvocationForInterface(@Mocked final Callable<Stri
new Expectations() {
{
mock.call();
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
String delegate(Invocation inv) {
return inv.getInvokedMember().getDeclaringClass().getName();
Expand Down Expand Up @@ -391,7 +391,7 @@ public void useOfContextParametersForJREMethods() throws Exception {
{
rt.exec(anyString, null);
maxTimes = 1;
result = new Delegate() {
result = new Delegate<Object>() {
@Mock
void exec(Invocation inv, String command, String[] envp) {
assertSame(rt, inv.getInvokedInstance());
Expand Down
Loading

0 comments on commit 08ec6f9

Please sign in to comment.