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

Upgrade Spring UT/IT to use JUnit 5. #21670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cce47f6
* Upgrade Spring UT/IT to use JUnit 5.
ZhuXiaoBing-cn May 20, 2021
eeece84
Merge branch 'master' into Upgrade_Spring_UT/IT_to_use_JUnit_5
ZhuXiaoBing-cn May 20, 2021
4d80b64
* update pom.xml
ZhuXiaoBing-cn May 20, 2021
b923cca
* Modify according to check style.
ZhuXiaoBing-cn May 20, 2021
04dea61
* Modify pom.xml
ZhuXiaoBing-cn May 21, 2021
d323b3a
* Update the pom file and KeyVault integration test code logic.
ZhuXiaoBing-cn May 25, 2021
e35ee5e
* add test.
ZhuXiaoBing-cn May 26, 2021
3dc6cce
* Readd test.
ZhuXiaoBing-cn May 26, 2021
e4007a3
* Modify the name of the integration test environment variable.
ZhuXiaoBing-cn May 26, 2021
3a410b9
* Modify the name of the integration test environment variable.
ZhuXiaoBing-cn May 26, 2021
c54142a
* Modify according to check style.
ZhuXiaoBing-cn May 26, 2021
d30fa08
* Modify wait time.
ZhuXiaoBing-cn May 27, 2021
6f8ee45
* Modify wait time.
ZhuXiaoBing-cn May 27, 2021
fd91166
Merge branch 'master' into Upgrade_Spring_UT/IT_to_use_JUnit_5
ZhuXiaoBing-cn May 27, 2021
f06d71f
Merge branch 'master' into Upgrade_Spring_UT/IT_to_use_JUnit_5
ZhuXiaoBing-cn May 28, 2021
d596977
* Modify according to comments.
ZhuXiaoBing-cn May 28, 2021
c8d9d20
* Modify according to check style.
ZhuXiaoBing-cn May 28, 2021
230143b
Merge branch 'master' into Upgrade_Spring_UT/IT_to_use_JUnit_5
ZhuXiaoBing-cn May 31, 2021
6cba0e8
* Add check exception log.
ZhuXiaoBing-cn May 31, 2021
f73edf5
* Add check exception log.
ZhuXiaoBing-cn May 31, 2021
f887d93
* Modify dependent versions.
ZhuXiaoBing-cn May 31, 2021
abe48a0
* Modify according to check style.
ZhuXiaoBing-cn Jun 1, 2021
a9fb4b4
* Optimize import.
ZhuXiaoBing-cn Jun 1, 2021
2426187
* Modify AADAccessTokenGroupRolesExtractionTest.
ZhuXiaoBing-cn Jun 1, 2021
d36872d
* Modify AADAccessTokenGroupRolesExtractionTest.
ZhuXiaoBing-cn Jun 1, 2021
e02f697
Merge branch 'master' into Upgrade_Spring_UT/IT_to_use_JUnit_5
ZhuXiaoBing-cn Jun 1, 2021
300e26f
* Update AzureRedisAutoConfigurationTest format.
ZhuXiaoBing-cn Jun 1, 2021
828d30e
* Modify the AADAccessTokenGroupRolesExtractionTest.
ZhuXiaoBing-cn Jun 1, 2021
6d890bb
* Rebuilding the AADAccessTokenGroupRolesExtractionTest unit tests.
ZhuXiaoBing-cn Jun 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions sdk/spring/azure-identity-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,13 @@
<artifactId>azure-identity</artifactId>
<version>1.3.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
</dependency>

<!-- TEST-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-params;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.5.0</version> <!-- {x-version-update;org.springframework.boot:spring-boot-starter-test;external_dependency} -->
<scope>test</scope>
<version>4.13.2</version> <!-- {x-version-update;junit:junit;external_dependency} -->
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-api-mockito2;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
saragluna marked this conversation as resolved.
Show resolved Hide resolved
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-module-junit4;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-api-mockito2;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-module-junit4;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
saragluna marked this conversation as resolved.
Show resolved Hide resolved
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-api-mockito2;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-module-junit4;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@
</dependency>

-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
saragluna marked this conversation as resolved.
Show resolved Hide resolved
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-keyvault-certificates</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,10 @@
<version>3.6.0-beta.1</version> <!-- {x-version-update;com.azure.spring:azure-spring-boot-starter-servicebus-jms;current} -->
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- TEST-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

package com.azure.spring.sample.jms.queue;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import java.util.UUID;
Expand All @@ -21,20 +21,17 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ServiceBusJMSQueueApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusJMSQueueApplicationIT {

@Autowired
private MockMvc mvc;

@Rule
public OutputCaptureRule outputCaptureRule = new OutputCaptureRule();

@Test
public void testQueueSendAndReceiveMessage() throws Exception {
public void testQueueSendAndReceiveMessage(CapturedOutput capture) throws Exception {
final String message = UUID.randomUUID().toString();

mvc.perform(post("/queue?message=" + message)).andExpect(status().isOk())
Expand All @@ -45,7 +42,7 @@ public void testQueueSendAndReceiveMessage() throws Exception {
boolean messageReceived = false;

for (int i = 0; i < 100; i++) {
final String output = outputCaptureRule.toString();
final String output = capture.toString();
if (!messageReceived && output.contains(messageReceivedLog)) {
messageReceived = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,10 @@
<version>3.6.0-beta.1</version> <!-- {x-version-update;com.azure.spring:azure-spring-boot-starter-servicebus-jms;current} -->
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- TEST-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

package com.azure.spring.sample.jms.topic;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import java.util.UUID;
Expand All @@ -21,31 +22,28 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ServiceBusJMSTopicApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusJMSTopicApplicationIT {

@Autowired
private MockMvc mvc;

@Rule
public OutputCaptureRule outputCaptureRule = new OutputCaptureRule();

@Test
public void testTopicSendAndReceiveMessage() throws Exception {
public void testTopicSendAndReceiveMessage(CapturedOutput capture) throws Exception {
final String message = UUID.randomUUID().toString();

mvc.perform(post("/topic?message=" + message)).andExpect(status().isOk())
.andExpect(content().string(message));
.andExpect(content().string(message));

final String messageReceivedLog = String.format("Received message from topic: %s", message);

boolean messageReceived = false;

for (int i = 0; i < 100; i++) {
final String output = outputCaptureRule.toString();
final String output = capture.toString();
if (!messageReceived && output.contains(messageReceivedLog)) {
messageReceived = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-api-mockito2;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-module-junit4;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- TEST-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Loading