Skip to content

Commit 93cdf2f

Browse files
authored
Merge pull request #126 from microsoftgraph/feature/junit-upgrade
feature/junit upgrade
2 parents ba6cf34 + 94da5ba commit 93cdf2f

39 files changed

Lines changed: 173 additions & 173 deletions

‎build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ java {
2222
}
2323

2424
test {
25+
useJUnitPlatform()
2526
finalizedBy jacocoTestReport // report is always generated after tests run
2627
}
2728
jacocoTestReport {

‎gradle/dependencies.gradle‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
dependencies {
22
// Use JUnit test framework
3-
testImplementation 'junit:junit:4.13.1'
4-
testImplementation 'org.mockito:mockito-inline:3.6.0'
3+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
4+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
5+
testImplementation 'org.mockito:mockito-inline:3.7.7'
56

67
api 'com.squareup.okhttp3:okhttp:4.9.0'
78

8-
implementation 'com.google.guava:guava:29.0-jre'
9+
implementation 'com.google.guava:guava:30.1-jre'
910

1011
implementation 'com.google.code.gson:gson:2.8.6'
11-
api 'com.azure:azure-identity:1.2.0'
12+
api 'com.azure:azure-identity:1.2.2'
1213
}

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>com.google.guava</groupId>
2222
<artifactId>guava</artifactId>
23-
<version>29.0-jre</version>
23+
<version>30.1-jre</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>com.squareup.okhttp3</groupId>

‎src/main/java/com/microsoft/graph/http/BaseStreamRequest.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import com.microsoft.graph.core.IBaseClient;
2727
import com.microsoft.graph.httpcore.middlewareoption.IShouldRedirect;
2828
import com.microsoft.graph.httpcore.middlewareoption.IShouldRetry;
29-
import com.microsoft.graph.httpcore.middlewareoption.RedirectOptions;
30-
import com.microsoft.graph.httpcore.middlewareoption.RetryOptions;
3129
import com.microsoft.graph.options.HeaderOption;
3230
import com.microsoft.graph.options.Option;
3331

‎src/test/java/com/microsoft/graph/authentication/BaseAuthenticationProviderTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.microsoft.graph.authentication;
22

3-
import static org.junit.Assert.assertFalse;
4-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
55

66
import java.net.MalformedURLException;
77
import java.net.URL;
88
import java.util.Arrays;
99
import java.util.HashSet;
1010
import java.util.concurrent.CompletableFuture;
1111

12-
import org.junit.Test;
12+
import org.junit.jupiter.api.Test;
1313

1414
public class BaseAuthenticationProviderTest {
1515
final BaseAuthenticationProvider authProvider = new BaseAuthenticationProvider() {

‎src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import com.azure.core.credential.TokenCredential;
44
import com.microsoft.graph.mocks.MockTokenCredential;
55

6-
import org.junit.Test;
6+
import org.junit.jupiter.api.Test;
77

8-
import static org.junit.Assert.*;
8+
import static org.junit.jupiter.api.Assertions.*;
99
import static org.mockito.Mockito.mock;
1010

1111
import java.net.MalformedURLException;
@@ -47,10 +47,10 @@ public void providerDoesntAddTokenOnInvalidHostName() throws MalformedURLExcepti
4747
}
4848
@Test
4949
public void providerDefensiveProgramming() {
50-
assertThrows("should throw on null credentials", NullPointerException.class, () -> { new TokenCredentialAuthProvider(null); });
51-
assertThrows("should throw on null scopes", IllegalArgumentException.class, () -> { new TokenCredentialAuthProvider(null, mock(TokenCredential.class)); });
52-
assertThrows("should throw on empty scopes", IllegalArgumentException.class, () -> { new TokenCredentialAuthProvider(new ArrayList<String>(), mock(TokenCredential.class)); });
50+
assertThrows(NullPointerException.class, () -> { new TokenCredentialAuthProvider(null); }, "should throw on null credentials");
51+
assertThrows(IllegalArgumentException.class, () -> { new TokenCredentialAuthProvider(null, mock(TokenCredential.class)); }, "should throw on null scopes");
52+
assertThrows(IllegalArgumentException.class, () -> { new TokenCredentialAuthProvider(new ArrayList<String>(), mock(TokenCredential.class)); }, "should throw on empty scopes");
5353
final TokenCredentialAuthProvider provider = new TokenCredentialAuthProvider(mock(TokenCredential.class));
54-
assertThrows("should throw on null url", NullPointerException.class, () -> { provider.getAuthorizationTokenAsync(null); });
54+
assertThrows(NullPointerException.class, () -> { provider.getAuthorizationTokenAsync(null); }, "should throw on null url");
5555
}
5656
}

‎src/test/java/com/microsoft/graph/content/MSBatchRequestContentTest.java‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.microsoft.graph.content;
22

3-
import static org.junit.Assert.assertFalse;
4-
import static org.junit.Assert.assertNotNull;
5-
import static org.junit.Assert.assertThrows;
6-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
77
import static org.mockito.ArgumentMatchers.any;
88
import static org.mockito.Mockito.mock;
99
import static org.mockito.Mockito.when;
@@ -19,7 +19,7 @@
1919
import com.microsoft.graph.logger.ILogger;
2020
import com.microsoft.graph.serializer.DefaultSerializer;
2121

22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323
import org.mockito.invocation.InvocationOnMock;
2424
import org.mockito.stubbing.Answer;
2525

@@ -110,35 +110,34 @@ public String answer(InvocationOnMock invocation) throws Throwable {
110110
}
111111
});
112112

113-
assertThrows("the number of steps cannot exceed 20", IllegalArgumentException.class, () -> {
113+
assertThrows(IllegalArgumentException.class, () -> {
114114
new MSBatchRequestContent(mock(ILogger.class), null, null, null, null, null, null, null, null, null, null, null, null, null,
115115
null, null, null, null, null, null, null, null, null);
116-
});
117-
assertThrows("the logger cannot be null", NullPointerException.class, () -> {
116+
}, "the number of steps cannot exceed 20");
117+
assertThrows(NullPointerException.class, () -> {
118118
new MSBatchRequestContent((ILogger) null, (MSBatchRequestStep)null);
119-
});
119+
}, "the logger cannot be null");
120120

121121
new MSBatchRequestContent(mockStep, null); // addind a null step doesn't throw
122-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
122+
assertThrows(NullPointerException.class, () -> {
123123
new MSBatchRequestContent().addBatchRequestStep(null);
124-
});
125-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
124+
}, "should throw argument exception");
125+
assertThrows(NullPointerException.class, () -> {
126126
new MSBatchRequestContent().addBatchRequestStep((Request) null);
127-
});
127+
}, "should throw argument exception");
128128

129-
assertThrows("the number of steps cannot exceed 20", IllegalArgumentException.class, () -> {
129+
assertThrows(IllegalArgumentException.class, () -> {
130130
final MSBatchRequestContent batchContent = new MSBatchRequestContent();
131131
for (int i = 0; i < MSBatchRequestContent.MAX_NUMBER_OF_REQUESTS; i++) {
132132
assertNotNull(batchContent.addBatchRequestStep(mock(Request.class)));
133133
}
134134
batchContent.addBatchRequestStep(mock(Request.class));
135-
});
135+
}, "the number of steps cannot exceed 20");
136136
{
137137
final MSBatchRequestContent batchContent = new MSBatchRequestContent();
138138
reservedIds.clear();
139139
for (int i = 0; i < MSBatchRequestContent.MAX_NUMBER_OF_REQUESTS; i++) {
140-
assertTrue("item number " + i + " should be added successfully",
141-
batchContent.addBatchRequestStep(mockStep));
140+
assertTrue(batchContent.addBatchRequestStep(mockStep), "item number " + i + " should be added successfully");
142141
}
143142
assertFalse(batchContent.addBatchRequestStep(mockStep));
144143
}

‎src/test/java/com/microsoft/graph/content/MSBatchRequestStepTest.java‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.microsoft.graph.content;
22

3-
import static org.junit.Assert.assertThrows;
4-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.jupiter.api.Assertions.assertThrows;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
55
import static org.mockito.Mockito.mock;
66

7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88

99
import okhttp3.Request;
1010

@@ -14,23 +14,23 @@ public class MSBatchRequestStepTest {
1414
public void testMSBatchRequestStepCreation() {
1515
Request request = new Request.Builder().url("http://graph.microsoft.com").build();
1616
MSBatchRequestStep requestStep = new MSBatchRequestStep("1", request);
17-
assertTrue("Test BatchRequestStep creation", requestStep != null);
18-
assertTrue("Test Request id", requestStep.getRequestId().compareTo("1") == 0);
19-
assertTrue("Test Request object", requestStep.getRequest() == request);
20-
assertTrue("Test Array of depends on Ids", requestStep.getDependsOnIds() != null);
17+
assertTrue(requestStep != null, "Test BatchRequestStep creation");
18+
assertTrue(requestStep.getRequestId().compareTo("1") == 0, "Test Request id");
19+
assertTrue(requestStep.getRequest() == request, "Test Request object");
20+
assertTrue(requestStep.getDependsOnIds() != null, "Test Array of depends on Ids");
2121
}
2222

2323
@Test
2424
public void defensiveProgrammingTests() {
25-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
25+
assertThrows(NullPointerException.class, () -> {
2626
new MSBatchRequestStep(null, null);
27-
});
28-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
27+
}, "should throw argument exception");
28+
assertThrows(NullPointerException.class, () -> {
2929
new MSBatchRequestStep("id", null);
30-
});
31-
assertThrows("should throw argument exception", IllegalArgumentException.class, () -> {
30+
}, "should throw argument exception");
31+
assertThrows(IllegalArgumentException.class, () -> {
3232
new MSBatchRequestStep("", null);
33-
});
33+
}, "should throw argument exception");
3434
new MSBatchRequestStep("id", mock(Request.class));
3535
}
3636

‎src/test/java/com/microsoft/graph/content/MSBatchResponseContentTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.microsoft.graph.content;
22

3-
import static org.junit.Assert.assertThrows;
4-
import static org.junit.Assert.assertTrue;
3+
import static org.junit.jupiter.api.Assertions.assertThrows;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
55

66
import java.io.IOException;
77
import java.util.Iterator;
88
import java.util.Map;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import okhttp3.MediaType;
1313
import okhttp3.Protocol;
@@ -20,9 +20,9 @@ public class MSBatchResponseContentTest {
2020

2121
@Test
2222
public void testNullMSBatchResponseContent() {
23-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
23+
assertThrows(NullPointerException.class, () -> {
2424
new MSBatchResponseContent((Response)null);
25-
});
25+
}, "should throw argument exception");
2626
}
2727

2828
@Test
@@ -45,9 +45,9 @@ public void testInvalidMSBatchResponseContentWithEmptyResponse() {
4545

4646
@Test
4747
public void testInvalidMSBatchResponseContentWithNullResponseString() {
48-
assertThrows("should throw argument exception", NullPointerException.class, () -> {
48+
assertThrows(NullPointerException.class, () -> {
4949
new MSBatchResponseContent(null);
50-
});
50+
}, "should throw argument exception");
5151
}
5252

5353
@Test

‎src/test/java/com/microsoft/graph/core/BaseClientTests.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import java.io.ObjectOutputStream;
1010
import java.io.OutputStream;
1111

12-
import static org.junit.Assert.assertEquals;
13-
import static org.junit.Assert.assertNotNull;
14-
import static org.junit.Assert.assertNull;
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import static org.junit.jupiter.api.Assertions.assertNotNull;
14+
import static org.junit.jupiter.api.Assertions.assertNull;
1515

16-
import org.junit.Before;
17-
import org.junit.Test;
16+
import org.junit.jupiter.api.BeforeEach;
17+
import org.junit.jupiter.api.Test;
1818

1919
import okhttp3.OkHttpClient;
2020
import okhttp3.Request;
@@ -40,7 +40,7 @@ public class BaseClientTests {
4040
private ILogger mLogger;
4141
private ISerializer mSerializer;
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() throws Exception {
4545
baseClient = new BaseClient();
4646
mLogger = mock(ILogger.class);

0 commit comments

Comments
 (0)