diff --git a/sdk/spring/azure-identity-spring/pom.xml b/sdk/spring/azure-identity-spring/pom.xml
index 5f2c71058d68f..2a6d39cb9f6ef 100644
--- a/sdk/spring/azure-identity-spring/pom.xml
+++ b/sdk/spring/azure-identity-spring/pom.xml
@@ -41,29 +41,13 @@
azure-identity
1.3.0
+
+
- org.junit.jupiter
- junit-jupiter-api
- 5.7.2
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- 5.7.2
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.2
- test
-
-
- junit
- junit
+ org.springframework.boot
+ spring-boot-starter-test
+ 2.5.0
test
- 4.13.2
diff --git a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-complete/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-complete/pom.xml
index b20f724d48bfa..e8265edb38985 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-complete/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-complete/pom.xml
@@ -45,36 +45,9 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-initial/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-initial/pom.xml
index 7fc087c3c189f..d367bafb9b3fe 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-initial/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-conversion-sample-initial/pom.xml
@@ -41,36 +41,9 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-sample/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-sample/pom.xml
index a3eaadd49f3ef..690564e040044 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-sample/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-appconfiguration-sample/pom.xml
@@ -38,36 +38,9 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-certificates-server-side/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-certificates-server-side/pom.xml
index 076ca691f01bb..25810e73cfa72 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-certificates-server-side/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-keyvault-certificates-server-side/pom.xml
@@ -84,17 +84,6 @@
-->
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
com.azure.spring
azure-spring-boot-starter-keyvault-certificates
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/pom.xml
index 4d3e7ea6be67c..e9cd55f30ecc1 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/pom.xml
@@ -41,24 +41,10 @@
3.6.0-beta.1
-
- junit
- junit
- test
-
+
org.springframework.boot
- spring-boot-test-autoconfigure
- test
-
-
- org.springframework
- spring-test
- test
-
-
- org.assertj
- assertj-core
+ spring-boot-starter-test
test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/src/test/java/com/azure/spring/sample/jms/queue/ServiceBusJMSQueueApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/src/test/java/com/azure/spring/sample/jms/queue/ServiceBusJMSQueueApplicationIT.java
index a6b2b8a19613f..45ab1b7980726 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/src/test/java/com/azure/spring/sample/jms/queue/ServiceBusJMSQueueApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue/src/test/java/com/azure/spring/sample/jms/queue/ServiceBusJMSQueueApplicationIT.java
@@ -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;
@@ -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())
@@ -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;
}
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/pom.xml
index 1b1bc3a8db710..bdcedb81baabc 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/pom.xml
@@ -41,24 +41,10 @@
3.6.0-beta.1
-
- junit
- junit
- test
-
+
org.springframework.boot
- spring-boot-test-autoconfigure
- test
-
-
- org.springframework
- spring-test
- test
-
-
- org.assertj
- assertj-core
+ spring-boot-starter-test
test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/src/test/java/com/azure/spring/sample/jms/topic/ServiceBusJMSTopicApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/src/test/java/com/azure/spring/sample/jms/topic/ServiceBusJMSTopicApplicationIT.java
index 574622d2eb537..2681996721356 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/src/test/java/com/azure/spring/sample/jms/topic/ServiceBusJMSTopicApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-topic/src/test/java/com/azure/spring/sample/jms/topic/ServiceBusJMSTopicApplicationIT.java
@@ -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;
@@ -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;
}
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/pom.xml
index 76341fc73b139..1ec43d3111278 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/pom.xml
@@ -45,32 +45,16 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
org.mockito
mockito-core
test
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/src/test/java/com/azure/spring/sample/cache/CacheApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/src/test/java/com/azure/spring/sample/cache/CacheApplicationIT.java
index 56015c0709022..22c4f780bd9de 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/src/test/java/com/azure/spring/sample/cache/CacheApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-cache/src/test/java/com/azure/spring/sample/cache/CacheApplicationIT.java
@@ -3,14 +3,14 @@
package com.azure.spring.sample.cache;
-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.http.MediaType;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import java.util.UUID;
@@ -19,11 +19,11 @@
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 = CacheApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(
locations = "classpath:application-test.properties")
+@ExtendWith({ MockitoExtension.class })
public class CacheApplicationIT {
@Autowired
@@ -35,7 +35,7 @@ public void testGetSuccess()
String key = "key" + UUID.randomUUID();
mvc.perform(get("/" + key)
.contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string("Hello " + key));
+ .andExpect(status().isOk())
+ .andExpect(content().string("Hello " + key));
}
}
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-binder/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-binder/pom.xml
index b97fd3f08766c..216478b1e2c65 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-binder/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-binder/pom.xml
@@ -54,49 +54,16 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
test
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.2
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-kafka/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-kafka/pom.xml
index 13c62686f68fb..7bdd5af8de0c3 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-kafka/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-kafka/pom.xml
@@ -54,49 +54,16 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
test
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.2
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/pom.xml
index 50c6aacedf0e5..1ca8393915442 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/pom.xml
@@ -46,32 +46,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/src/test/java/com/azure/spring/sample/eventhubs/multibinders/EventHubMultiBindersApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/src/test/java/com/azure/spring/sample/eventhubs/multibinders/EventHubMultiBindersApplicationIT.java
index 78e667a979c58..2c31088f06dc8 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/src/test/java/com/azure/spring/sample/eventhubs/multibinders/EventHubMultiBindersApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-multibinders/src/test/java/com/azure/spring/sample/eventhubs/multibinders/EventHubMultiBindersApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.eventhubs.multibinders;
-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;
@@ -21,23 +21,21 @@
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 = EventHubMultiBindersApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class EventHubMultiBindersApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
String messageReceivedLog = String.format("[1] New message received: '%s'", message);
String messageCheckpointedLog = String.format("[1] Message '%s' successfully checkpointed", message);
@@ -64,11 +62,11 @@ public void testSendAndReceiveMessage() throws Exception {
}
@Test
- public void testSendAndReceiveMessage_2() throws Exception {
+ public void testSendAndReceiveMessage_2(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages1?message=" + message)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
String messageReceivedLog = String.format("[2] New message received: '%s'", message);
String messageCheckpointedLog = String.format("[2] Message '%s' successfully checkpointed", message);
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/pom.xml
index e8a3aae8543d1..ba5a286c70bbb 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/src/test/java/com/azure/spring/sample/eventhubs/operation/EventHubOperationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/src/test/java/com/azure/spring/sample/eventhubs/operation/EventHubOperationApplicationIT.java
index 848c1ab950ac7..2cc8e1f4d1e64 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/src/test/java/com/azure/spring/sample/eventhubs/operation/EventHubOperationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-eventhubs-operation/src/test/java/com/azure/spring/sample/eventhubs/operation/EventHubOperationApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.eventhubs.operation;
-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;
@@ -21,19 +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 = EventHubOperationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class EventHubOperationApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-eventhubs/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-eventhubs/pom.xml
index 02c4542e24f69..896c6e967c2bd 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-eventhubs/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-eventhubs/pom.xml
@@ -49,37 +49,10 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-servicebus/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-servicebus/pom.xml
index 2da8a29b54d3f..e51329fa2bc87 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-servicebus/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-messaging-servicebus/pom.xml
@@ -36,37 +36,10 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/pom.xml
index c0f906e78f046..454c79f2f95df 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/src/test/java/com/azure/spring/sample/servicebus/operation/ServiceBusOperationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/src/test/java/com/azure/spring/sample/servicebus/operation/ServiceBusOperationApplicationIT.java
index 87c2c3895148f..8520a2f5fcc11 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/src/test/java/com/azure/spring/sample/servicebus/operation/ServiceBusOperationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-operation/src/test/java/com/azure/spring/sample/servicebus/operation/ServiceBusOperationApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.servicebus.operation;
-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;
@@ -21,34 +21,32 @@
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 = ServiceBusOperationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusOperationApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testQueueSendAndReceiveMessage() throws Exception {
- testSendAndReceiveMessage("queues");
+ public void testQueueSendAndReceiveMessage(CapturedOutput capture) throws Exception {
+ testSendAndReceiveMessage("queues", capture);
}
@Test
- public void testTopicSendAndReceiveMessage() throws Exception {
- testSendAndReceiveMessage("topics");
+ public void testTopicSendAndReceiveMessage(CapturedOutput capture) throws Exception {
+ testSendAndReceiveMessage("topics", capture);
}
- private void testSendAndReceiveMessage(String url) throws Exception {
+ private void testSendAndReceiveMessage(String url, CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
String urlTemplate = String.format("/%s?message=%s", url, message);
mvc.perform(post(urlTemplate)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
String messageReceivedLog = String.format("New message received: '%s'", message);
String messageCheckpointedLog = String.format("Message '%s' successfully checkpointed", message);
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/pom.xml
index 67e32c99f6a18..6c6d0f6d709f9 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/src/test/java/com/azure/spring/sample/servicebus/queue/binder/ServiceBusQueueBinderApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/src/test/java/com/azure/spring/sample/servicebus/queue/binder/ServiceBusQueueBinderApplicationIT.java
index f23b162a46a78..df69f0cc92985 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/src/test/java/com/azure/spring/sample/servicebus/queue/binder/ServiceBusQueueBinderApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-binder/src/test/java/com/azure/spring/sample/servicebus/queue/binder/ServiceBusQueueBinderApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.servicebus.queue.binder;
-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;
@@ -21,19 +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 = ServiceBusQueueBinderApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusQueueBinderApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/pom.xml
index 5135fdda17735..7fb06e4ecba87 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/src/test/java/com/azure/spring/sample/servicebus/queue/multibinders/ServiceBusQueueMultiBindersApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/src/test/java/com/azure/spring/sample/servicebus/queue/multibinders/ServiceBusQueueMultiBindersApplicationIT.java
index a7a336ba19c43..4f10e03bc4f03 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/src/test/java/com/azure/spring/sample/servicebus/queue/multibinders/ServiceBusQueueMultiBindersApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-queue-multibinders/src/test/java/com/azure/spring/sample/servicebus/queue/multibinders/ServiceBusQueueMultiBindersApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.servicebus.queue.multibinders;
-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;
@@ -21,19 +21,18 @@
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 = ServiceBusQueueMultiBindersApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusQueueMultiBindersApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
@@ -64,7 +63,7 @@ public void testSendAndReceiveMessage() throws Exception {
}
@Test
- public void testSendAndReceiveMessage_2() throws Exception {
+ public void testSendAndReceiveMessage_2(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages1?message=" + message)).andExpect(status().isOk())
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/pom.xml
index 35c7b8fd3c2d7..6de18cb00d458 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/src/test/java/com/azure/spring/sample/servicebus/topic/binder/ServiceBusTopicBinderApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/src/test/java/com/azure/spring/sample/servicebus/topic/binder/ServiceBusTopicBinderApplicationIT.java
index 75ac29d38cb00..3dbb2b4ebc162 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/src/test/java/com/azure/spring/sample/servicebus/topic/binder/ServiceBusTopicBinderApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-servicebus-topic-binder/src/test/java/com/azure/spring/sample/servicebus/topic/binder/ServiceBusTopicBinderApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.servicebus.topic.binder;
-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;
@@ -21,19 +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 = ServiceBusTopicBinderApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusTopicBinderApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/pom.xml
index 7654dd0c6b816..25d97a7816028 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/src/test/java/com/azure/spring/sample/storage/queue/operation/StorageQueueOperationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/src/test/java/com/azure/spring/sample/storage/queue/operation/StorageQueueOperationApplicationIT.java
index f3c023459e80c..ac89d08b43f18 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/src/test/java/com/azure/spring/sample/storage/queue/operation/StorageQueueOperationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-cloud-sample-storage-queue-operation/src/test/java/com/azure/spring/sample/storage/queue/operation/StorageQueueOperationApplicationIT.java
@@ -3,14 +3,14 @@
package com.azure.spring.sample.storage.queue.operation;
-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.http.MediaType;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import java.util.UUID;
@@ -20,10 +20,10 @@
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 = StorageQueueOperationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ MockitoExtension.class })
public class StorageQueueOperationApplicationIT {
@Autowired
@@ -34,13 +34,13 @@ public void testSendAndReceiveMessage() throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
Thread.sleep(1_000L);
mvc.perform(get("/messages")
.contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(status().isOk())
+ .andExpect(content().string(message));
}
}
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/pom.xml
index 742b6ef9939a4..74cb2908e99fd 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/src/test/java/com/azure/spring/sample/eventhubs/EventHubOperationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/src/test/java/com/azure/spring/sample/eventhubs/EventHubOperationApplicationIT.java
index 279d08c3e1398..2aae44471f5cd 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/src/test/java/com/azure/spring/sample/eventhubs/EventHubOperationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-eventhubs/src/test/java/com/azure/spring/sample/eventhubs/EventHubOperationApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.eventhubs;
-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;
@@ -21,19 +21,18 @@
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 = EventHubIntegrationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class EventHubOperationApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/pom.xml
index 10dbde49b77d8..722c114e48a86 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/pom.xml
@@ -45,32 +45,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/src/test/java/com/azure/spring/sample/servicebus/ServiceBusIntegrationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/src/test/java/com/azure/spring/sample/servicebus/ServiceBusIntegrationApplicationIT.java
index d9de40f6c8bd8..1adeac613d84e 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/src/test/java/com/azure/spring/sample/servicebus/ServiceBusIntegrationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-servicebus/src/test/java/com/azure/spring/sample/servicebus/ServiceBusIntegrationApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.servicebus;
-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;
@@ -21,34 +21,32 @@
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 = ServiceBusIntegrationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class ServiceBusIntegrationApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testQueueSendAndReceiveMessage() throws Exception {
- testSendAndReceiveMessage("queues");
+ public void testQueueSendAndReceiveMessage(CapturedOutput capture) throws Exception {
+ testSendAndReceiveMessage("queues", capture);
}
@Test
- public void testTopicSendAndReceiveMessage() throws Exception {
- testSendAndReceiveMessage("topics");
+ public void testTopicSendAndReceiveMessage(CapturedOutput capture) throws Exception {
+ testSendAndReceiveMessage("topics", capture);
}
- private void testSendAndReceiveMessage(String url) throws Exception {
+ private void testSendAndReceiveMessage(String url, CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
String urlTemplate = String.format("/%s?message=%s", url, message);
mvc.perform(post(urlTemplate)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
String messageReceivedLog = String.format("New message received: '%s'", message);
String messageCheckpointedLog = String.format("Message '%s' successfully checkpointed", message);
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/pom.xml
index c76fe0ca5ebb4..afce41995a0ce 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/pom.xml
@@ -49,32 +49,11 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/src/test/java/com/azure/spring/sample/storage/queue/StorageQueueIntegrationApplicationIT.java b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/src/test/java/com/azure/spring/sample/storage/queue/StorageQueueIntegrationApplicationIT.java
index 90627a46c3db4..7659cdab9d56d 100644
--- a/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/src/test/java/com/azure/spring/sample/storage/queue/StorageQueueIntegrationApplicationIT.java
+++ b/sdk/spring/azure-spring-boot-samples/azure-spring-integration-sample-storage-queue/src/test/java/com/azure/spring/sample/storage/queue/StorageQueueIntegrationApplicationIT.java
@@ -3,15 +3,15 @@
package com.azure.spring.sample.storage.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;
@@ -21,23 +21,21 @@
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 = StorageQueueIntegrationApplication.class)
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application-test.properties")
+@ExtendWith({ OutputCaptureExtension.class, MockitoExtension.class })
public class StorageQueueIntegrationApplicationIT {
- @Rule
- public OutputCaptureRule capture = new OutputCaptureRule();
@Autowired
private MockMvc mvc;
@Test
- public void testSendAndReceiveMessage() throws Exception {
+ public void testSendAndReceiveMessage(CapturedOutput capture) throws Exception {
String message = UUID.randomUUID().toString();
mvc.perform(post("/messages?message=" + message)).andExpect(status().isOk())
- .andExpect(content().string(message));
+ .andExpect(content().string(message));
String messageReceivedLog = String.format("New message received: '%s'", message);
String messageCheckpointedLog = String.format("Message '%s' successfully checkpointed", message);
diff --git a/sdk/spring/azure-spring-boot-samples/feature-management-sample/pom.xml b/sdk/spring/azure-spring-boot-samples/feature-management-sample/pom.xml
index 361ab9bc8e030..5d078edfe7d68 100644
--- a/sdk/spring/azure-spring-boot-samples/feature-management-sample/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/feature-management-sample/pom.xml
@@ -38,36 +38,9 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-samples/feature-management-web-sample/pom.xml b/sdk/spring/azure-spring-boot-samples/feature-management-web-sample/pom.xml
index 8b1c80fb8ee63..5853edd70d4e4 100644
--- a/sdk/spring/azure-spring-boot-samples/feature-management-web-sample/pom.xml
+++ b/sdk/spring/azure-spring-boot-samples/feature-management-web-sample/pom.xml
@@ -51,36 +51,9 @@
org.springframework.boot
spring-boot-starter-logging
-
- junit
- junit
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
org.hibernate.validator
hibernate-validator
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
diff --git a/sdk/spring/azure-spring-boot-starter-keyvault-certificates/pom.xml b/sdk/spring/azure-spring-boot-starter-keyvault-certificates/pom.xml
index 3b82cb8a43e70..dbf3a5120f8f4 100644
--- a/sdk/spring/azure-spring-boot-starter-keyvault-certificates/pom.xml
+++ b/sdk/spring/azure-spring-boot-starter-keyvault-certificates/pom.xml
@@ -46,6 +46,8 @@
2.5.0
true
+
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-test-aad-b2c/pom.xml b/sdk/spring/azure-spring-boot-test-aad-b2c/pom.xml
index 496df274b6308..786ad41940741 100644
--- a/sdk/spring/azure-spring-boot-test-aad-b2c/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-aad-b2c/pom.xml
@@ -52,6 +52,7 @@
1.0.0
test
+
ch.qos.logback
logback-core
@@ -64,13 +65,6 @@
ch.qos.logback
logback-classic
-
-
- junit
- junit
- 4.13.2
- test
-
\ No newline at end of file
diff --git a/sdk/spring/azure-spring-boot-test-aad/pom.xml b/sdk/spring/azure-spring-boot-test-aad/pom.xml
index 6395e861d8d90..745c0634f7673 100644
--- a/sdk/spring/azure-spring-boot-test-aad/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-aad/pom.xml
@@ -33,6 +33,7 @@
spring-boot-starter-oauth2-client
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-test-application/pom.xml b/sdk/spring/azure-spring-boot-test-application/pom.xml
index c1eb25fade0f1..690f22c153c57 100644
--- a/sdk/spring/azure-spring-boot-test-application/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-application/pom.xml
@@ -27,6 +27,7 @@
org.springframework.boot
spring-boot-starter-web
+
org.springframework.boot
spring-boot-starter-test
diff --git a/sdk/spring/azure-spring-boot-test-core/pom.xml b/sdk/spring/azure-spring-boot-test-core/pom.xml
index 40147c3055022..ff10e25363705 100644
--- a/sdk/spring/azure-spring-boot-test-core/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-core/pom.xml
@@ -80,12 +80,5 @@
spring-boot-starter-test
test
-
-
- junit
- junit
- 4.13.2
- test
-
diff --git a/sdk/spring/azure-spring-boot-test-core/src/main/java/com/azure/spring/test/EnvironmentVariable.java b/sdk/spring/azure-spring-boot-test-core/src/main/java/com/azure/spring/test/EnvironmentVariable.java
index 3c2217e498b58..b57f2929379a3 100644
--- a/sdk/spring/azure-spring-boot-test-core/src/main/java/com/azure/spring/test/EnvironmentVariable.java
+++ b/sdk/spring/azure-spring-boot-test-core/src/main/java/com/azure/spring/test/EnvironmentVariable.java
@@ -44,6 +44,7 @@ public class EnvironmentVariable {
public static final String SPRING_CLIENT_ID = System.getenv("SPRING_CLIENT_ID");
public static final String SPRING_CLIENT_SECRET = System.getenv("SPRING_CLIENT_SECRET");
public static final String SPRING_RESOURCE_GROUP = System.getenv("SPRING_RESOURCE_GROUP");
+ public static final String KEY_VAULT_SPRING_RESOURCE_GROUP = System.getenv("KEY_VAULT_SPRING_RESOURCE_GROUP");
public static final String SPRING_SUBSCRIPTION_ID = System.getenv("SPRING_SUBSCRIPTION_ID");
public static final String SPRING_TENANT_ID = System.getenv("SPRING_TENANT_ID");
public static final String SPRING_JMS_STANDARD_SERVICEBUS_CONNECTION_STRING = System.getenv("SPRING_JMS_STANDARD_SERVICEBUS_CONNECTION_STRING");
diff --git a/sdk/spring/azure-spring-boot-test-core/src/test/java/com/azure/spring/test/aad/ropc/AADOauth2ROPCGrantClientIT.java b/sdk/spring/azure-spring-boot-test-core/src/test/java/com/azure/spring/test/aad/ropc/AADOauth2ROPCGrantClientIT.java
index 8d520e97d7a9a..10923faf6dd8f 100644
--- a/sdk/spring/azure-spring-boot-test-core/src/test/java/com/azure/spring/test/aad/ropc/AADOauth2ROPCGrantClientIT.java
+++ b/sdk/spring/azure-spring-boot-test-core/src/test/java/com/azure/spring/test/aad/ropc/AADOauth2ROPCGrantClientIT.java
@@ -3,7 +3,7 @@
package com.azure.spring.test.aad.ropc;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.azure.spring.test.Constant.MULTI_TENANT_SCOPE_GRAPH_READ;
import static com.azure.spring.test.EnvironmentVariable.AAD_MULTI_TENANT_CLIENT_ID;
@@ -11,7 +11,7 @@
import static com.azure.spring.test.EnvironmentVariable.AAD_TENANT_ID_1;
import static com.azure.spring.test.EnvironmentVariable.AAD_USER_NAME_1;
import static com.azure.spring.test.EnvironmentVariable.AAD_USER_PASSWORD_1;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class AADOauth2ROPCGrantClientIT {
@@ -19,12 +19,12 @@ public class AADOauth2ROPCGrantClientIT {
public void getOAuth2ROPCResponseByROPCGrantTest() {
AADOauth2ROPCGrantClient.OAuth2ROPCResponse oAuth2ROPCResponse =
AADOauth2ROPCGrantClient.getOAuth2ROPCResponseByROPCGrant(
- AAD_TENANT_ID_1,
- AAD_MULTI_TENANT_CLIENT_ID,
- AAD_MULTI_TENANT_CLIENT_SECRET,
- AAD_USER_NAME_1,
- AAD_USER_PASSWORD_1,
- MULTI_TENANT_SCOPE_GRAPH_READ);
+ AAD_TENANT_ID_1,
+ AAD_MULTI_TENANT_CLIENT_ID,
+ AAD_MULTI_TENANT_CLIENT_SECRET,
+ AAD_USER_NAME_1,
+ AAD_USER_PASSWORD_1,
+ MULTI_TENANT_SCOPE_GRAPH_READ);
assertNotNull(oAuth2ROPCResponse);
}
}
diff --git a/sdk/spring/azure-spring-boot-test-cosmos/pom.xml b/sdk/spring/azure-spring-boot-test-cosmos/pom.xml
index 8df1fd7c63381..8db133663d8c4 100644
--- a/sdk/spring/azure-spring-boot-test-cosmos/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-cosmos/pom.xml
@@ -27,11 +27,6 @@
azure-spring-boot-test-core
1.0.0
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
org.springframework.boot
spring-boot-starter-actuator
@@ -44,11 +39,10 @@
io.projectreactor.netty
reactor-netty
-
+
- junit
- junit
- 4.13.2
+ org.springframework.boot
+ spring-boot-starter-test
test
diff --git a/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosActuatorIT.java b/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosActuatorIT.java
index ed5b5eec7415d..e17f80f515327 100644
--- a/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosActuatorIT.java
+++ b/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosActuatorIT.java
@@ -4,8 +4,8 @@
package com.azure.test.cosmos;
import com.azure.spring.test.AppRunner;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestTemplate;
public class CosmosActuatorIT {
@@ -31,7 +31,7 @@ public void testCosmosSpringBootActuatorHealth() {
final String response = REST_TEMPLATE.getForObject(
"http://localhost:" + app.port() + "/actuator/health/cosmos", String.class);
- Assert.assertTrue(response != null && response.contains("\"status\":\"UP\""));
+ Assertions.assertTrue(response != null && response.contains("\"status\":\"UP\""));
}
}
}
diff --git a/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosIT.java b/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosIT.java
index 6a7292aeae1e7..1f1eada24a57f 100644
--- a/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosIT.java
+++ b/sdk/spring/azure-spring-boot-test-cosmos/src/test/java/com/azure/test/cosmos/CosmosIT.java
@@ -5,9 +5,9 @@
import com.azure.spring.autoconfigure.aad.AADAuthenticationFilterAutoConfiguration;
import com.azure.spring.test.AppRunner;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Disabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -16,6 +16,8 @@
import java.util.Optional;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
public class CosmosIT {
private static final Logger LOGGER = LoggerFactory.getLogger(CosmosIT.class);
@@ -23,8 +25,8 @@ public class CosmosIT {
private static final String AZURE_COSMOS_ACCOUNT_KEY = System.getenv("AZURE_COSMOS_ACCOUNT_KEY");
private static final String AZURE_COSMOS_DATABASE_NAME = System.getenv("AZURE_COSMOS_DATABASE_NAME");
- @Test(expected = NoSuchBeanDefinitionException.class)
- @Ignore
+ @Disabled
+ @Test
public void testCosmosStarterIsolating() {
try (AppRunner app = new AppRunner(DummyApp.class)) {
//set properties
@@ -35,7 +37,8 @@ public void testCosmosStarterIsolating() {
//start app
app.start();
- app.getBean(AADAuthenticationFilterAutoConfiguration.class);
+ assertThrows(NoSuchBeanDefinitionException.class,
+ () -> app.getBean(AADAuthenticationFilterAutoConfiguration.class));
}
}
@@ -73,21 +76,22 @@ public void testCosmosOperation() {
// findById will not return the user as user is not present.
final Mono findByIdMono = repository.findById(testUser.getId());
final User findByIdUser = findByIdMono.block();
- Assert.assertNull("User must be null", findByIdUser);
+ Assertions.assertNull(findByIdUser, "User must be null");
final User savedUser = saveUserMono.block();
- Assert.assertNotNull("Saved user must not be null", savedUser);
- Assert.assertEquals("Saved user first name doesn't match",
- testUser.getFirstName(), savedUser.getFirstName());
+ Assertions.assertNotNull(savedUser, "Saved user must not be null");
+ Assertions.assertEquals(testUser.getFirstName(), savedUser.getFirstName(),
+ "Saved user first name doesn't match");
firstNameUserFlux.collectList().block();
final Optional optionalUserResult = repository.findById(testUser.getId()).blockOptional();
- Assert.assertTrue("Cannot find user.", optionalUserResult.isPresent());
+ Assertions.assertTrue(optionalUserResult.isPresent(), "Cannot find user.");
final User result = optionalUserResult.get();
- Assert.assertEquals("query result firstName doesn't match!",
- testUser.getFirstName(), result.getFirstName());
- Assert.assertEquals("query result lastName doesn't match!", testUser.getLastName(), result.getLastName());
+ Assertions.assertEquals(testUser.getFirstName(), result.getFirstName(),
+ "query result firstName doesn't match!");
+ Assertions.assertEquals(testUser.getLastName(), result.getLastName(),
+ "query result lastName doesn't match!");
LOGGER.info("findOne in User collection get result: {}", result.toString());
}
diff --git a/sdk/spring/azure-spring-boot-test-keyvault/pom-reactive.xml b/sdk/spring/azure-spring-boot-test-keyvault/pom-reactive.xml
index b918c999d9dae..5a6e42fa0ff1d 100644
--- a/sdk/spring/azure-spring-boot-test-keyvault/pom-reactive.xml
+++ b/sdk/spring/azure-spring-boot-test-keyvault/pom-reactive.xml
@@ -28,19 +28,9 @@
1.0.0
- com.microsoft.azure
- azure
- 1.34.0
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.google.code.gson
- gson
-
-
+ com.azure.resourcemanager
+ azure-resourcemanager
+ 2.5.0
org.springframework.boot
@@ -55,13 +45,6 @@
spring-boot-starter-test
test
-
-
- junit
- junit
- 4.13.2
- test
-
diff --git a/sdk/spring/azure-spring-boot-test-keyvault/pom.xml b/sdk/spring/azure-spring-boot-test-keyvault/pom.xml
index a3c006dd515ee..abecbb9e6d0d0 100644
--- a/sdk/spring/azure-spring-boot-test-keyvault/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-keyvault/pom.xml
@@ -28,19 +28,9 @@
1.0.0
- com.microsoft.azure
- azure
- 1.34.0
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.google.code.gson
- gson
-
-
+ com.azure.resourcemanager
+ azure-resourcemanager
+ 2.5.0
org.springframework.boot
@@ -55,13 +45,6 @@
spring-boot-starter-test
test
-
-
- junit
- junit
- 4.13.2
- test
-
diff --git a/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultActuatorIT.java b/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultActuatorIT.java
index 827d8b7732e93..7c92abfb6f984 100644
--- a/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultActuatorIT.java
+++ b/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultActuatorIT.java
@@ -4,7 +4,7 @@
import com.azure.spring.test.AppRunner;
import com.azure.spring.test.keyvault.app.DummyApp;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
diff --git a/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultSecretValueIT.java b/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultSecretValueIT.java
index 4ec69d2b51fa5..bcaa3ba2da078 100644
--- a/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultSecretValueIT.java
+++ b/sdk/spring/azure-spring-boot-test-keyvault/src/test/java/com/azure/spring/test/keyvault/KeyVaultSecretValueIT.java
@@ -3,34 +3,21 @@
package com.azure.spring.test.keyvault;
-import static com.azure.spring.test.EnvironmentVariable.AZURE_KEYVAULT_URI;
-import static com.azure.spring.test.EnvironmentVariable.KEY_VAULT_SECRET_NAME;
-import static com.azure.spring.test.EnvironmentVariable.KEY_VAULT_SECRET_VALUE;
-import static com.azure.spring.test.EnvironmentVariable.SPRING_CLIENT_ID;
-import static com.azure.spring.test.EnvironmentVariable.SPRING_CLIENT_SECRET;
-import static com.azure.spring.test.EnvironmentVariable.SPRING_RESOURCE_GROUP;
-import static com.azure.spring.test.EnvironmentVariable.SPRING_SUBSCRIPTION_ID;
-import static com.azure.spring.test.EnvironmentVariable.SPRING_TENANT_ID;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import com.azure.spring.test.keyvault.app.DummyApp;
-import com.microsoft.azure.AzureEnvironment;
-import com.microsoft.azure.credentials.ApplicationTokenCredentials;
-import com.microsoft.azure.credentials.AzureTokenCredentials;
-import com.microsoft.azure.management.Azure;
-import com.microsoft.azure.management.appservice.WebApp;
-import com.microsoft.azure.management.compute.RunCommandInput;
-import com.microsoft.azure.management.compute.VirtualMachine;
-import com.microsoft.azure.management.resources.fluentcore.utils.SdkContext;
+import com.azure.core.credential.TokenCredential;
+import com.azure.core.management.AzureEnvironment;
+import com.azure.core.management.profile.AzureProfile;
+import com.azure.identity.ClientSecretCredentialBuilder;
+import com.azure.resourcemanager.AzureResourceManager;
+import com.azure.resourcemanager.appservice.models.WebApp;
+import com.azure.resourcemanager.compute.models.RunCommandInput;
+import com.azure.resourcemanager.compute.models.VirtualMachine;
import com.azure.spring.test.AppRunner;
import com.azure.spring.test.MavenBasedProject;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.junit.Ignore;
-import org.junit.Test;
+import com.azure.spring.test.keyvault.app.DummyApp;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
@@ -41,6 +28,22 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import static com.azure.spring.test.EnvironmentVariable.AZURE_KEYVAULT_URI;
+import static com.azure.spring.test.EnvironmentVariable.KEY_VAULT_SECRET_NAME;
+import static com.azure.spring.test.EnvironmentVariable.KEY_VAULT_SECRET_VALUE;
+import static com.azure.spring.test.EnvironmentVariable.SPRING_CLIENT_ID;
+import static com.azure.spring.test.EnvironmentVariable.SPRING_CLIENT_SECRET;
+import static com.azure.spring.test.EnvironmentVariable.KEY_VAULT_SPRING_RESOURCE_GROUP;
+import static com.azure.spring.test.EnvironmentVariable.SPRING_SUBSCRIPTION_ID;
+import static com.azure.spring.test.EnvironmentVariable.SPRING_TENANT_ID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@TestMethodOrder(MethodOrderer.MethodName.class)
public class KeyVaultSecretValueIT {
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultSecretValueIT.class);
@@ -49,22 +52,23 @@ public class KeyVaultSecretValueIT {
private static final String VM_USER_USERNAME = System.getenv("VM_USER_USERNAME");
private static final String VM_USER_PASSWORD = System.getenv("VM_USER_PASSWORD");
private static final int DEFAULT_MAX_RETRY_TIMES = 3;
- private static final Azure AZURE;
+ private static final AzureResourceManager AZURE;
private static final RestTemplate REST_TEMPLATE = new RestTemplate();
static {
- AZURE = Azure.authenticate(credentials())
- .withSubscription(SPRING_SUBSCRIPTION_ID);
+ AzureProfile profile = new AzureProfile(SPRING_TENANT_ID, SPRING_SUBSCRIPTION_ID, AzureEnvironment.AZURE);
+ AZURE = AzureResourceManager.configure()
+ .authenticate(credentials(), profile)
+ .withDefaultSubscription();
}
-
- private static AzureTokenCredentials credentials() {
- return new ApplicationTokenCredentials(
- SPRING_CLIENT_ID,
- SPRING_TENANT_ID,
- SPRING_CLIENT_SECRET,
- AzureEnvironment.AZURE);
+ private static TokenCredential credentials() {
+ return new ClientSecretCredentialBuilder()
+ .clientId(SPRING_CLIENT_ID)
+ .clientSecret(SPRING_CLIENT_SECRET)
+ .tenantId(SPRING_TENANT_ID)
+ .build();
}
@Test
@@ -100,7 +104,7 @@ public void keyVaultAsPropertySourceWithSpecificKeys() {
app.property("azure.keyvault.client-key", SPRING_CLIENT_SECRET);
app.property("azure.keyvault.tenant-id", SPRING_TENANT_ID);
app.property("azure.keyvault.secret-keys", KEY_VAULT_SECRET_NAME);
- LOGGER.info("====" + KEY_VAULT_SECRET_NAME );
+ LOGGER.info("====" + KEY_VAULT_SECRET_NAME);
app.start();
assertEquals(KEY_VAULT_SECRET_VALUE, app.getProperty(KEY_VAULT_SECRET_NAME));
}
@@ -108,11 +112,11 @@ public void keyVaultAsPropertySourceWithSpecificKeys() {
}
@Test
- public void keyVaultWithAppServiceMSI() {
+ public void keyVaultWithAppServiceMSI() throws InterruptedException {
LOGGER.info("keyVaultWithAppServiceMSI begin.");
final WebApp webApp = AZURE
.webApps()
- .getByResourceGroup(SPRING_RESOURCE_GROUP, APP_SERVICE_NAME);
+ .getByResourceGroup(KEY_VAULT_SPRING_RESOURCE_GROUP, APP_SERVICE_NAME);
final MavenBasedProject app = new MavenBasedProject("../azure-spring-boot-test-application");
app.packageUp();
@@ -126,7 +130,7 @@ public void keyVaultWithAppServiceMSI() {
retryCount += 1;
try {
webApp.zipDeploy(zipFile);
- LOGGER.info(String.format("Deployed the artifact to https://%s", webApp.defaultHostName()));
+ LOGGER.info(String.format("Deployed the artifact to https://%s", webApp.defaultHostname()));
break;
} catch (Exception e) {
LOGGER.error(String.format("Exception occurred when deploying the zip package: %s, "
@@ -146,10 +150,10 @@ public void keyVaultWithAppServiceMSI() {
}
@Test
- @Ignore("Block live test, ignore temporarily")
- public void keyVaultWithVirtualMachineMSI() {
+ @Disabled("Block live test, ignore temporarily")
+ public void keyVaultWithVirtualMachineMSI() throws InterruptedException {
LOGGER.info("keyVaultWithVirtualMachineMSI begin.");
- final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(SPRING_RESOURCE_GROUP, VM_NAME);
+ final VirtualMachine vm = AZURE.virtualMachines().getByResourceGroup(KEY_VAULT_SPRING_RESOURCE_GROUP, VM_NAME);
final String host = vm.getPrimaryPublicIPAddress().ipAddress();
final List commands = new ArrayList<>();
commands.add(String.format("cd /home/%s", VM_USER_USERNAME));
@@ -187,15 +191,15 @@ public void keyVaultWithVirtualMachineMSI() {
}
private static ResponseEntity curlWithRetry(String resourceUrl,
- final int retryTimes,
- int sleepMills,
- Class clazz) {
+ final int retryTimes,
+ int sleepMills,
+ Class clazz) throws InterruptedException {
HttpStatus httpStatus = HttpStatus.BAD_REQUEST;
ResponseEntity response = ResponseEntity.of(Optional.empty());
int rt = retryTimes;
while (rt-- > 0 && httpStatus != HttpStatus.OK) {
- SdkContext.sleep(sleepMills);
+ Thread.sleep(sleepMills);
LOGGER.info("CURLing " + resourceUrl);
diff --git a/sdk/spring/azure-spring-boot-test-keyvault/test-resources.json b/sdk/spring/azure-spring-boot-test-keyvault/test-resources.json
index 8a93fb8c215c2..fbd9757de7da9 100644
--- a/sdk/spring/azure-spring-boot-test-keyvault/test-resources.json
+++ b/sdk/spring/azure-spring-boot-test-keyvault/test-resources.json
@@ -334,7 +334,7 @@
"type": "string",
"value": "[parameters('testApplicationSecret')]"
},
- "SPRING_RESOURCE_GROUP": {
+ "KEY_VAULT_SPRING_RESOURCE_GROUP": {
"type": "string",
"value": "[resourceGroup().name]"
},
diff --git a/sdk/spring/azure-spring-boot-test-servicebus-jms/pom.xml b/sdk/spring/azure-spring-boot-test-servicebus-jms/pom.xml
index d8e85a16d0e5f..f32e28205ca1e 100644
--- a/sdk/spring/azure-spring-boot-test-servicebus-jms/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-servicebus-jms/pom.xml
@@ -21,17 +21,11 @@
azure-spring-boot-starter-servicebus-jms
3.6.0-beta.1
-
+
org.springframework.boot
spring-boot-starter-test
test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
com.azure.spring
diff --git a/sdk/spring/azure-spring-boot-test-storage/pom.xml b/sdk/spring/azure-spring-boot-test-storage/pom.xml
index ef255a9807729..982113be27174 100644
--- a/sdk/spring/azure-spring-boot-test-storage/pom.xml
+++ b/sdk/spring/azure-spring-boot-test-storage/pom.xml
@@ -22,17 +22,6 @@
azure-spring-boot-starter-storage
3.6.0-beta.1
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
com.azure.spring
azure-spring-boot-test-core
@@ -46,6 +35,12 @@
org.springframework.boot
spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
diff --git a/sdk/spring/azure-spring-boot/pom.xml b/sdk/spring/azure-spring-boot/pom.xml
index 008c5c66c4900..f2c1908bebec6 100644
--- a/sdk/spring/azure-spring-boot/pom.xml
+++ b/sdk/spring/azure-spring-boot/pom.xml
@@ -274,18 +274,6 @@
5.3.7
true
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.2
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
org.apache.httpcomponents
httpclient
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADJwtBearerTokenAuthenticationConverterTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADJwtBearerTokenAuthenticationConverterTest.java
index 54583e3763115..2d38b16f25838 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADJwtBearerTokenAuthenticationConverterTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADJwtBearerTokenAuthenticationConverterTest.java
@@ -3,8 +3,8 @@
package com.azure.spring.aad.webapi;
import net.minidev.json.JSONArray;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.oauth2.jwt.Jwt;
@@ -23,7 +23,7 @@ public class AADJwtBearerTokenAuthenticationConverterTest {
private Map headers = new HashMap<>();
private JSONArray jsonArray = new JSONArray().appendElement("User.read").appendElement("User.write");
- @Before
+ @BeforeEach
public void init() {
claims.put("iss", "fake-issuer");
claims.put("tid", "fake-tid");
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerClientConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerClientConfigurationTest.java
index 76aabb7ac9745..ae72c7d177d78 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerClientConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerClientConfigurationTest.java
@@ -4,7 +4,7 @@
package com.azure.spring.aad.webapi;
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -22,6 +22,7 @@
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AADResourceServerClientConfigurationTest {
@@ -51,7 +52,8 @@ public void testWithoutAnyPropertiesSet() {
@Test
public void testWithRequiredPropertiesSet() {
new WebApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(WebOAuth2ClientApp.class, AADResourceServerClientConfiguration.class))
+ .withConfiguration(AutoConfigurations.of(WebOAuth2ClientApp.class,
+ AADResourceServerClientConfiguration.class))
.withPropertyValues("azure.activedirectory.client-id=fake-client-id")
.run(context -> {
assertThat(context).hasSingleBean(AADAuthenticationProperties.class);
@@ -79,7 +81,8 @@ public void testNotExistOAuth2LoginAuthenticationFilter() {
@Test
public void testOnlyGraphClient() {
this.contextRunner
- .withConfiguration(AutoConfigurations.of(WebOAuth2ClientApp.class, AADResourceServerClientConfiguration.class))
+ .withConfiguration(AutoConfigurations.of(WebOAuth2ClientApp.class,
+ AADResourceServerClientConfiguration.class))
.withPropertyValues("azure.activedirectory.authorization-clients.graph.scopes="
+ "https://graph.microsoft.com/User.Read")
.run(context -> {
@@ -98,18 +101,18 @@ public void testOnlyGraphClient() {
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testGrantTypeIsAuthorizationCodeClient() {
this.contextRunner
.withUserConfiguration(AADResourceServerClientConfiguration.class)
.withPropertyValues("azure.activedirectory.authorization-clients.graph.authorization-grant-type="
+ "authorization_code")
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void clientWhichGrantTypeIsOboButOnDemandExceptionTest() {
this.contextRunner
.withUserConfiguration(AADResourceServerClientConfiguration.class)
@@ -117,7 +120,7 @@ public void clientWhichGrantTypeIsOboButOnDemandExceptionTest() {
+ "on-behalf-of")
.withPropertyValues("azure.activedirectory.authorization-clients.graph.on-demand = true")
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerConfigurationTest.java
index 9e23075e069b1..9d09beaaa8920 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/AADResourceServerConfigurationTest.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.aad.webapi;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtAudienceValidatorTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtAudienceValidatorTest.java
index 2ef08f90a6e67..4a1f837ff9e9d 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtAudienceValidatorTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtAudienceValidatorTest.java
@@ -3,19 +3,19 @@
package com.azure.spring.aad.webapi.validator;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
import com.azure.spring.autoconfigure.aad.AADTokenClaim;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
import org.springframework.security.oauth2.jwt.Jwt;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
public class AADJwtAudienceValidatorTest {
final AADAuthenticationProperties aadAuthenticationProperties = mock(AADAuthenticationProperties.class);
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtIssuerValidatorTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtIssuerValidatorTest.java
index a6b19e390b7b3..d44a58a113292 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtIssuerValidatorTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapi/validator/AADJwtIssuerValidatorTest.java
@@ -5,7 +5,7 @@
import com.azure.spring.aad.AADTrustedIssuerRepository;
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
import com.azure.spring.autoconfigure.aad.AADTokenClaim;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
import org.springframework.security.oauth2.jwt.Jwt;
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADAccessTokenGroupRolesExtractionTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADAccessTokenGroupRolesExtractionTest.java
index 509f7a5e6508c..76b58da9a1fba 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADAccessTokenGroupRolesExtractionTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADAccessTokenGroupRolesExtractionTest.java
@@ -3,8 +3,14 @@
package com.azure.spring.aad.webapp;
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import java.util.ArrayList;
@@ -13,39 +19,46 @@
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
+@ExtendWith(MockitoExtension.class)
public class AADAccessTokenGroupRolesExtractionTest {
- private AADAuthenticationProperties properties = spy(AADAuthenticationProperties.class);
- private OAuth2AccessToken accessToken = mock(OAuth2AccessToken.class);
+ @Mock
+ private OAuth2AccessToken accessToken;
+ @Mock
+ private GraphClient graphClient;
+
+ private AADAuthenticationProperties properties = new AADAuthenticationProperties();
private AADAuthenticationProperties.UserGroupProperties userGroup =
- mock(AADAuthenticationProperties.UserGroupProperties.class);
- private GraphClient graphClient = mock(GraphClient.class);
- private AADOAuth2UserService userService = new AADOAuth2UserService(properties, graphClient);
+ new AADAuthenticationProperties.UserGroupProperties();
+ private AADOAuth2UserService userService;
+ private AutoCloseable autoCloseable;
@BeforeEach
- private void setup() {
- Set groups = new HashSet<>();
- groups.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
- groups.add("6eddcc22-a24a-4459-b036-b9d9fc0f0bc7");
- groups.add("group1");
- groups.add("group2");
- when(properties.allowedGroupNamesConfigured()).thenReturn(true);
- when(properties.allowedGroupIdsConfigured()).thenReturn(true);
- when(properties.getUserGroup()).thenReturn(userGroup);
- when(properties.getGraphMembershipUri()).thenReturn("https://graph.microsoft.com/v1.0/me/memberOf");
- when(accessToken.getTokenValue()).thenReturn("fake-access-token");
- when(graphClient.getGroupsFromGraph(accessToken.getTokenValue())).thenReturn(groups);
+ public void setup() {
+ this.autoCloseable = MockitoAnnotations.openMocks(this);
+ properties.setUserGroup(userGroup);
+ properties.setGraphMembershipUri("https://graph.microsoft.com/v1.0/me/memberOf");
+ Mockito.lenient().when(accessToken.getTokenValue()).thenReturn("fake-access-token");
+ userService = new AADOAuth2UserService(properties, graphClient);
+ }
+
+ @AfterEach
+ public void close() throws Exception {
+ this.autoCloseable.close();
}
@Test
public void testGroupsName() {
- List allowedGroupNames = new ArrayList<>();
+ Set allowedGroupNames = new HashSet<>();
allowedGroupNames.add("group1");
- when(userGroup.getAllowedGroupNames()).thenReturn(allowedGroupNames);
+ allowedGroupNames.add("group2");
+ List customizeGroupName = new ArrayList<>();
+ customizeGroupName.add("group1");
+
+ Mockito.lenient().when(graphClient.getGroupsFromGraph(accessToken.getTokenValue()))
+ .thenReturn(allowedGroupNames);
+ userGroup.setAllowedGroupNames(customizeGroupName);
Set groupsName = userService.extractGroupRolesFromAccessToken(accessToken);
assertThat(groupsName).contains("ROLE_group1");
@@ -57,9 +70,14 @@ public void testGroupsName() {
public void testGroupsId() {
Set allowedGroupIds = new HashSet<>();
allowedGroupIds.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
- when(userGroup.getAllowedGroupIds()).thenReturn(allowedGroupIds);
+ List customizeGroupId = new ArrayList<>();
+ customizeGroupId.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ Mockito.lenient().when(graphClient.getGroupsFromGraph(accessToken.getTokenValue()))
+ .thenReturn(allowedGroupIds);
+ userGroup.setAllowedGroupIds(allowedGroupIds);
Set groupsName = userService.extractGroupRolesFromAccessToken(accessToken);
+
assertThat(groupsName).contains("ROLE_d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
assertThat(groupsName).doesNotContain("ROLE_d07c0bd6-4aab-45ac-b87c-23e8d00194abaaa");
assertThat(groupsName).hasSize(1);
@@ -67,12 +85,20 @@ public void testGroupsId() {
@Test
public void testGroupsNameAndGroupsId() {
- Set allowedGroupIds = new HashSet<>();
- allowedGroupIds.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
- when(userGroup.getAllowedGroupIds()).thenReturn(allowedGroupIds);
- List allowedGroupNames = new ArrayList<>();
- allowedGroupNames.add("group1");
- when(userGroup.getAllowedGroupNames()).thenReturn(allowedGroupNames);
+ Set allowedGroupIdsAndGroupNames = new HashSet<>();
+ allowedGroupIdsAndGroupNames.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ allowedGroupIdsAndGroupNames.add("group1");
+
+ Set customizeGroupIds = new HashSet<>();
+ customizeGroupIds.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ List customizeGroupName = new ArrayList<>();
+ customizeGroupName.add("group1");
+
+ userGroup.setAllowedGroupIds(customizeGroupIds);
+ userGroup.setAllowedGroupNames(customizeGroupName);
+
+ Mockito.lenient().when(graphClient.getGroupsFromGraph(accessToken.getTokenValue()))
+ .thenReturn(allowedGroupIdsAndGroupNames);
Set groupsName = userService.extractGroupRolesFromAccessToken(accessToken);
assertThat(groupsName).contains("ROLE_group1");
@@ -84,22 +110,47 @@ public void testGroupsNameAndGroupsId() {
@Test
public void testEnableFullList() {
- when(properties.getUserGroup().getEnableFullList()).thenReturn(true);
+ Set allowedGroupIdsAndGroupNames = new HashSet<>();
+ allowedGroupIdsAndGroupNames.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ allowedGroupIdsAndGroupNames.add("6eddcc22-a24a-4459-b036-b9d9fc0f0bc7");
+ allowedGroupIdsAndGroupNames.add("group1");
+ allowedGroupIdsAndGroupNames.add("group2");
+
+ Set customizeGroupIds = new HashSet<>();
+ customizeGroupIds.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ List customizeGroupName = new ArrayList<>();
+ customizeGroupName.add("group1");
+
+ userGroup.setAllowedGroupIds(customizeGroupIds);
+ userGroup.setAllowedGroupNames(customizeGroupName);
+ userGroup.setEnableFullList(true);
+
+ Mockito.lenient().when(graphClient.getGroupsFromGraph(accessToken.getTokenValue()))
+ .thenReturn(allowedGroupIdsAndGroupNames);
Set groupIds = userService.extractGroupRolesFromAccessToken(accessToken);
assertThat(groupIds).hasSize(4);
}
@Test
public void testDisableFullList() {
- when(properties.getUserGroup().getEnableFullList()).thenReturn(false);
+ Set allowedGroupIdsAndGroupNames = new HashSet<>();
+ allowedGroupIdsAndGroupNames.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
+ allowedGroupIdsAndGroupNames.add("6eddcc22-a24a-4459-b036-b9d9fc0f0bc7");
+ allowedGroupIdsAndGroupNames.add("group1");
+ allowedGroupIdsAndGroupNames.add("group2");
+
+ userGroup.setEnableFullList(false);
Set allowedGroupIds = new HashSet<>();
allowedGroupIds.add("d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
- when(userGroup.getAllowedGroupIds()).thenReturn(allowedGroupIds);
+ userGroup.setAllowedGroupIds(allowedGroupIds);
List allowedGroupNames = new ArrayList<>();
allowedGroupNames.add("group1");
- when(userGroup.getAllowedGroupNames()).thenReturn(allowedGroupNames);
+ userGroup.setAllowedGroupNames(allowedGroupNames);
+ Mockito.lenient().when(graphClient.getGroupsFromGraph(accessToken.getTokenValue()))
+ .thenReturn(allowedGroupIdsAndGroupNames);
Set groupsName = userService.extractGroupRolesFromAccessToken(accessToken);
+
assertThat(groupsName).contains("ROLE_group1");
assertThat(groupsName).doesNotContain("ROLE_group5");
assertThat(groupsName).contains("ROLE_d07c0bd6-4aab-45ac-b87c-23e8d00194ab");
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADIdTokenRolesExtractionTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADIdTokenRolesExtractionTest.java
index 4063587ff3a44..c92b882dd06cd 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADIdTokenRolesExtractionTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADIdTokenRolesExtractionTest.java
@@ -4,7 +4,7 @@
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
import net.minidev.json.JSONArray;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import java.util.Arrays;
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADWebAppConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADWebAppConfigurationTest.java
index 0eaf0a66ad0bc..6b4037d86dc75 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADWebAppConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/aad/webapp/AADWebAppConfigurationTest.java
@@ -5,7 +5,7 @@
import com.azure.spring.aad.AADAuthorizationServerEndpoints;
import com.azure.spring.autoconfigure.aad.AADAuthenticationProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserService;
@@ -22,6 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AADWebAppConfigurationTest {
@@ -148,12 +149,14 @@ public void clientWithClientCredentialsPermissions() {
ClientRegistration azure = repo.findByRegistrationId("azure");
ClientRegistration graph = repo.findByRegistrationId("graph");
- assertEquals(repo.findByRegistrationId("azure").getAuthorizationGrantType(), AuthorizationGrantType.AUTHORIZATION_CODE);
- assertEquals(repo.findByRegistrationId("graph").getAuthorizationGrantType(), AuthorizationGrantType.CLIENT_CREDENTIALS);
+ assertEquals(repo.findByRegistrationId("azure").getAuthorizationGrantType(),
+ AuthorizationGrantType.AUTHORIZATION_CODE);
+ assertEquals(repo.findByRegistrationId("graph").getAuthorizationGrantType(),
+ AuthorizationGrantType.CLIENT_CREDENTIALS);
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void webAppWithOboWithExceptionTest() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -161,11 +164,11 @@ public void webAppWithOboWithExceptionTest() {
"azure.activedirectory.authorization-clients.graph.authorizationGrantType = on-behalf-of"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void clientWhichIsNotAuthorizationCodeButOnDemandExceptionTest() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -174,7 +177,7 @@ public void clientWhichIsNotAuthorizationCodeButOnDemandExceptionTest() {
"azure.activedirectory.authorization-clients.graph.on-demand = true"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
@@ -247,8 +250,7 @@ public void customizeUri() {
public void defaultClientWithAuthzScope() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties().withPropertyValues(
- "azure.activedirectory.authorization-clients.azure.scopes = Calendars.Read"
- )
+ "azure.activedirectory.authorization-clients.azure.scopes = Calendars.Read")
.run(context -> {
AADWebAppClientRegistrationRepository clientRepo =
context.getBean(AADWebAppClientRegistrationRepository.class);
@@ -323,7 +325,7 @@ public void graphUriConfigurationTest() {
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void graphUriConfigurationWithExceptionTest() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -331,11 +333,11 @@ public void graphUriConfigurationWithExceptionTest() {
"azure.activedirectory.graph-membership-uri=https://microsoftgraph.chinacloudapi.cn/v1.0/me/memberOf"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsConfiguredTest1() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -344,11 +346,11 @@ public void multiTenantWithAllowedGroupsConfiguredTest1() {
"azure.activedirectory.user-group.allowed-groups=group1,group2"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsConfiguredTest2() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -357,11 +359,11 @@ public void multiTenantWithAllowedGroupsConfiguredTest2() {
"azure.activedirectory.user-group.allowed-groups=group1,group2"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsConfiguredTest3() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -370,11 +372,11 @@ public void multiTenantWithAllowedGroupsConfiguredTest3() {
"azure.activedirectory.user-group.allowed-groups=group1,group2"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsIdConfiguredTest1() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -384,11 +386,11 @@ public void multiTenantWithAllowedGroupsIdConfiguredTest1() {
+ "39087533-2593-4b5b-ad05-4a73a01ea6a9"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsIdConfiguredTest2() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -398,11 +400,11 @@ public void multiTenantWithAllowedGroupsIdConfiguredTest2() {
+ "39087533-2593-4b5b-ad05-4a73a01ea6a9"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsIdConfiguredTest3() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -412,11 +414,11 @@ public void multiTenantWithAllowedGroupsIdConfiguredTest3() {
+ "39087533-2593-4b5b-ad05-4a73a01ea6a9"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsIdConfiguredTest4() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -426,11 +428,11 @@ public void multiTenantWithAllowedGroupsIdConfiguredTest4() {
+ "39087533-2593-4b5b-ad05-4a73a01ea6a9"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void multiTenantWithAllowedGroupsConfiguredTest4() {
WebApplicationContextRunnerUtils
.getContextRunnerWithRequiredProperties()
@@ -439,7 +441,7 @@ public void multiTenantWithAllowedGroupsConfiguredTest4() {
"azure.activedirectory.user-group.allowed-groups=group1,group2"
)
.run(context -> {
- AADAuthenticationProperties properties = context.getBean(AADAuthenticationProperties.class);
+ assertThrows(IllegalStateException.class, () -> context.getBean(AADAuthenticationProperties.class));
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAppRoleAuthenticationFilterTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAppRoleAuthenticationFilterTest.java
index 9846822a6bda7..4af6307047502 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAppRoleAuthenticationFilterTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAppRoleAuthenticationFilterTest.java
@@ -14,7 +14,7 @@
import com.nimbusds.jwt.proc.BadJWTException;
import net.minidev.json.JSONArray;
import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -33,12 +33,12 @@
import java.util.Collections;
import java.util.Set;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -96,19 +96,19 @@ public void testDoFilterGoodCase()
assertNotNull(context);
final Authentication authentication = context.getAuthentication();
assertNotNull(authentication);
- assertTrue("User should be authenticated!", authentication.isAuthenticated());
+ assertTrue(authentication.isAuthenticated(), "User should be authenticated!");
assertEquals(dummyPrincipal, authentication.getPrincipal());
- @SuppressWarnings("unchecked")
- final Collection authorities = (Collection) authentication
- .getAuthorities();
+ @SuppressWarnings("unchecked") final Collection authorities =
+ (Collection) authentication
+ .getAuthorities();
Assertions.assertThat(authorities).containsExactlyInAnyOrder(roleAdmin, roleUser);
};
filter.doFilterInternal(request, response, filterChain);
verify(userPrincipalManager).buildUserPrincipal(TOKEN);
- assertNull("Authentication has not been cleaned up!", SecurityContextHolder.getContext().getAuthentication());
+ assertNull(SecurityContextHolder.getContext().getAuthentication(), "Authentication has not been cleaned up!");
}
@Test
@@ -139,19 +139,19 @@ public void testDoFilterAddsDefaultRole()
assertNotNull(context);
final Authentication authentication = context.getAuthentication();
assertNotNull(authentication);
- assertTrue("User should be authenticated!", authentication.isAuthenticated());
+ assertTrue(authentication.isAuthenticated(), "User should be authenticated!");
final SimpleGrantedAuthority expectedDefaultRole = new SimpleGrantedAuthority("ROLE_USER");
- @SuppressWarnings("unchecked")
- final Collection authorities = (Collection) authentication
- .getAuthorities();
+ @SuppressWarnings("unchecked") final Collection authorities =
+ (Collection) authentication
+ .getAuthorities();
Assertions.assertThat(authorities).containsExactlyInAnyOrder(expectedDefaultRole);
};
filter.doFilterInternal(request, response, filterChain);
verify(userPrincipalManager).buildUserPrincipal(TOKEN);
- assertNull("Authentication has not been cleaned up!", SecurityContextHolder.getContext().getAuthentication());
+ assertNull(SecurityContextHolder.getContext().getAuthentication(), "Authentication has not been cleaned up!");
}
@Test
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterPropertiesTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterPropertiesTest.java
index a773f8e4ab48b..99cfca307ff3d 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterPropertiesTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterPropertiesTest.java
@@ -3,9 +3,9 @@
package com.azure.spring.autoconfigure.aad;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.context.properties.ConfigurationPropertiesBindException;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.bind.validation.BindValidationException;
@@ -21,7 +21,8 @@
import static org.assertj.core.api.Assertions.assertThat;
public class AADAuthenticationFilterPropertiesTest {
- @After
+
+ @AfterEach
public void clearAllProperties() {
System.clearProperty("azure.activedirectory.environment");
System.clearProperty("azure.activedirectory.tenant-id");
@@ -43,7 +44,7 @@ public void canSetProperties() {
assertThat(properties.getClientId()).isEqualTo(TestConstants.CLIENT_ID);
assertThat(properties.getClientSecret()).isEqualTo(TestConstants.CLIENT_SECRET);
assertThat(properties.getActiveDirectoryGroups()
- .toString()).isEqualTo(TestConstants.TARGETED_GROUPS.toString());
+ .toString()).isEqualTo(TestConstants.TARGETED_GROUPS.toString());
}
}
@@ -56,8 +57,9 @@ private void configureAllRequiredProperties() {
System.setProperty("azure.activedirectory.allow-telemetry", "false");
}
+ @Disabled
@Test
- @Ignore // TODO (wepa) clientId and clientSecret can also be configured in oauth2 config, test to be refactored
+ //TODO (wepa) clientId and clientSecret can also be configured in oauth2 config, test to be refactored
public void emptySettingsNotAllowed() {
System.setProperty("azure.activedirectory.client-id", "");
System.setProperty("azure.activedirectory.client-secret", "");
@@ -82,10 +84,10 @@ public void emptySettingsNotAllowed() {
final List errorStrings = errors.stream().map(ObjectError::toString).collect(Collectors.toList());
final List errorStringsExpected = Arrays.asList(
- "Field error in object 'azure.activedirectory' on field 'activeDirectoryGroups': "
- + "rejected value [null];",
- "Field error in object 'azure.activedirectory' on field 'clientId': rejected value [];",
- "Field error in object 'azure.activedirectory' on field 'clientSecret': rejected value [];"
+ "Field error in object 'azure.activedirectory' on field 'activeDirectoryGroups': "
+ + "rejected value [null];",
+ "Field error in object 'azure.activedirectory' on field 'clientId': rejected value [];",
+ "Field error in object 'azure.activedirectory' on field 'clientSecret': rejected value [];"
);
Collections.sort(errorStrings);
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterTest.java
index 9c07615e4c05d..65e2b0254c789 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AADAuthenticationFilterTest.java
@@ -6,8 +6,8 @@
import com.azure.spring.aad.AADAuthorizationServerEndpoints;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.proc.BadJOSEException;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.security.core.Authentication;
@@ -24,8 +24,8 @@
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -53,7 +53,7 @@ public AADAuthenticationFilterTest() {
//TODO (Zhou Liu): current test case is out of date, a new test case need to cover here, do it later.
@Test
- @Ignore
+ @Disabled
public void doFilterInternal() {
this.contextRunner.withPropertyValues("azure.activedirectory.client-id", TestConstants.CLIENT_ID)
.withPropertyValues("azure.activedirectory.client-secret", TestConstants.CLIENT_SECRET)
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AzureADGraphClientTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AzureADGraphClientTest.java
index 771aff271d29d..1e8622ae5be3f 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AzureADGraphClientTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/AzureADGraphClientTest.java
@@ -5,11 +5,9 @@
import com.azure.spring.aad.AADAuthorizationServerEndpoints;
import com.google.common.collect.ImmutableSet;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@@ -19,7 +17,6 @@
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(MockitoJUnitRunner.class)
public class AzureADGraphClientTest {
private AzureADGraphClient client;
@@ -27,7 +24,7 @@ public class AzureADGraphClientTest {
@Mock
private AADAuthorizationServerEndpoints endpoints;
- @Before
+ @BeforeEach
public void setup() {
final List activeDirectoryGroups = new ArrayList<>();
activeDirectoryGroups.add("Test_Group");
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/MembershipTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/MembershipTest.java
index 8c27525c463ec..beb39f840c2a9 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/MembershipTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/MembershipTest.java
@@ -3,36 +3,36 @@
package com.azure.spring.autoconfigure.aad;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class MembershipTest {
private static final Membership GROUP_1 = new Membership("12345", Membership.OBJECT_TYPE_GROUP, "test");
@Test
public void getDisplayName() {
- Assert.assertEquals("test", GROUP_1.getDisplayName());
+ Assertions.assertEquals("test", GROUP_1.getDisplayName());
}
@Test
public void getObjectType() {
- Assert.assertEquals(Membership.OBJECT_TYPE_GROUP, GROUP_1.getObjectType());
+ Assertions.assertEquals(Membership.OBJECT_TYPE_GROUP, GROUP_1.getObjectType());
}
@Test
public void getObjectID() {
- Assert.assertEquals("12345", GROUP_1.getObjectID());
+ Assertions.assertEquals("12345", GROUP_1.getObjectID());
}
@Test
public void equals() {
final Membership group2 = new Membership("12345", Membership.OBJECT_TYPE_GROUP, "test");
- Assert.assertEquals(GROUP_1, group2);
+ Assertions.assertEquals(GROUP_1, group2);
}
@Test
public void hashCodeTest() {
final Membership group2 = new Membership("12345", Membership.OBJECT_TYPE_GROUP, "test");
- Assert.assertEquals(GROUP_1.hashCode(), group2.hashCode());
+ Assertions.assertEquals(GROUP_1.hashCode(), group2.hashCode());
}
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/ResourceRetrieverTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/ResourceRetrieverTest.java
index a922045dad122..3763e5d25b555 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/ResourceRetrieverTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/ResourceRetrieverTest.java
@@ -6,7 +6,7 @@
import com.nimbusds.jose.jwk.source.RemoteJWKSet;
import com.nimbusds.jose.util.DefaultResourceRetriever;
import com.nimbusds.jose.util.ResourceRetriever;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalAzureADGraphTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalAzureADGraphTest.java
index 53b4bb1997e40..5d94f5803b854 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalAzureADGraphTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalAzureADGraphTest.java
@@ -6,9 +6,9 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jwt.JWTClaimsSet;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.util.StringUtils;
import java.io.File;
@@ -20,10 +20,27 @@
import java.nio.file.Files;
import java.text.ParseException;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class UserPrincipalAzureADGraphTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(9519);
+
+ private WireMockRule wireMockRule;
+
+ @BeforeEach
+ void setup() {
+ wireMockRule = new WireMockRule(9519);
+ wireMockRule.start();
+ }
+
+ @AfterEach
+ void close() {
+ if (wireMockRule.isRunning()) {
+ wireMockRule.stop();
+ }
+ }
@Test
public void userPrincipalIsSerializable() throws ParseException, IOException, ClassNotFoundException {
@@ -42,12 +59,10 @@ public void userPrincipalIsSerializable() throws ParseException, IOException, Cl
final UserPrincipal serializedPrincipal = (UserPrincipal) objectInputStream.readObject();
- Assert.assertNotNull("Serialized UserPrincipal not null", serializedPrincipal);
- Assert.assertFalse("Serialized UserPrincipal kid not empty",
- StringUtils.isEmpty(serializedPrincipal.getKid()));
- Assert.assertNotNull("Serialized UserPrincipal claims not null.", serializedPrincipal.getClaims());
- Assert.assertTrue("Serialized UserPrincipal claims not empty.",
- serializedPrincipal.getClaims().size() > 0);
+ assertNotNull(serializedPrincipal, "Serialized UserPrincipal not null");
+ assertFalse(StringUtils.isEmpty(serializedPrincipal.getKid()), "Serialized UserPrincipal kid not empty");
+ assertNotNull(serializedPrincipal.getClaims(), "Serialized UserPrincipal claims not null.");
+ assertTrue(serializedPrincipal.getClaims().size() > 0, "Serialized UserPrincipal claims not empty.");
} finally {
Files.deleteIfExists(tmpOutputFile.toPath());
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerAudienceTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerAudienceTest.java
index 1851c85489092..d2f843ac35216 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerAudienceTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerAudienceTest.java
@@ -15,8 +15,8 @@
import com.nimbusds.jose.util.ResourceRetriever;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -43,7 +43,7 @@ public class UserPrincipalManagerAudienceTest {
private AADAuthenticationProperties properties;
private UserPrincipalManager userPrincipalManager;
- @Before
+ @BeforeEach
public void setupKeys() throws NoSuchAlgorithmException {
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerTest.java
index d11d8cd3ab7ab..1e99814e621ad 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalManagerTest.java
@@ -8,32 +8,33 @@
import com.nimbusds.jose.jwk.source.ImmutableJWKSet;
import com.nimbusds.jose.proc.SecurityContext;
import com.nimbusds.jwt.proc.BadJWTException;
-import junitparams.FileParameters;
-import junitparams.JUnitParamsRunner;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-@RunWith(JUnitParamsRunner.class)
+
public class UserPrincipalManagerTest {
private static ImmutableJWKSet immutableJWKSet;
- @BeforeClass
+ @BeforeAll
public static void setupClass() throws Exception {
final X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509")
- .generateCertificate(Files.newInputStream(Paths.get("src/test/resources/test-public-key.txt")));
+ .generateCertificate(Files.newInputStream(Paths.get("src/test/resources/test-public-key.txt")));
immutableJWKSet = new ImmutableJWKSet<>(new JWKSet(JWK.parse(
- cert)));
+ cert)));
}
private UserPrincipalManager userPrincipalManager;
@@ -43,36 +44,43 @@ public static void setupClass() throws Exception {
public void testAlgIsTakenFromJWT() throws Exception {
userPrincipalManager = new UserPrincipalManager(immutableJWKSet);
final UserPrincipal userPrincipal = userPrincipalManager.buildUserPrincipal(
- new String(Files.readAllBytes(
- Paths.get("src/test/resources/jwt-signed.txt")), StandardCharsets.UTF_8));
+ new String(Files.readAllBytes(
+ Paths.get("src/test/resources/jwt-signed.txt")), StandardCharsets.UTF_8));
assertThat(userPrincipal).isNotNull().extracting(UserPrincipal::getIssuer, UserPrincipal::getSubject)
- .containsExactly("https://sts.windows.net/test", "test@example.com");
+ .containsExactly("https://sts.windows.net/test", "test@example.com");
}
@Test
public void invalidIssuer() {
userPrincipalManager = new UserPrincipalManager(immutableJWKSet);
- assertThatCode(() -> userPrincipalManager.buildUserPrincipal(
- new String(Files.readAllBytes(
- Paths.get("src/test/resources/jwt-bad-issuer.txt")), StandardCharsets.UTF_8)))
- .isInstanceOf(BadJWTException.class);
+ assertThatCode(() -> userPrincipalManager.buildUserPrincipal(readJwtValidIssuerTxt()))
+ .isInstanceOf(BadJWTException.class);
}
- @Test
//TODO: add more generated tokens with other valid issuers to this file. Didn't manage to generate them
- @FileParameters("src/test/resources/jwt-valid-issuer.txt")
+ @ParameterizedTest
+ @MethodSource("readJwtValidIssuerTxtStream")
public void validIssuer(final String token) {
userPrincipalManager = new UserPrincipalManager(immutableJWKSet);
assertThatCode(() -> userPrincipalManager.buildUserPrincipal(token))
- .doesNotThrowAnyException();
+ .doesNotThrowAnyException();
}
@Test
public void nullIssuer() {
userPrincipalManager = new UserPrincipalManager(immutableJWKSet);
- assertThatCode(() -> userPrincipalManager.buildUserPrincipal(
- new String(Files.readAllBytes(
- Paths.get("src/test/resources/jwt-null-issuer.txt")), StandardCharsets.UTF_8)))
- .isInstanceOf(BadJWTException.class);
+ assertThatCode(() -> userPrincipalManager.buildUserPrincipal(readJwtValidIssuerTxt()))
+ .isInstanceOf(BadJWTException.class);
+ }
+
+ private String readJwtValidIssuerTxt() throws IOException {
+ return new String(Files.readAllBytes(
+ Paths.get("src/test/resources/jwt-null-issuer.txt")), StandardCharsets.UTF_8);
}
+
+ private static Stream readJwtValidIssuerTxtStream() throws IOException {
+ return Stream.of(new String(Files.readAllBytes(
+ Paths.get("src/test/resources/jwt-valid-issuer.txt")), StandardCharsets.UTF_8));
+ }
+
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalMicrosoftGraphTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalMicrosoftGraphTest.java
index eed497fded4c5..ebe2c95768f31 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalMicrosoftGraphTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/aad/UserPrincipalMicrosoftGraphTest.java
@@ -9,10 +9,10 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jwt.JWTClaimsSet;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
import org.springframework.util.StringUtils;
import java.io.File;
@@ -37,14 +37,18 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.http.HttpHeaders.ACCEPT;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class UserPrincipalMicrosoftGraphTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(9519);
+
+ private WireMockRule wireMockRule;
private String clientId;
private String clientSecret;
@@ -65,17 +69,26 @@ public class UserPrincipalMicrosoftGraphTest {
e.printStackTrace();
userGroupsJson = null;
}
- Assert.assertNotNull(userGroupsJson);
+ assertNotNull(userGroupsJson);
}
- @Before
+ @BeforeAll
public void setup() {
accessToken = MicrosoftGraphConstants.BEARER_TOKEN;
properties = new AADAuthenticationProperties();
- properties.setGraphMembershipUri("http://localhost:9519/memberOf");
+ properties.setGraphMembershipUri("http://localhost:8080/memberOf");
endpoints = new AADAuthorizationServerEndpoints(properties.getBaseUri(), properties.getTenantId());
clientId = "client";
clientSecret = "pass";
+ wireMockRule = new WireMockRule(8080);
+ wireMockRule.start();
+ }
+
+ @AfterAll
+ public void close() {
+ if (wireMockRule.isRunning()) {
+ wireMockRule.shutdown();
+ }
}
@Test
@@ -83,7 +96,6 @@ public void getGroups() throws Exception {
properties.getUserGroup().setAllowedGroups(Arrays.asList("group1", "group2", "group3"));
AzureADGraphClient graphClientMock = new AzureADGraphClient(clientId, clientSecret, properties,
endpoints);
-
stubFor(get(urlEqualTo("/memberOf"))
.withHeader(ACCEPT, equalTo(APPLICATION_JSON_VALUE))
.willReturn(aResponse()
@@ -118,12 +130,10 @@ public void userPrincipalIsSerializable() throws ParseException, IOException, Cl
final UserPrincipal serializedPrincipal = (UserPrincipal) objectInputStream.readObject();
- Assert.assertNotNull("Serialized UserPrincipal not null", serializedPrincipal);
- Assert.assertFalse("Serialized UserPrincipal kid not empty",
- StringUtils.isEmpty(serializedPrincipal.getKid()));
- Assert.assertNotNull("Serialized UserPrincipal claims not null.", serializedPrincipal.getClaims());
- Assert.assertTrue("Serialized UserPrincipal claims not empty.",
- serializedPrincipal.getClaims().size() > 0);
+ assertNotNull(serializedPrincipal, "Serialized UserPrincipal not null");
+ assertFalse(StringUtils.isEmpty(serializedPrincipal.getKid()), "Serialized UserPrincipal kid not empty");
+ assertNotNull(serializedPrincipal.getClaims(), "Serialized UserPrincipal claims not null.");
+ assertTrue(serializedPrincipal.getClaims().size() > 0, "Serialized UserPrincipal claims not empty.");
} finally {
Files.deleteIfExists(tmpOutputFile.toPath());
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosAutoConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosAutoConfigurationTest.java
index fe06591cb9425..0d58e960e2896 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosAutoConfigurationTest.java
@@ -5,20 +5,20 @@
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.cosmos.implementation.ConnectionPolicy;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-@Ignore
+@Disabled
public class CosmosAutoConfigurationTest {
- @BeforeClass
+ @BeforeAll
public static void beforeClass() {
PropertySettingUtil.setProperties();
}
- @AfterClass
+ @AfterAll
public static void afterClass() {
PropertySettingUtil.unsetProperties();
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosPropertiesTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosPropertiesTest.java
index 45a496e502912..6b9f06dd1ddb9 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosPropertiesTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosPropertiesTest.java
@@ -3,7 +3,7 @@
package com.azure.spring.autoconfigure.cosmos;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.context.properties.ConfigurationPropertiesBindException;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.bind.validation.BindValidationException;
@@ -19,6 +19,7 @@
import static org.assertj.core.api.Assertions.assertThat;
public class CosmosPropertiesTest {
+
@Test
public void canSetAllProperties() {
PropertySettingUtil.setProperties();
@@ -77,9 +78,9 @@ public void emptySettingNotAllowed() {
Collections.sort(errorStrings);
final List errorStringsExpected = Arrays.asList(
- "Field error in object 'azure.cosmos' on field 'database': rejected value [null];",
- "Field error in object 'azure.cosmos' on field 'key': rejected value [null];",
- "Field error in object 'azure.cosmos' on field 'uri': rejected value [null];"
+ "Field error in object 'azure.cosmos' on field 'database': rejected value [null];",
+ "Field error in object 'azure.cosmos' on field 'key': rejected value [null];",
+ "Field error in object 'azure.cosmos' on field 'uri': rejected value [null];"
);
assertThat(errorStrings.size()).isEqualTo(errorStringsExpected.size());
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosRepositoriesAutoConfigurationUnitTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosRepositoriesAutoConfigurationUnitTest.java
index fe76f759d5b07..f8a7ccbe4d7f8 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosRepositoriesAutoConfigurationUnitTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/cosmos/CosmosRepositoriesAutoConfigurationUnitTest.java
@@ -3,23 +3,22 @@
package com.azure.spring.autoconfigure.cosmos;
-import com.azure.spring.data.cosmos.core.CosmosTemplate;
-import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories;
import com.azure.spring.autoconfigure.cosmos.domain.Person;
import com.azure.spring.autoconfigure.cosmos.domain.PersonRepository;
+import com.azure.spring.data.cosmos.core.CosmosTemplate;
+import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories;
import org.assertj.core.api.Assertions;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
-@RunWith(MockitoJUnitRunner.class)
-@Ignore
+@Disabled
public class CosmosRepositoriesAutoConfigurationUnitTest {
private AnnotationConfigApplicationContext context;
@@ -27,7 +26,12 @@ public class CosmosRepositoriesAutoConfigurationUnitTest {
@InjectMocks
private CosmosTemplate cosmosTemplate;
- @After
+ @BeforeEach
+ public void setUp() {
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
public void close() {
if (this.context != null) {
this.context.close();
@@ -41,10 +45,12 @@ public void testDefaultRepositoryConfiguration() throws Exception {
Assertions.assertThat(this.context.getBean(PersonRepository.class)).isNotNull();
}
- @Test(expected = NoSuchBeanDefinitionException.class)
+ @Test
public void autConfigNotKickInIfManualConfigDidNotCreateRepositories() throws Exception {
prepareApplicationContext(InvalidCustomConfiguration.class);
- this.context.getBean(PersonRepository.class);
+
+ org.junit.jupiter.api.Assertions.assertThrows(NoSuchBeanDefinitionException.class,
+ () -> this.context.getBean(PersonRepository.class));
}
private void prepareApplicationContext(Class>... configurationClasses) {
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/ConnectionStringResolverTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/ConnectionStringResolverTest.java
index 17537dd507173..e565014ad0d73 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/ConnectionStringResolverTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/ConnectionStringResolverTest.java
@@ -3,10 +3,11 @@
package com.azure.spring.autoconfigure.jms;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class ConnectionStringResolverTest {
+
@Test
public void testConnectionStringResolver() {
final String connectionString = "Endpoint=sb://host/;SharedAccessKeyName=sasKeyName;SharedAccessKey=sasKey";
@@ -16,8 +17,8 @@ public void testConnectionStringResolver() {
final String sasKeyName = serviceBusKey.getSharedAccessKeyName();
final String sasKey = serviceBusKey.getSharedAccessKey();
- Assert.assertEquals("host", host);
- Assert.assertEquals("sasKeyName", sasKeyName);
- Assert.assertEquals("sasKey", sasKey);
+ Assertions.assertEquals("host", host);
+ Assertions.assertEquals("sasKeyName", sasKeyName);
+ Assertions.assertEquals("sasKey", sasKey);
}
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/NonPremiumServiceBusJMSAutoConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/NonPremiumServiceBusJMSAutoConfigurationTest.java
index a0209101fbe4a..78a81597b2065 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/NonPremiumServiceBusJMSAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/NonPremiumServiceBusJMSAutoConfigurationTest.java
@@ -4,7 +4,8 @@
package com.azure.spring.autoconfigure.jms;
import org.apache.qpid.jms.JmsConnectionFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -34,19 +35,22 @@ public void testAzureServiceBusNonPremiumAutoConfiguration() {
.run(context -> assertThat(context).hasSingleBean(AzureServiceBusJMSProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureServiceBusJMSPropertiesConnectionStringValidation() {
ApplicationContextRunner contextRunner = getEmptyContextRunner();
- contextRunner.run(context -> context.getBean(AzureServiceBusJMSProperties.class));
+ contextRunner.run(
+ context -> Assertions.assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureServiceBusJMSProperties.class)));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureServiceBusJMSPropertiesPricingTireValidation() {
ApplicationContextRunner contextRunner = getEmptyContextRunner();
contextRunner.withPropertyValues(
"spring.jms.servicebus.pricing-tier=fake",
"spring.jms.servicebus.connection-string=" + CONNECTION_STRING)
- .run(context -> context.getBean(AzureServiceBusJMSProperties.class));
+ .run(context -> Assertions.assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureServiceBusJMSProperties.class)));
}
@Test
@@ -90,7 +94,8 @@ public void testAzureServiceBusJMSPropertiesConfigured() {
private ApplicationContextRunner getEmptyContextRunner() {
return new ApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(NonPremiumServiceBusJMSAutoConfiguration.class, JmsAutoConfiguration.class))
+ .withConfiguration(AutoConfigurations.of(NonPremiumServiceBusJMSAutoConfiguration.class,
+ JmsAutoConfiguration.class))
.withPropertyValues(
"spring.jms.servicebus.pricing-tier=basic"
);
@@ -99,7 +104,8 @@ private ApplicationContextRunner getEmptyContextRunner() {
private ApplicationContextRunner getContextRunnerWithProperties() {
return new ApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(NonPremiumServiceBusJMSAutoConfiguration.class, JmsAutoConfiguration.class))
+ .withConfiguration(AutoConfigurations.of(NonPremiumServiceBusJMSAutoConfiguration.class,
+ JmsAutoConfiguration.class))
.withPropertyValues(
"spring.jms.servicebus.connection-string=" + CONNECTION_STRING,
"spring.jms.servicebus.topic-client-id=cid",
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/PremiumServiceBusJMSAutoConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/PremiumServiceBusJMSAutoConfigurationTest.java
index 77e8d3081fefd..7cc42d8c1137d 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/PremiumServiceBusJMSAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/jms/PremiumServiceBusJMSAutoConfigurationTest.java
@@ -4,7 +4,8 @@
package com.azure.spring.autoconfigure.jms;
import com.microsoft.azure.servicebus.jms.ServiceBusJmsConnectionFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -34,10 +35,12 @@ public void testAzureServiceBusPremiumAutoConfiguration() {
.run(context -> assertThat(context).hasSingleBean(AzureServiceBusJMSProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureServiceBusJMSPropertiesConnectionStringValidation() {
ApplicationContextRunner contextRunner = getEmptyContextRunner();
- contextRunner.run(context -> context.getBean(AzureServiceBusJMSProperties.class));
+ contextRunner.run(
+ context -> Assertions.assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureServiceBusJMSProperties.class)));
}
@Test
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/AzureStorageResourcePatternResolverTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/AzureStorageResourcePatternResolverTest.java
index 86a49f5e0df46..0da160490163f 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/AzureStorageResourcePatternResolverTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/AzureStorageResourcePatternResolverTest.java
@@ -17,27 +17,29 @@
import com.azure.storage.file.share.ShareServiceClient;
import com.azure.storage.file.share.models.ShareFileItem;
import com.azure.storage.file.share.models.ShareItem;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.util.ArrayList;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* The JUnit tests for the AzureStorageResourcePatternResolver class.
*/
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@SpringBootTest(properties = "spring.main.banner-mode=off")
-@RunWith(SpringRunner.class)
public class AzureStorageResourcePatternResolverTest {
/**
@@ -52,6 +54,18 @@ public class AzureStorageResourcePatternResolverTest {
@Autowired
private ShareServiceClient shareServiceClient;
+ private AutoCloseable closeable;
+
+ @BeforeAll
+ public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterAll
+ public void close() throws Exception {
+ closeable.close();
+ }
+
/**
* Test getResources method.
*
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/StorageAutoConfigurationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/StorageAutoConfigurationTest.java
index b764d0d9ce06b..a95a9b65702df 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/StorageAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/StorageAutoConfigurationTest.java
@@ -5,8 +5,7 @@
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.file.share.ShareServiceClientBuilder;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@@ -15,6 +14,8 @@
import org.springframework.core.io.ClassPathResource;
import static org.assertj.core.api.Assertions.assertThat;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
public class StorageAutoConfigurationTest {
@@ -35,10 +36,11 @@ public void testWithoutStorageClient() {
.run(context -> assertThat(context).doesNotHaveBean(StorageProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureStoragePropertiesIllegal() {
this.contextRunner.withPropertyValues("azure.storage.accountName=a")
- .run(context -> context.getBean(StorageProperties.class));
+ .run(context -> assertThrows(IllegalStateException.class,
+ () -> context.getBean(StorageProperties.class)));
}
@Test
@@ -49,9 +51,9 @@ public void testAzureStoragePropertiesConfigured() {
.run(context -> {
assertThat(context).hasSingleBean(StorageProperties.class);
final StorageProperties storageProperties = context.getBean(StorageProperties.class);
- Assertions.assertThat(storageProperties.getAccountName()).isEqualTo("acc1");
- Assertions.assertThat(storageProperties.getAccountKey()).isEqualTo("key1");
- Assertions.assertThat(storageProperties.getBlobEndpoint()).isEqualTo("endpoint1");
+ assertThat(storageProperties.getAccountName()).isEqualTo("acc1");
+ assertThat(storageProperties.getAccountKey()).isEqualTo("key1");
+ assertThat(storageProperties.getBlobEndpoint()).isEqualTo("endpoint1");
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/BlobStorageHealthIndicatorTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/BlobStorageHealthIndicatorTest.java
index 1ef55336a6dbe..b869f6fab4c5e 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/BlobStorageHealthIndicatorTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/BlobStorageHealthIndicatorTest.java
@@ -12,8 +12,8 @@
import com.azure.storage.blob.models.StorageAccountInfo;
import com.azure.storage.file.share.ShareServiceClientBuilder;
import org.apache.http.HttpException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -29,7 +29,7 @@ public class BlobStorageHealthIndicatorTest {
private static final String MOCK_URL = "https://example.org/bigly_fake_url";
- @Test(expected = IllegalStateException.class)
+ @Test
public void testWithNoStorageConfiguration() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withAllowBeanDefinitionOverriding(true)
@@ -37,7 +37,9 @@ public void testWithNoStorageConfiguration() {
.withBean(ShareServiceClientBuilder.class)
.withConfiguration(AutoConfigurations.of(StorageHealthConfiguration.class));
- contextRunner.run(context -> context.getBean(BlobStorageHealthIndicator.class).getHealth(true));
+ contextRunner.run(context ->
+ Assertions.assertThrows(IllegalStateException.class,
+ () -> context.getBean(BlobStorageHealthIndicator.class).getHealth(true)));
}
@Test
@@ -51,8 +53,8 @@ public void testWithStorageConfigurationWithConnectionUp() {
contextRunner.run(context -> {
Health health = context.getBean("blobStorageHealthIndicator", BlobStorageHealthIndicator.class)
.getHealth(true);
- Assert.assertEquals(Status.UP, health.getStatus());
- Assert.assertEquals(MOCK_URL, health.getDetails().get(Constants.URL_FIELD));
+ Assertions.assertEquals(Status.UP, health.getStatus());
+ Assertions.assertEquals(MOCK_URL, health.getDetails().get(Constants.URL_FIELD));
});
}
@@ -67,8 +69,8 @@ public void testWithStorageConfigurationWithConnectionDown() {
contextRunner.run(context -> {
Health health = context.getBean("blobStorageHealthIndicator", BlobStorageHealthIndicator.class)
.getHealth(true);
- Assert.assertEquals(Status.DOWN, health.getStatus());
- Assert.assertEquals(MOCK_URL, health.getDetails().get(Constants.URL_FIELD));
+ Assertions.assertEquals(Status.DOWN, health.getStatus());
+ Assertions.assertEquals(MOCK_URL, health.getDetails().get(Constants.URL_FIELD));
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/FileStorageHealthIndicatorTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/FileStorageHealthIndicatorTest.java
index 7dacb2bead8a8..729f4dd396048 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/FileStorageHealthIndicatorTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/actuator/FileStorageHealthIndicatorTest.java
@@ -10,8 +10,8 @@
import com.azure.storage.file.share.ShareServiceClientBuilder;
import com.azure.storage.file.share.models.ShareServiceProperties;
import org.apache.http.HttpException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -27,16 +27,16 @@
public class FileStorageHealthIndicatorTest {
private static final String MOCK_URL = "https://example.org/bigly_fake_url";
- @Test(expected = IllegalStateException.class)
+ @Test
public void testWithNoStorageConfiguration() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withAllowBeanDefinitionOverriding(true)
.withBean(ShareServiceClientBuilder.class)
.withConfiguration(AutoConfigurations.of(StorageHealthConfiguration.class));
- contextRunner.withBean(FileStorageHealthIndicator.class).run(context -> {
- context.getBean(FileStorageHealthIndicator.class).getHealth(true);
- });
+ contextRunner.withBean(FileStorageHealthIndicator.class).run(context ->
+ Assertions.assertThrows(IllegalStateException.class,
+ () -> context.getBean(FileStorageHealthIndicator.class).getHealth(true)));
}
@Test
@@ -48,8 +48,8 @@ public void testWithStorageConfigurationWithConnectionUp() {
.withPropertyValues("azure.storage.account-name=acc1");
contextRunner.run(context -> {
Health health = context.getBean(FileStorageHealthIndicator.class).getHealth(true);
- Assert.assertEquals(Status.UP, health.getStatus());
- Assert.assertEquals(MOCK_URL, health.getDetails().get(URL_FIELD));
+ Assertions.assertEquals(Status.UP, health.getStatus());
+ Assertions.assertEquals(MOCK_URL, health.getDetails().get(URL_FIELD));
});
}
@@ -62,8 +62,8 @@ public void testWithStorageConfigurationWithConnectionDown() {
.withPropertyValues("azure.storage.account-name=acc1");
contextRunner.run(context -> {
Health health = context.getBean(FileStorageHealthIndicator.class).getHealth(true);
- Assert.assertEquals(Status.DOWN, health.getStatus());
- Assert.assertEquals(MOCK_URL, health.getDetails().get(URL_FIELD));
+ Assertions.assertEquals(Status.DOWN, health.getStatus());
+ Assertions.assertEquals(MOCK_URL, health.getDetails().get(URL_FIELD));
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/resource/AzureBlobStorageTests.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/resource/AzureBlobStorageTests.java
index 315e8f35db4e9..7bdfcaddcb072 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/resource/AzureBlobStorageTests.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/autoconfigure/storage/resource/AzureBlobStorageTests.java
@@ -11,9 +11,8 @@
import com.azure.storage.blob.specialized.BlobInputStream;
import com.azure.storage.blob.specialized.BlobOutputStream;
import com.azure.storage.blob.specialized.BlockBlobClient;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -22,7 +21,6 @@
import org.springframework.context.annotation.Import;
import org.springframework.core.io.Resource;
import org.springframework.core.io.WritableResource;
-import org.springframework.test.context.junit4.SpringRunner;
import java.io.FileNotFoundException;
import java.io.OutputStream;
@@ -36,7 +34,6 @@
* @author Warren Zhu
*/
@SpringBootTest(properties = "spring.main.banner-mode=off")
-@RunWith(SpringRunner.class)
public class AzureBlobStorageTests {
private static final String CONTAINER_NAME = "container";
@@ -50,27 +47,29 @@ public class AzureBlobStorageTests {
@Autowired
private BlobServiceClient blobServiceClient;
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyPath() {
- new BlobStorageResource(this.blobServiceClient, "azure-blob://");
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new BlobStorageResource(this.blobServiceClient,
+ "azure-blob://"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testSlashPath() {
- new BlobStorageResource(this.blobServiceClient, "azure-blob:///");
+ Assertions.assertThrows(IllegalArgumentException.class, () -> new BlobStorageResource(this.blobServiceClient,
+ "azure-blob:///"));
}
@Test
public void testValidObject() throws Exception {
- Assert.assertTrue(this.remoteResource.exists());
- Assert.assertEquals(CONTENT_LENGTH, this.remoteResource.contentLength());
+ Assertions.assertTrue(this.remoteResource.exists());
+ Assertions.assertEquals(CONTENT_LENGTH, this.remoteResource.contentLength());
}
@Test
public void testWritable() throws Exception {
- Assert.assertTrue(this.remoteResource instanceof WritableResource);
+ Assertions.assertTrue(this.remoteResource instanceof WritableResource);
WritableResource writableResource = (WritableResource) this.remoteResource;
- Assert.assertTrue(writableResource.isWritable());
+ Assertions.assertTrue(writableResource.isWritable());
writableResource.getOutputStream();
}
@@ -80,44 +79,44 @@ public void testWritableOutputStream() throws Exception {
BlobStorageResource resource = new BlobStorageResource(blobServiceClient, location);
OutputStream os = resource.getOutputStream();
- Assert.assertNotNull(os);
+ Assertions.assertNotNull(os);
}
- @Test(expected = FileNotFoundException.class)
- public void testWritableOutputStreamNoAutoCreateOnNullBlob() throws Exception {
+ @Test
+ public void testWritableOutputStreamNoAutoCreateOnNullBlob() {
String location = "azure-blob://container/non-existing";
BlobStorageResource resource = new BlobStorageResource(this.blobServiceClient, location);
- resource.getOutputStream();
+ Assertions.assertThrows(FileNotFoundException.class, () -> resource.getOutputStream());
}
- @Test(expected = FileNotFoundException.class)
- public void testGetInputStreamOnNullBlob() throws Exception {
+ @Test
+ public void testGetInputStreamOnNullBlob() {
String location = "azure-blob://container/non-existing";
BlobStorageResource resource = new BlobStorageResource(blobServiceClient, location);
- resource.getInputStream();
+ Assertions.assertThrows(FileNotFoundException.class, () -> resource.getInputStream());
}
@Test
public void testGetFilenameOnNonExistingBlob() {
String location = "azure-blob://container/non-existing";
BlobStorageResource resource = new BlobStorageResource(blobServiceClient, location);
- Assert.assertEquals(NON_EXISTING, resource.getFilename());
+ Assertions.assertEquals(NON_EXISTING, resource.getFilename());
}
@Test
public void testContainerDoesNotExist() {
BlobStorageResource resource = new BlobStorageResource(this.blobServiceClient,
"azure-blob://non-existing/blob");
- Assert.assertFalse(resource.exists());
+ Assertions.assertFalse(resource.exists());
}
@Test
public void testContainerExistsButResourceDoesNot() {
BlobStorageResource resource = new BlobStorageResource(this.blobServiceClient,
"azure-blob://container/non-existing");
- Assert.assertFalse(resource.exists());
+ Assertions.assertFalse(resource.exists());
}
@Configuration
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/cloudfoundry/environment/AzureCloudFoundryServiceApplicationTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/cloudfoundry/environment/AzureCloudFoundryServiceApplicationTest.java
index c8ffda6981187..dfdee77aab9fb 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/cloudfoundry/environment/AzureCloudFoundryServiceApplicationTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/cloudfoundry/environment/AzureCloudFoundryServiceApplicationTest.java
@@ -3,8 +3,7 @@
package com.azure.spring.cloudfoundry.environment;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,17 +11,15 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = {VcapProcessor.class})
public class AzureCloudFoundryServiceApplicationTest {
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/CaseSensitiveKeyVaultTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/CaseSensitiveKeyVaultTest.java
index cd35b152d802e..f18385ae86748 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/CaseSensitiveKeyVaultTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/CaseSensitiveKeyVaultTest.java
@@ -4,31 +4,42 @@
package com.azure.spring.keyvault;
import com.azure.security.keyvault.secrets.SecretClient;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import static com.azure.spring.utils.Constants.DEFAULT_REFRESH_INTERVAL_MS;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-
-@RunWith(MockitoJUnitRunner.class)
public class CaseSensitiveKeyVaultTest {
+ private AutoCloseable closeable;
+
@Mock
private SecretClient keyVaultClient;
+ @BeforeEach
+ public void setup() {
+ closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Test
public void testGet() {
final KeyVaultOperation keyVaultOperation = new KeyVaultOperation(
- keyVaultClient,
- DEFAULT_REFRESH_INTERVAL_MS,
- new ArrayList<>(),
- true);
+ keyVaultClient,
+ DEFAULT_REFRESH_INTERVAL_MS,
+ new ArrayList<>(),
+ true);
final LinkedHashMap properties = new LinkedHashMap<>();
properties.put("key1", "value1");
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/InitializerTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/InitializerTest.java
index 21aff5ec99ff8..feb169a3c1549 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/InitializerTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/InitializerTest.java
@@ -4,18 +4,19 @@
package com.azure.spring.keyvault;
import com.azure.spring.utils.Constants;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@TestPropertySource(locations = "classpath:application.properties")
public class InitializerTest {
@@ -25,9 +26,9 @@ public class InitializerTest {
@Test
public void testAzureKvPropertySourceNotInitialized() {
final MutablePropertySources sources =
- ((ConfigurableEnvironment) context.getEnvironment()).getPropertySources();
+ ((ConfigurableEnvironment) context.getEnvironment()).getPropertySources();
- assertFalse("PropertySources should not contains azurekv when enabled=false",
- sources.contains(Constants.AZURE_KEYVAULT_PROPERTYSOURCE_NAME));
+ assertFalse(sources.contains(Constants.AZURE_KEYVAULT_PROPERTYSOURCE_NAME), "PropertySources should not "
+ + "contains azurekv when enabled=false");
}
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultEnvironmentPostProcessorTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultEnvironmentPostProcessorTest.java
index 1bca6eec71a43..b3887d08c26c0 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultEnvironmentPostProcessorTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultEnvironmentPostProcessorTest.java
@@ -8,8 +8,8 @@
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ManagedIdentityCredential;
import org.hamcrest.core.IsInstanceOf;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
@@ -28,7 +28,7 @@
import static com.azure.spring.keyvault.KeyVaultProperties.Property.CLIENT_KEY;
import static com.azure.spring.keyvault.KeyVaultProperties.Property.TENANT_ID;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class KeyVaultEnvironmentPostProcessorTest {
private KeyVaultEnvironmentPostProcessorHelper keyVaultEnvironmentPostProcessorHelper;
@@ -36,7 +36,7 @@ public class KeyVaultEnvironmentPostProcessorTest {
private MutablePropertySources propertySources;
private Map testProperties = new HashMap<>();
- @Before
+ @BeforeEach
public void setup() {
environment = new MockEnvironment();
environment.setProperty(KeyVaultProperties.getPropertyName(ALLOW_TELEMETRY), "false");
@@ -114,16 +114,16 @@ public void postProcessorHasConfiguredOrder() {
@Test
public void postProcessorOrderConfigurable() {
final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
- .withConfiguration(AutoConfigurations.of(OrderedProcessConfig.class))
- .withPropertyValues("azure.keyvault.uri=fakeuri", "azure.keyvault.enabled=true");
+ .withConfiguration(AutoConfigurations.of(OrderedProcessConfig.class))
+ .withPropertyValues("azure.keyvault.uri=fakeuri", "azure.keyvault.enabled=true");
contextRunner.run(context -> {
assertThat("Configured order for KeyVaultEnvironmentPostProcessor is different with default order "
+ "value.",
KeyVaultEnvironmentPostProcessor.DEFAULT_ORDER != OrderedProcessConfig.TEST_ORDER);
- assertEquals("KeyVaultEnvironmentPostProcessor order should be changed.",
- OrderedProcessConfig.TEST_ORDER,
- context.getBean(KeyVaultEnvironmentPostProcessor.class).getOrder());
+ assertEquals(OrderedProcessConfig.TEST_ORDER,
+ context.getBean(KeyVaultEnvironmentPostProcessor.class).getOrder(), "KeyVaultEnvironmentPostProcessor"
+ + " order should be changed.");
});
}
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultOperationUnitTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultOperationUnitTest.java
index 081a9102d5a6b..f5d9eea075742 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultOperationUnitTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultOperationUnitTest.java
@@ -12,10 +12,11 @@
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
import com.azure.security.keyvault.secrets.models.SecretProperties;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -27,7 +28,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class KeyVaultOperationUnitTest {
private static final List SECRET_KEYS_CONFIG = Arrays.asList("key1", "key2", "key3");
@@ -55,8 +55,21 @@ public class KeyVaultOperationUnitTest {
@Mock
private SecretClient keyVaultClient;
+
private KeyVaultOperation keyVaultOperation;
+ private AutoCloseable closeable;
+
+ @BeforeEach
+ public void setup() {
+ closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
public void setupSecretBundle(List secretKeysConfig) {
keyVaultOperation = new KeyVaultOperation(
keyVaultClient,
diff --git a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultPropertySourceUnitTest.java b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultPropertySourceUnitTest.java
index 8eb33088379a3..7a04b56e49275 100644
--- a/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultPropertySourceUnitTest.java
+++ b/sdk/spring/azure-spring-boot/src/test/java/com/azure/spring/keyvault/KeyVaultPropertySourceUnitTest.java
@@ -3,26 +3,33 @@
package com.azure.spring.keyvault;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+
public class KeyVaultPropertySourceUnitTest {
private static final String TEST_PROPERTY_NAME_1 = "testPropertyName1";
+
+ private AutoCloseable closeable;
+
@Mock
KeyVaultOperation keyVaultOperation;
+
KeyVaultPropertySource keyVaultPropertySource;
- @Before
+ @BeforeEach
public void setup() {
+ closeable = MockitoAnnotations.openMocks(this);
+
final String[] propertyNameList = new String[]{TEST_PROPERTY_NAME_1};
when(keyVaultOperation.getProperty(anyString())).thenReturn(TEST_PROPERTY_NAME_1);
@@ -31,6 +38,11 @@ public void setup() {
keyVaultPropertySource = new KeyVaultPropertySource(keyVaultOperation);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Test
public void testGetPropertyNames() {
final String[] result = keyVaultPropertySource.getPropertyNames();
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/pom.xml b/sdk/spring/azure-spring-cloud-autoconfigure/pom.xml
index 007c32797133d..e531143d825de 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/pom.xml
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/pom.xml
@@ -154,6 +154,7 @@
true
+
org.springframework.boot
spring-boot-starter-test
@@ -161,34 +162,6 @@
test
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
-
-
- org.mockito
- mockito-core
- 3.9.0
- test
-
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
-
com.azure.spring
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cache/AzureRedisAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cache/AzureRedisAutoConfigurationTest.java
index 55f93061cdefd..4cde7e260e046 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cache/AzureRedisAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cache/AzureRedisAutoConfigurationTest.java
@@ -6,7 +6,7 @@
import com.azure.resourcemanager.redis.models.RedisAccessKeys;
import com.azure.resourcemanager.redis.models.RedisCache;
import com.azure.spring.cloud.context.core.impl.RedisCacheManager;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -16,6 +16,7 @@
import org.springframework.data.redis.core.RedisOperations;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -31,26 +32,30 @@ public class AzureRedisAutoConfigurationTest {
@Test
public void testAzureRedisDisabled() {
this.contextRunner.withPropertyValues("spring.cloud.azure.redis.enabled=false")
- .run(context -> assertThat(context).doesNotHaveBean(AzureRedisProperties.class));
+ .run(context -> assertThat(context).doesNotHaveBean(AzureRedisProperties.class));
}
@Test
public void testWithoutRedisOperationsClass() {
this.contextRunner.withClassLoader(new FilteredClassLoader(RedisOperations.class))
- .run(context -> assertThat(context).doesNotHaveBean(AzureRedisProperties.class));
+ .run(context -> assertThat(context).doesNotHaveBean(AzureRedisProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureRedisPropertiesIllegal() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
- .withPropertyValues("spring.cloud.azure.redis.name=")
- .run(context -> context.getBean(AzureRedisProperties.class));
+ .withPropertyValues("spring.cloud.azure.redis.name=")
+ .run(context -> assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureRedisProperties.class)));
}
@Test
public void testAzureRedisPropertiesConfigured() {
- this.contextRunner.withUserConfiguration(TestConfiguration.class).
- withPropertyValues("spring.cloud.azure.redis.name=redis").run(context -> {
+ this.contextRunner
+ .withUserConfiguration(TestConfiguration.class)
+ .withPropertyValues("spring.cloud.azure.redis.name=redis")
+ .run(
+ context -> {
assertThat(context).hasSingleBean(AzureRedisProperties.class);
assertThat(context.getBean(AzureRedisProperties.class).getName()).isEqualTo("redis");
assertThat(context).hasSingleBean(RedisProperties.class);
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cloudfoundry/AzureCloudFoundryEnvironmentPostProcessorTests.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cloudfoundry/AzureCloudFoundryEnvironmentPostProcessorTests.java
index 263d3e9040970..a927e815a1cef 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cloudfoundry/AzureCloudFoundryEnvironmentPostProcessorTests.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/cloudfoundry/AzureCloudFoundryEnvironmentPostProcessorTests.java
@@ -6,7 +6,7 @@
import com.azure.spring.cloud.autoconfigure.storage.AzureStorageProperties;
import com.azure.spring.cloud.autoconfigure.eventhub.AzureEventHubProperties;
import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubAutoConfigurationTest.java
index 5fd39f5ae8d97..67c919af2a89d 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubAutoConfigurationTest.java
@@ -16,7 +16,7 @@
import com.azure.spring.integration.eventhub.api.EventHubClientFactory;
import com.azure.spring.integration.eventhub.api.EventHubOperation;
import com.azure.spring.integration.eventhub.factory.EventHubConnectionStringProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -31,6 +31,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AzureEventHubAutoConfigurationTest {
@@ -52,10 +53,11 @@ public void testWithoutEventHubClient() {
.run(context -> assertThat(context).doesNotHaveBean(AzureEventHubProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureEventHubPropertiesStorageAccountIllegal() {
this.contextRunner.withPropertyValues(EVENT_HUB_PROPERTY_PREFIX + "checkpoint-storage-account=1")
- .run(context -> context.getBean(AzureEventHubProperties.class));
+ .run(context -> assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureEventHubProperties.class)));
}
@Test
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubKafkaAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubKafkaAutoConfigurationTest.java
index 3c1eb1bd6c012..4159ba5c8e97f 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubKafkaAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/eventhub/AzureEventHubKafkaAutoConfigurationTest.java
@@ -14,8 +14,8 @@
import com.azure.resourcemanager.eventhubs.models.EventHubNamespaceAuthorizationRule;
import com.azure.resourcemanager.eventhubs.models.EventHubNamespaces;
import com.azure.spring.cloud.context.core.config.AzureProperties;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -31,6 +31,7 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AzureEventHubKafkaAutoConfigurationTest {
@@ -51,12 +52,13 @@ public void testWithoutKafkaTemplate() {
.run(context -> assertThat(context).doesNotHaveBean(AzureEventHubProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureEventHubPropertiesStorageAccountIllegal() {
this.contextRunner.withPropertyValues(
EVENT_HUB_PROPERTY_PREFIX + "namespace=ns1",
EVENT_HUB_PROPERTY_PREFIX + "checkpoint-storage-account=1")
- .run(context -> context.getBean(AzureEventHubProperties.class));
+ .run(context -> assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureEventHubProperties.class)));
}
@Test
@@ -68,7 +70,7 @@ public void testNamespaceProvided() {
.run(context -> context.getBean(AzureEventHubProperties.class));
}
- @Ignore("org.apache.kafka.common.serialization.StringSerializer required on classpath")
+ @Disabled("org.apache.kafka.common.serialization.StringSerializer required on classpath")
@Test
public void testAzureEventHubPropertiesConfigured() {
this.contextRunner.withPropertyValues(EVENT_HUB_PROPERTY_PREFIX + "namespace=ns1").run(context -> {
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusAutoConfigurationTest.java
index 2f36e4b8f506e..4a6ae9f343960 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusAutoConfigurationTest.java
@@ -8,7 +8,7 @@
import com.azure.spring.cloud.context.core.config.AzureProperties;
import com.azure.spring.cloud.context.core.impl.ServiceBusNamespaceManager;
import com.azure.spring.integration.servicebus.factory.ServiceBusConnectionStringProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -20,6 +20,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AzureServiceBusAutoConfigurationTest {
@@ -63,10 +64,11 @@ public void testWithoutServiceBusSDKInClasspath() {
.run(context -> assertThat(context).doesNotHaveBean(AzureServiceBusProperties.class));
}
- @Test(expected = NoSuchBeanDefinitionException.class)
+ @Test
public void testAzureServiceBusPropertiesValidation() {
this.contextRunner.withClassLoader(new FilteredClassLoader(ServiceBusReceivedMessage.class))
- .run(context -> context.getBean(AzureServiceBusProperties.class));
+ .run(context -> assertThrows(NoSuchBeanDefinitionException.class,
+ () -> context.getBean(AzureServiceBusProperties.class)));
}
@Test
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueAutoConfigurationTest.java
index 20a43448282c6..d5d793ca7cb2f 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueAutoConfigurationTest.java
@@ -13,7 +13,11 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusQueueClientFactory;
import com.azure.spring.integration.servicebus.queue.ServiceBusQueueOperation;
import com.azure.spring.integration.servicebus.queue.ServiceBusQueueTemplate;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.mockito.MockitoAnnotations;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -29,6 +33,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class AzureServiceBusQueueAutoConfigurationTest {
private static final String SERVICE_BUS_PROPERTY_PREFIX = "spring.cloud.azure.servicebus.";
@@ -40,15 +45,27 @@ public class AzureServiceBusQueueAutoConfigurationTest {
private static final String SHARED_ACCESS_KEY_NAME = "dummySasKeyName";
private static final String SHARED_ACCESS_KEY = "dummySasKey";
private static final String ENDPOINT = getUri(ENDPOINT_FORMAT, NAMESPACE_NAME, DEFAULT_DOMAIN_NAME).toString();
- static final String NAMESPACE_CONNECTION_STRING = String.format("Endpoint=%s;SharedAccessKeyName=%s;SharedAccessKey=%s",
- ENDPOINT, SHARED_ACCESS_KEY_NAME, SHARED_ACCESS_KEY);
+ static final String NAMESPACE_CONNECTION_STRING = String.format("Endpoint=%s;SharedAccessKeyName=%s;"
+ + "SharedAccessKey=%s",
+ ENDPOINT, SHARED_ACCESS_KEY_NAME, SHARED_ACCESS_KEY);
+ private AutoCloseable closeable;
+
+ @BeforeAll
+ public void setup() {
+ this.closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterAll
+ public void close() throws Exception {
+ this.closeable.close();
+ }
private static URI getUri(String endpointFormat, String namespace, String domainName) {
try {
return new URI(String.format(Locale.US, endpointFormat, namespace, domainName));
} catch (URISyntaxException exception) {
throw new IllegalArgumentException(String.format(Locale.US,
- "Invalid namespace name: %s", namespace), exception);
+ "Invalid namespace name: %s", namespace), exception);
}
}
@@ -75,7 +92,8 @@ public void testWithoutServiceBusNamespaceManager() {
@Test
public void testWithServiceBusNamespaceManager() {
- this.contextRunner.withUserConfiguration(TestConfigWithServiceBusNamespaceManager.class, TestConfigWithConnectionStringProvider.class)
+ this.contextRunner.withUserConfiguration(TestConfigWithServiceBusNamespaceManager.class,
+ TestConfigWithConnectionStringProvider.class)
.run(context -> assertThat(context).hasSingleBean(ServiceBusQueueManager.class));
}
@@ -93,7 +111,8 @@ public void testConnectionStringProvided() {
this.contextRunner.withPropertyValues(SERVICE_BUS_PROPERTY_PREFIX + "connection-string=" + NAMESPACE_CONNECTION_STRING)
.withUserConfiguration(AzureServiceBusAutoConfiguration.class)
.run(context -> {
- assertThat(context.getBean(ServiceBusConnectionStringProvider.class).getConnectionString()).isEqualTo(NAMESPACE_CONNECTION_STRING);
+ assertThat(context.getBean(ServiceBusConnectionStringProvider.class)
+ .getConnectionString()).isEqualTo(NAMESPACE_CONNECTION_STRING);
assertThat(context).doesNotHaveBean(ServiceBusNamespaceManager.class);
assertThat(context).doesNotHaveBean(ServiceBusQueueManager.class);
assertThat(context).hasSingleBean(ServiceBusQueueClientFactory.class);
@@ -132,7 +151,8 @@ public void testMessageConverterProvided() {
assertThat(context).hasSingleBean(ServiceBusMessageConverter.class);
assertThat(context).hasSingleBean(ServiceBusQueueTemplate.class);
- ServiceBusMessageConverter messageConverter = context.getBean(ServiceBusMessageConverter.class);
+ ServiceBusMessageConverter messageConverter =
+ context.getBean(ServiceBusMessageConverter.class);
ServiceBusQueueTemplate queueTemplate = context.getBean(ServiceBusQueueTemplate.class);
assertSame(messageConverter, queueTemplate.getMessageConverter());
});
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicAutoConfigurationTest.java
index 9f32dcf5cf6c2..e23b0df30e758 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicAutoConfigurationTest.java
@@ -14,7 +14,11 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusTopicClientFactory;
import com.azure.spring.integration.servicebus.topic.ServiceBusTopicOperation;
import com.azure.spring.integration.servicebus.topic.ServiceBusTopicTemplate;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.mockito.MockitoAnnotations;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.FilteredClassLoader;
@@ -27,6 +31,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class AzureServiceBusTopicAutoConfigurationTest {
private static final String SERVICE_BUS_PROPERTY_PREFIX = "spring.cloud.azure.servicebus.";
@@ -34,6 +39,17 @@ public class AzureServiceBusTopicAutoConfigurationTest {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(AzureServiceBusTopicAutoConfiguration.class));
+ private AutoCloseable closeable;
+
+ @BeforeAll
+ public void setup() {
+ this.closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterAll
+ public void close() throws Exception {
+ this.closeable.close();
+ }
@Test
public void testAzureServiceBusTopicDisabled() {
@@ -64,7 +80,8 @@ public void testWithServiceBusNamespaceManager() {
@Test
public void testTopicClientFactoryCreated() {
- this.contextRunner.withUserConfiguration(TestConfigWithConnectionStringProvider.class, TestConfigWithServiceBusNamespaceManager.class)
+ this.contextRunner.withUserConfiguration(TestConfigWithConnectionStringProvider.class,
+ TestConfigWithServiceBusNamespaceManager.class)
.run(context -> assertThat(context).hasSingleBean(ServiceBusTopicClientFactory.class)
.hasSingleBean(ServiceBusTopicOperation.class));
}
@@ -86,7 +103,8 @@ public void testConnectionStringProvided() {
@Test
public void testResourceManagerProvided() {
- this.contextRunner.withUserConfiguration(TestConfigWithAzureResourceManager.class, TestConfigWithConnectionStringProvider.class, AzureServiceBusAutoConfiguration.class)
+ this.contextRunner.withUserConfiguration(TestConfigWithAzureResourceManager.class,
+ TestConfigWithConnectionStringProvider.class, AzureServiceBusAutoConfiguration.class)
.withPropertyValues(
AZURE_PROPERTY_PREFIX + "resource-group=rg1",
SERVICE_BUS_PROPERTY_PREFIX + "namespace=ns1"
@@ -112,7 +130,8 @@ public void testMessageConverterProvided() {
assertThat(context).hasSingleBean(ServiceBusMessageConverter.class);
assertThat(context).hasSingleBean(ServiceBusTopicTemplate.class);
- ServiceBusMessageConverter messageConverter = context.getBean(ServiceBusMessageConverter.class);
+ ServiceBusMessageConverter messageConverter =
+ context.getBean(ServiceBusMessageConverter.class);
ServiceBusTopicTemplate topicTemplate = context.getBean(ServiceBusTopicTemplate.class);
assertSame(messageConverter, topicTemplate.getMessageConverter());
});
diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/ServiceBusUtilsTest.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/ServiceBusUtilsTest.java
index e5c3697ffd9b9..56b9b853a431b 100644
--- a/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/ServiceBusUtilsTest.java
+++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/servicebus/ServiceBusUtilsTest.java
@@ -3,8 +3,8 @@
package com.azure.spring.cloud.autoconfigure.servicebus;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class ServiceBusUtilsTest {
@@ -12,11 +12,11 @@ public class ServiceBusUtilsTest {
public void testGetNamespace() {
String connectionString = "Endpoint=sb://namespace.servicebus.windows.net/;"
+ "SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=key";
- Assert.assertEquals("namespace", ServiceBusUtils.getNamespace(connectionString));
+ Assertions.assertEquals("namespace", ServiceBusUtils.getNamespace(connectionString));
}
@Test
public void testGetNamespaceWithInvalidConnectionString() {
- Assert.assertNull(ServiceBusUtils.getNamespace("fake-connection-str"));
+ Assertions.assertNull(ServiceBusUtils.getNamespace("fake-connection-str"));
}
}
diff --git a/sdk/spring/azure-spring-cloud-context/pom.xml b/sdk/spring/azure-spring-cloud-context/pom.xml
index 5d5cddb018f60..9f38eae8b743b 100644
--- a/sdk/spring/azure-spring-cloud-context/pom.xml
+++ b/sdk/spring/azure-spring-cloud-context/pom.xml
@@ -73,24 +73,12 @@
-
- org.mockito
- mockito-core
- 3.9.0
- test
-
org.springframework.boot
spring-boot-starter-test
2.5.0
test
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
-
- junit
- junit
- 4.13.2
- test
-
-
-
- org.mockito
- mockito-core
- 3.9.0
- test
-
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
provided
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ 2.5.0
+ test
+
diff --git a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AbstractAzureMessagingAnnotationDrivenTests.java b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AbstractAzureMessagingAnnotationDrivenTests.java
index c4bf0a36d6b60..e327dfb7a62ac 100644
--- a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AbstractAzureMessagingAnnotationDrivenTests.java
+++ b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AbstractAzureMessagingAnnotationDrivenTests.java
@@ -8,23 +8,20 @@
import com.azure.spring.messaging.endpoint.AzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.MethodAzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.SimpleAzureListenerEndpoint;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.springframework.test.util.AssertionErrors.assertNotNull;
+
/**
* @author Warren Zhu
*/
-public abstract class AbstractAzureMessagingAnnotationDrivenTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
+public abstract class AbstractAzureMessagingAnnotationDrivenTests {
@Test
public abstract void sampleConfiguration();
@@ -51,29 +48,28 @@ public abstract class AbstractAzureMessagingAnnotationDrivenTests {
public abstract void azureMessageListeners();
/**
- * Test for {@link SampleBean} discovery. If a factory with the default name
- * is set, an endpoint will use it automatically
+ * Test for {@link SampleBean} discovery. If a factory with the default name is set, an endpoint will use it
+ * automatically
*/
public void testSampleConfiguration(ApplicationContext context) {
AzureListenerContainerTestFactory defaultFactory =
- context.getBean("azureListenerContainerFactory", AzureListenerContainerTestFactory.class);
+ context.getBean("azureListenerContainerFactory", AzureListenerContainerTestFactory.class);
AzureListenerContainerTestFactory simpleFactory =
- context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
+ context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
assertEquals(1, defaultFactory.getListenerContainers().size());
assertEquals(1, simpleFactory.getListenerContainers().size());
}
/**
- * Test for {@link FullBean} discovery. In this case, no default is set because
- * all endpoints provide a default registry. This shows that the default factory
- * is only retrieved if it needs to be.
+ * Test for {@link FullBean} discovery. In this case, no default is set because all endpoints provide a default
+ * registry. This shows that the default factory is only retrieved if it needs to be.
*/
public void testFullConfiguration(ApplicationContext context) {
AzureListenerContainerTestFactory simpleFactory =
- context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
+ context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
assertEquals(1, simpleFactory.getListenerContainers().size());
MethodAzureListenerEndpoint endpoint =
- (MethodAzureListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint();
+ (MethodAzureListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint();
assertEquals("listener1", endpoint.getId());
assertEquals("queueIn", endpoint.getDestination());
assertEquals("group1", endpoint.getGroup());
@@ -81,71 +77,70 @@ public void testFullConfiguration(ApplicationContext context) {
}
/**
- * Test for {@link CustomBean} and an manually endpoint registered
- * with "myCustomEndpointId". The custom endpoint does not provide
- * any factory so it's registered with the default one
+ * Test for {@link CustomBean} and an manually endpoint registered with "myCustomEndpointId". The custom endpoint
+ * does not provide any factory so it's registered with the default one
*/
public void testCustomConfiguration(ApplicationContext context) {
AzureListenerContainerTestFactory defaultFactory = context.getBean(
- AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
- AzureListenerContainerTestFactory.class);
+ AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
+ AzureListenerContainerTestFactory.class);
AzureListenerContainerTestFactory customFactory =
- context.getBean("customFactory", AzureListenerContainerTestFactory.class);
+ context.getBean("customFactory", AzureListenerContainerTestFactory.class);
assertEquals(1, defaultFactory.getListenerContainers().size());
assertEquals(1, customFactory.getListenerContainers().size());
AzureListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
- assertEquals("Wrong endpoint type", SimpleAzureListenerEndpoint.class, endpoint.getClass());
+ assertEquals(SimpleAzureListenerEndpoint.class, endpoint.getClass(), "Wrong endpoint type");
AzureListenerEndpointRegistry customRegistry =
- context.getBean("customRegistry", AzureListenerEndpointRegistry.class);
- assertEquals("Wrong number of containers in the registry", 2, customRegistry.getListenerContainerIds().size());
- assertEquals("Wrong number of containers in the registry", 2, customRegistry.getListenerContainers().size());
+ context.getBean("customRegistry", AzureListenerEndpointRegistry.class);
+ assertEquals(2, customRegistry.getListenerContainerIds().size(), "Wrong number of containers in the registry");
+ assertEquals(2, customRegistry.getListenerContainers().size(), "Wrong number of containers in the registry");
assertNotNull("Container with custom id on the annotation should be found",
- customRegistry.getListenerContainer("listenerId"));
+ customRegistry.getListenerContainer("listenerId"));
assertNotNull("Container created with custom id should be found",
- customRegistry.getListenerContainer("myCustomEndpointId"));
+ customRegistry.getListenerContainer("myCustomEndpointId"));
}
/**
- * Test for {@link DefaultBean} that does not define the container
- * factory to use as a default is registered with an explicit
- * default.
+ * Test for {@link DefaultBean} that does not define the container factory to use as a default is registered with an
+ * explicit default.
*/
public void testExplicitContainerFactoryConfiguration(ApplicationContext context) {
AzureListenerContainerTestFactory defaultFactory =
- context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
+ context.getBean("simpleFactory", AzureListenerContainerTestFactory.class);
assertEquals(1, defaultFactory.getListenerContainers().size());
}
/**
- * Test for {@link DefaultBean} that does not define the container
- * factory to use as a default is registered with the default name.
+ * Test for {@link DefaultBean} that does not define the container factory to use as a default is registered with
+ * the default name.
*/
public void testDefaultContainerFactoryConfiguration(ApplicationContext context) {
AzureListenerContainerTestFactory defaultFactory = context.getBean(
- AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
- AzureListenerContainerTestFactory.class);
+ AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
+ AzureListenerContainerTestFactory.class);
assertEquals(1, defaultFactory.getListenerContainers().size());
}
/**
- * Test for {@link AzureListenerRepeatableBean} and {@link AzureListenersBean} that validates that the
- * {@code @AzureListener} annotation is repeatable and generate one specific container per annotation.
+ * Test for {@link AzureListenerRepeatableBean} and {@link AzureListenersBean} that validates that the {@code
+ *
+ * @AzureListener} annotation is repeatable and generate one specific container per annotation.
*/
public void testAzureListenerRepeatable(ApplicationContext context) {
AzureListenerContainerTestFactory simpleFactory = context.getBean(
- AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
- AzureListenerContainerTestFactory.class);
+ AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
+ AzureListenerContainerTestFactory.class);
assertEquals(2, simpleFactory.getListenerContainers().size());
MethodAzureListenerEndpoint first =
- (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("first").getEndpoint();
+ (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("first").getEndpoint();
assertEquals("first", first.getId());
assertEquals("myQueue", first.getDestination());
assertEquals(null, first.getConcurrency());
MethodAzureListenerEndpoint second =
- (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint();
+ (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint();
assertEquals("second", second.getId());
assertEquals("anotherQueue", second.getDestination());
assertEquals("2-10", second.getConcurrency());
@@ -167,7 +162,7 @@ public void simpleHandle(String msg) {
static class FullBean {
@AzureMessageListener(id = "listener1", containerFactory = "simpleFactory", destination = "queueIn",
- group = "group1", concurrency = "1-10")
+ group = "group1", concurrency = "1-10")
@SendTo("queueOut")
public String fullHandle(String msg) {
return "reply";
@@ -201,8 +196,8 @@ public void repeatableHandle(String msg) {
@Component
static class AzureListenersBean {
- @AzureMessageListeners({@AzureMessageListener(id = "first", destination = "myQueue"),
- @AzureMessageListener(id = "second", destination = "anotherQueue", concurrency = "2-10")})
+ @AzureMessageListeners({ @AzureMessageListener(id = "first", destination = "myQueue"),
+ @AzureMessageListener(id = "second", destination = "anotherQueue", concurrency = "2-10") })
public void repeatableHandle(String msg) {
}
}
diff --git a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerAnnotationBeanPostProcessorTests.java b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerAnnotationBeanPostProcessorTests.java
index 89208fc9a53f7..e4feface80c1d 100644
--- a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerAnnotationBeanPostProcessorTests.java
+++ b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerAnnotationBeanPostProcessorTests.java
@@ -9,9 +9,7 @@
import com.azure.spring.messaging.endpoint.AbstractAzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.AzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.MethodAzureListenerEndpoint;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -29,55 +27,54 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* @author Warren Zhu
*/
public class AzureListenerAnnotationBeanPostProcessorTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
-
@Test
public void simpleMessageListener() throws Exception {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(Config.class, SimpleMessageListenerTestBean.class);
+ new AnnotationConfigApplicationContext(Config.class, SimpleMessageListenerTestBean.class);
AzureListenerContainerTestFactory factory = context.getBean(AzureListenerContainerTestFactory.class);
- assertEquals("One container should have been registered", 1, factory.getListenerContainers().size());
+ assertEquals(1, factory.getListenerContainers().size(), "One container should have been registered");
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
AzureListenerEndpoint endpoint = container.getEndpoint();
- assertEquals("Wrong endpoint type", MethodAzureListenerEndpoint.class, endpoint.getClass());
+ assertEquals(MethodAzureListenerEndpoint.class, endpoint.getClass(), "Wrong endpoint type");
MethodAzureListenerEndpoint methodEndpoint = (MethodAzureListenerEndpoint) endpoint;
assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass());
assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class),
- methodEndpoint.getMethod());
+ methodEndpoint.getMethod());
MessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
methodEndpoint.setupListenerContainer(listenerContainer);
assertNotNull(listenerContainer.getMessageHandler());
- assertTrue("Should have been started " + container, container.isStarted());
+ assertTrue(container.isStarted(), "Should have been started " + container);
context.close(); // Close and stop the listeners
- assertTrue("Should have been stopped " + container, container.isStopped());
+ assertTrue(container.isStopped(), "Should have been stopped " + container);
}
@Test
public void metaAnnotationIsDiscovered() throws Exception {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(Config.class, MetaAnnotationTestBean.class);
+ new AnnotationConfigApplicationContext(Config.class, MetaAnnotationTestBean.class);
try {
AzureListenerContainerTestFactory factory = context.getBean(AzureListenerContainerTestFactory.class);
- assertEquals("one container should have been registered", 1, factory.getListenerContainers().size());
+ assertEquals(1, factory.getListenerContainers().size(), "one container should have been registered");
AzureListenerEndpoint endpoint = factory.getListenerContainers().get(0).getEndpoint();
- assertEquals("Wrong endpoint type", MethodAzureListenerEndpoint.class, endpoint.getClass());
+ assertEquals(MethodAzureListenerEndpoint.class, endpoint.getClass(), "Wrong endpoint type");
MethodAzureListenerEndpoint methodEndpoint = (MethodAzureListenerEndpoint) endpoint;
assertEquals(MetaAnnotationTestBean.class, methodEndpoint.getBean().getClass());
assertEquals(MetaAnnotationTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod());
@@ -90,10 +87,9 @@ public void metaAnnotationIsDiscovered() throws Exception {
@Test
@SuppressWarnings("resource")
public void invalidProxy() {
- thrown.expect(BeanCreationException.class);
- thrown.expectCause(is(instanceOf(IllegalStateException.class)));
- thrown.expectMessage("handleIt2");
- new AnnotationConfigApplicationContext(Config.class, ProxyConfig.class, InvalidProxyTestBean.class);
+ assertThrows(BeanCreationException.class,
+ () -> new AnnotationConfigApplicationContext(Config.class, ProxyConfig.class, InvalidProxyTestBean.class),
+ "handleIt2");
}
@AzureMessageListener(destination = "metaTestQueue")
diff --git a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistrarTests.java b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistrarTests.java
index 41914aab8cc8a..7be19f67a1fce 100644
--- a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistrarTests.java
+++ b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistrarTests.java
@@ -4,27 +4,24 @@
package com.azure.spring.messaging.config;
import com.azure.spring.messaging.endpoint.SimpleAzureListenerEndpoint;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.StaticListableBeanFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.springframework.test.util.AssertionErrors.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Warren Zhu
*/
public class AzureListenerEndpointRegistrarTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
private final AzureListenerEndpointRegistrar registrar = new AzureListenerEndpointRegistrar();
private final AzureListenerEndpointRegistry registry = new AzureListenerEndpointRegistry();
private final AzureListenerContainerTestFactory containerFactory = new AzureListenerContainerTestFactory();
- @Before
+ @BeforeEach
public void setup() {
this.registrar.setEndpointRegistry(this.registry);
this.registrar.setBeanFactory(new StaticListableBeanFactory());
@@ -32,14 +29,14 @@ public void setup() {
@Test
public void registerNullEndpoint() {
- this.thrown.expect(IllegalArgumentException.class);
- this.registrar.registerEndpoint(null, this.containerFactory);
+ assertThrows(IllegalArgumentException.class,
+ () -> this.registrar.registerEndpoint(null, this.containerFactory));
}
@Test
public void registerNullEndpointId() {
- this.thrown.expect(IllegalArgumentException.class);
- this.registrar.registerEndpoint(new SimpleAzureListenerEndpoint(), this.containerFactory);
+ assertThrows(IllegalArgumentException.class,
+ () -> this.registrar.registerEndpoint(new SimpleAzureListenerEndpoint(), this.containerFactory));
}
@Test
@@ -47,8 +44,8 @@ public void registerEmptyEndpointId() {
SimpleAzureListenerEndpoint endpoint = new SimpleAzureListenerEndpoint();
endpoint.setId("");
- this.thrown.expect(IllegalArgumentException.class);
- this.registrar.registerEndpoint(endpoint, this.containerFactory);
+ assertThrows(IllegalArgumentException.class,
+ () -> this.registrar.registerEndpoint(endpoint, this.containerFactory));
}
@Test
@@ -69,9 +66,8 @@ public void registerNullContainerFactoryWithNoDefault() throws Exception {
endpoint.setId("some id");
this.registrar.registerEndpoint(endpoint, null);
- this.thrown.expect(IllegalStateException.class);
- this.thrown.expectMessage(endpoint.toString());
- this.registrar.afterPropertiesSet();
+ assertThrows(IllegalStateException.class,
+ () -> this.registrar.afterPropertiesSet(), endpoint.toString());
}
@Test
diff --git a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistryTests.java b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistryTests.java
index 137fbf6f92a99..5c72c5cd503a7 100644
--- a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistryTests.java
+++ b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/AzureListenerEndpointRegistryTests.java
@@ -5,44 +5,42 @@
import com.azure.spring.messaging.endpoint.MethodAzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.SimpleAzureListenerEndpoint;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Warren Zhu
*/
public class AzureListenerEndpointRegistryTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
private final AzureListenerEndpointRegistry registry = new AzureListenerEndpointRegistry();
private final AzureListenerContainerTestFactory containerFactory = new AzureListenerContainerTestFactory();
@Test
public void createWithNullEndpoint() {
- thrown.expect(IllegalArgumentException.class);
- registry.registerListenerContainer(null, containerFactory);
+ assertThrows(IllegalArgumentException.class,
+ () -> registry.registerListenerContainer(null, containerFactory));
}
@Test
public void createWithNullEndpointId() {
- thrown.expect(IllegalArgumentException.class);
- registry.registerListenerContainer(new MethodAzureListenerEndpoint(), containerFactory);
+ assertThrows(IllegalArgumentException.class,
+ () -> registry.registerListenerContainer(new MethodAzureListenerEndpoint(), containerFactory));
}
@Test
public void createWithNullContainerFactory() {
- thrown.expect(IllegalArgumentException.class);
- registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null);
+ assertThrows(IllegalArgumentException.class,
+ () -> registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null));
}
@Test
public void createWithDuplicateEndpointId() {
registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
- thrown.expect(IllegalStateException.class);
- registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
+ assertThrows(IllegalStateException.class,
+ () -> registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory));
}
private SimpleAzureListenerEndpoint createEndpoint(String id, String destinationName) {
diff --git a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/EnableAzureMessagingTests.java b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/EnableAzureMessagingTests.java
index efedf66d9c5ba..bc1d19353dcde 100644
--- a/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/EnableAzureMessagingTests.java
+++ b/sdk/spring/azure-spring-cloud-messaging/src/test/java/com/azure/spring/messaging/config/EnableAzureMessagingTests.java
@@ -3,16 +3,14 @@
package com.azure.spring.messaging.config;
-import com.azure.spring.messaging.endpoint.MethodAzureListenerEndpoint;
-import com.azure.spring.messaging.listener.AzureMessageHandler;
-import com.azure.spring.messaging.listener.DefaultAzureMessageHandler;
import com.azure.spring.integration.core.api.SubscribeByGroupOperation;
import com.azure.spring.messaging.annotation.AzureMessageListener;
import com.azure.spring.messaging.annotation.EnableAzureMessaging;
+import com.azure.spring.messaging.endpoint.MethodAzureListenerEndpoint;
import com.azure.spring.messaging.endpoint.SimpleAzureListenerEndpoint;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import com.azure.spring.messaging.listener.AzureMessageHandler;
+import com.azure.spring.messaging.listener.DefaultAzureMessageHandler;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -25,7 +23,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
@@ -33,14 +35,12 @@
*/
public class EnableAzureMessagingTests extends AbstractAzureMessagingAnnotationDrivenTests {
- @Rule
- public final ExpectedException thrown = ExpectedException.none();
@Override
@Test
public void sampleConfiguration() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingSampleConfig.class, SampleBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingSampleConfig.class, SampleBean.class);
testSampleConfiguration(context);
}
@@ -48,7 +48,7 @@ public void sampleConfiguration() {
@Test
public void fullConfiguration() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingFullConfig.class, FullBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingFullConfig.class, FullBean.class);
testFullConfiguration(context);
}
@@ -61,7 +61,7 @@ public void fullConfigurableConfiguration() {
@Test
public void customConfiguration() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingCustomConfig.class, CustomBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingCustomConfig.class, CustomBean.class);
testCustomConfiguration(context);
}
@@ -69,8 +69,8 @@ public void customConfiguration() {
@Test
public void explicitContainerFactory() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingCustomContainerFactoryConfig.class,
- DefaultBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingCustomContainerFactoryConfig.class,
+ DefaultBean.class);
testExplicitContainerFactoryConfiguration(context);
}
@@ -78,16 +78,16 @@ public void explicitContainerFactory() {
@Test
public void defaultContainerFactory() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
- DefaultBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
+ DefaultBean.class);
testDefaultContainerFactoryConfiguration(context);
}
@Test
public void containerAreStartedByDefault() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
- DefaultBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
+ DefaultBean.class);
AzureListenerContainerTestFactory factory = context.getBean(AzureListenerContainerTestFactory.class);
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
assertTrue(container.isAutoStartup());
@@ -97,8 +97,8 @@ public void containerAreStartedByDefault() {
@Test
public void containerCanBeStarterViaTheRegistry() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingAutoStartupFalseConfig.class,
- DefaultBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingAutoStartupFalseConfig.class,
+ DefaultBean.class);
AzureListenerContainerTestFactory factory = context.getBean(AzureListenerContainerTestFactory.class);
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
assertFalse(container.isAutoStartup());
@@ -112,8 +112,8 @@ public void containerCanBeStarterViaTheRegistry() {
@Test
public void azureMessageListenerIsRepeatable() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
- AzureListenerRepeatableBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
+ AzureListenerRepeatableBean.class);
testAzureListenerRepeatable(context);
}
@@ -121,28 +121,28 @@ public void azureMessageListenerIsRepeatable() {
@Test
public void azureMessageListeners() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
- AzureListenersBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
+ AzureListenersBean.class);
testAzureListenerRepeatable(context);
}
@Test
public void composedAzureMessageListeners() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
- EnableAzureMessagingDefaultContainerFactoryConfig.class, ComposedAzureMessageListenersBean.class)) {
+ EnableAzureMessagingDefaultContainerFactoryConfig.class, ComposedAzureMessageListenersBean.class)) {
AzureListenerContainerTestFactory simpleFactory = context.getBean(
- AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
- AzureListenerContainerTestFactory.class);
+ AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
+ AzureListenerContainerTestFactory.class);
assertEquals(2, simpleFactory.getListenerContainers().size());
MethodAzureListenerEndpoint first =
- (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("first").getEndpoint();
+ (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("first").getEndpoint();
assertEquals("first", first.getId());
assertEquals("orderQueue", first.getDestination());
assertNull(first.getConcurrency());
MethodAzureListenerEndpoint second =
- (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint();
+ (MethodAzureListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint();
assertEquals("second", second.getId());
assertEquals("billingQueue", second.getDestination());
assertEquals("2-10", second.getConcurrency());
@@ -152,27 +152,27 @@ public void composedAzureMessageListeners() {
@Test
@SuppressWarnings("resource")
public void unknownFactory() {
- thrown.expect(BeanCreationException.class);
- thrown.expectMessage("customFactory"); // not found
- new AnnotationConfigApplicationContext(EnableAzureMessagingSampleConfig.class, CustomBean.class);
+ assertThrows(BeanCreationException.class,
+ () -> new AnnotationConfigApplicationContext(EnableAzureMessagingSampleConfig.class, CustomBean.class),
+ "customFactory");
}
@Test
public void lazyComponent() {
ConfigurableApplicationContext context =
- new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
- LazyBean.class);
+ new AnnotationConfigApplicationContext(EnableAzureMessagingDefaultContainerFactoryConfig.class,
+ LazyBean.class);
AzureListenerContainerTestFactory defaultFactory = context.getBean(
- AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
- AzureListenerContainerTestFactory.class);
+ AzureListenerAnnotationBeanPostProcessor.DEFAULT_AZURE_LISTENER_CONTAINER_FACTORY_BEAN_NAME,
+ AzureListenerContainerTestFactory.class);
assertEquals(0, defaultFactory.getListenerContainers().size());
context.getBean(LazyBean.class); // trigger lazy resolution
assertEquals(1, defaultFactory.getListenerContainers().size());
MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
- assertTrue("Should have been started " + container, container.isStarted());
+ assertTrue(container.isStarted(), "Should have been started " + container);
context.close(); // close and stop the listeners
- assertTrue("Should have been stopped " + container, container.isStopped());
+ assertTrue(container.isStopped(), "Should have been stopped " + container);
}
@AzureMessageListener(destination = "orderQueue")
diff --git a/sdk/spring/azure-spring-cloud-starter-eventhubs/pom.xml b/sdk/spring/azure-spring-cloud-starter-eventhubs/pom.xml
index b2f25f31be14a..087f4256647e8 100644
--- a/sdk/spring/azure-spring-cloud-starter-eventhubs/pom.xml
+++ b/sdk/spring/azure-spring-cloud-starter-eventhubs/pom.xml
@@ -31,7 +31,6 @@
azure-spring-cloud-messaging
2.6.0-beta.1
-
diff --git a/sdk/spring/azure-spring-cloud-storage/pom.xml b/sdk/spring/azure-spring-cloud-storage/pom.xml
index b4cce90e88f88..11916e74c15a3 100644
--- a/sdk/spring/azure-spring-cloud-storage/pom.xml
+++ b/sdk/spring/azure-spring-cloud-storage/pom.xml
@@ -75,34 +75,6 @@
test
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
-
-
- org.mockito
- mockito-core
- 3.9.0
- test
-
-
-
- org.powermock
- powermock-api-mockito2
- 2.0.2
- test
-
-
-
- org.powermock
- powermock-module-junit4
- 2.0.2
- test
-
-
diff --git a/sdk/spring/azure-spring-cloud-storage/src/test/java/com/azure/spring/cloud/autoconfigure/storage/AzureStorageQueueAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-storage/src/test/java/com/azure/spring/cloud/autoconfigure/storage/AzureStorageQueueAutoConfigurationTest.java
index 14a25e5498c94..df9bd4dd335ea 100644
--- a/sdk/spring/azure-spring-cloud-storage/src/test/java/com/azure/spring/cloud/autoconfigure/storage/AzureStorageQueueAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-storage/src/test/java/com/azure/spring/cloud/autoconfigure/storage/AzureStorageQueueAutoConfigurationTest.java
@@ -5,7 +5,7 @@
import com.azure.spring.integration.storage.queue.factory.DefaultStorageQueueClientFactory;
import com.azure.storage.queue.QueueServiceClient;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@@ -14,6 +14,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AzureStorageQueueAutoConfigurationTest {
@@ -25,19 +26,20 @@ public class AzureStorageQueueAutoConfigurationTest {
@Test
public void testAzureStorageDisabled() {
this.contextRunner.withPropertyValues("spring.cloud.azure.storage.queue.enabled=false")
- .run(context -> assertThat(context).doesNotHaveBean(AzureStorageProperties.class));
+ .run(context -> assertThat(context).doesNotHaveBean(AzureStorageProperties.class));
}
@Test
public void testWithoutCloudQueueClient() {
this.contextRunner.withClassLoader(new FilteredClassLoader(QueueServiceClient.class))
- .run(context -> assertThat(context).doesNotHaveBean(AzureStorageProperties.class));
+ .run(context -> assertThat(context).doesNotHaveBean(AzureStorageProperties.class));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAzureStoragePropertiesIllegal() {
this.contextRunner.withPropertyValues("spring.cloud.azure.storage.account=a")
- .run(context -> context.getBean(AzureStorageProperties.class));
+ .run(context -> assertThrows(IllegalStateException.class,
+ () -> context.getBean(AzureStorageProperties.class)));
}
@Test
diff --git a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubBinderHealthIndicatorTest.java b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubBinderHealthIndicatorTest.java
index 153c99b1ff7a9..08569fa911252 100644
--- a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubBinderHealthIndicatorTest.java
+++ b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubBinderHealthIndicatorTest.java
@@ -6,8 +6,9 @@
import com.azure.messaging.eventhubs.EventHubProducerAsyncClient;
import com.azure.messaging.eventhubs.EventHubProperties;
import com.azure.spring.integration.eventhub.api.EventHubClientFactory;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.actuate.health.Health;
@@ -35,7 +36,7 @@ public class EventHubBinderHealthIndicatorTest {
private EventHubHealthIndicator healthIndicator;
- @Before
+ @BeforeEach
public void init() {
MockitoAnnotations.openMocks(this);
when(clientFactory.getOrCreateProducerClient(anyString())).thenReturn(producerAsyncClient);
@@ -75,7 +76,8 @@ public void testEventHubIsDown() {
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
- @Test(timeout = 5000)
+ @Test
+ @Timeout(5)
public void testGetEventHubInfoTimeout() {
healthIndicator.setTimeout(1);
diff --git a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubMessageChannelBinderTest.java b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubMessageChannelBinderTest.java
index 871dc2008d5e1..2e1264d854b28 100644
--- a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubMessageChannelBinderTest.java
+++ b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubMessageChannelBinderTest.java
@@ -10,8 +10,8 @@
import com.azure.spring.integration.eventhub.api.EventHubClientFactory;
import com.azure.spring.integration.eventhub.support.EventHubTestOperation;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.cloud.stream.binder.ExtendedProducerProperties;
import org.springframework.cloud.stream.provisioning.ProducerDestination;
@@ -42,7 +42,7 @@ public class EventHubMessageChannelBinderTest {
private static final String PARTITION_HEADER = "headers['scst_partition']";
- @Before
+ @BeforeEach
public void setUp() {
this.binder = new EventHubTestBinder(new EventHubTestOperation(clientFactory, () -> eventContext));
this.producerProperties = new ExtendedProducerProperties<>(new EventHubProducerProperties());
diff --git a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubPartitionBinderTests.java b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubPartitionBinderTests.java
index e236156dc708d..bd78d49b63bd6 100644
--- a/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubPartitionBinderTests.java
+++ b/sdk/spring/azure-spring-cloud-stream-binder-eventhubs/src/test/java/com/azure/spring/eventhub/stream/binder/EventHubPartitionBinderTests.java
@@ -3,20 +3,17 @@
package com.azure.spring.eventhub.stream.binder;
-import com.azure.spring.eventhub.stream.binder.properties.EventHubProducerProperties;
import com.azure.messaging.eventhubs.models.EventContext;
import com.azure.messaging.eventhubs.models.PartitionContext;
import com.azure.spring.eventhub.stream.binder.properties.EventHubConsumerProperties;
-import com.azure.spring.servicebus.stream.binder.test.AzurePartitionBinderTests;
+import com.azure.spring.eventhub.stream.binder.properties.EventHubProducerProperties;
import com.azure.spring.integration.core.api.StartPosition;
import com.azure.spring.integration.eventhub.api.EventHubClientFactory;
import com.azure.spring.integration.eventhub.support.EventHubTestOperation;
+import com.azure.spring.servicebus.stream.binder.test.AzurePartitionBinderTests;
import org.junit.Before;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.cloud.stream.binder.ExtendedConsumerProperties;
import org.springframework.cloud.stream.binder.ExtendedProducerProperties;
import org.springframework.cloud.stream.binder.HeaderMode;
@@ -29,12 +26,10 @@
*
* @author Warren Zhu
*/
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
-@PrepareForTest(EventContext.class)
public class EventHubPartitionBinderTests extends
- AzurePartitionBinderTests,
- ExtendedProducerProperties> {
+ AzurePartitionBinderTests,
+ ExtendedProducerProperties> {
+ //TODO (Xiaobing Zhu): It is currently impossible to upgrade JUnit 4 to JUnit 5 due to the inheritance of Spring unit tests.
@Mock
EventHubClientFactory clientFactory;
@@ -45,11 +40,11 @@ public class EventHubPartitionBinderTests extends
@Mock
PartitionContext partitionContext;
-
private EventHubTestBinder binder;
@Before
public void setUp() {
+ MockitoAnnotations.openMocks(this);
when(this.eventContext.updateCheckpointAsync()).thenReturn(Mono.empty());
when(this.eventContext.getPartitionContext()).thenReturn(this.partitionContext);
when(this.partitionContext.getPartitionId()).thenReturn("1");
@@ -70,7 +65,7 @@ protected EventHubTestBinder getBinder() throws Exception {
@Override
protected ExtendedConsumerProperties createConsumerProperties() {
ExtendedConsumerProperties properties =
- new ExtendedConsumerProperties<>(new EventHubConsumerProperties());
+ new ExtendedConsumerProperties<>(new EventHubConsumerProperties());
properties.setHeaderMode(HeaderMode.embeddedHeaders);
properties.getExtension().setStartPosition(StartPosition.EARLIEST);
return properties;
@@ -79,7 +74,7 @@ protected ExtendedConsumerProperties createConsumerP
@Override
protected ExtendedProducerProperties createProducerProperties() {
ExtendedProducerProperties properties =
- new ExtendedProducerProperties<>(new EventHubProducerProperties());
+ new ExtendedProducerProperties<>(new EventHubProducerProperties());
properties.setHeaderMode(HeaderMode.embeddedHeaders);
return properties;
}
diff --git a/sdk/spring/azure-spring-cloud-stream-binder-servicebus-queue/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusQueuePartitionBinderTests.java b/sdk/spring/azure-spring-cloud-stream-binder-servicebus-queue/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusQueuePartitionBinderTests.java
index 4baedd201f3ee..3c99e26dece5a 100644
--- a/sdk/spring/azure-spring-cloud-stream-binder-servicebus-queue/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusQueuePartitionBinderTests.java
+++ b/sdk/spring/azure-spring-cloud-stream-binder-servicebus-queue/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusQueuePartitionBinderTests.java
@@ -26,6 +26,7 @@ public class ServiceBusQueuePartitionBinderTests
extends AzurePartitionBinderTests,
ExtendedProducerProperties> {
+ //TODO (Xiaobing Zhu): It is currently impossible to upgrade JUnit 4 to JUnit 5 due to the inheritance of Spring unit tests.
@Mock
ServiceBusQueueClientFactory clientFactory;
diff --git a/sdk/spring/azure-spring-cloud-stream-binder-servicebus-topic/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusTopicPartitionBinderTests.java b/sdk/spring/azure-spring-cloud-stream-binder-servicebus-topic/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusTopicPartitionBinderTests.java
index 1afbb985fa16a..1de3436d94e07 100644
--- a/sdk/spring/azure-spring-cloud-stream-binder-servicebus-topic/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusTopicPartitionBinderTests.java
+++ b/sdk/spring/azure-spring-cloud-stream-binder-servicebus-topic/src/test/java/com/azure/spring/servicebus/stream/binder/ServiceBusTopicPartitionBinderTests.java
@@ -27,6 +27,8 @@ public class ServiceBusTopicPartitionBinderTests
ExtendedConsumerProperties,
ExtendedProducerProperties> {
+ //TODO (Xiaobing Zhu): It is currently impossible to upgrade JUnit 4 to JUnit 5 due to the inheritance of Spring unit tests.
+
@Mock
ServiceBusTopicClientFactory clientFactory;
diff --git a/sdk/spring/azure-spring-cloud-telemetry/pom.xml b/sdk/spring/azure-spring-cloud-telemetry/pom.xml
index b7f361d4e66e4..8d1054c6601dc 100644
--- a/sdk/spring/azure-spring-cloud-telemetry/pom.xml
+++ b/sdk/spring/azure-spring-cloud-telemetry/pom.xml
@@ -60,12 +60,6 @@
2.5.0
test
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
diff --git a/sdk/spring/azure-spring-cloud-telemetry/src/test/java/com/azure/spring/cloud/autoconfigure/telemetry/TelemetryAutoConfigurationTest.java b/sdk/spring/azure-spring-cloud-telemetry/src/test/java/com/azure/spring/cloud/autoconfigure/telemetry/TelemetryAutoConfigurationTest.java
index 575aa35a5ccb2..a0a5f6a3ce05a 100644
--- a/sdk/spring/azure-spring-cloud-telemetry/src/test/java/com/azure/spring/cloud/autoconfigure/telemetry/TelemetryAutoConfigurationTest.java
+++ b/sdk/spring/azure-spring-cloud-telemetry/src/test/java/com/azure/spring/cloud/autoconfigure/telemetry/TelemetryAutoConfigurationTest.java
@@ -7,7 +7,7 @@
import com.azure.spring.cloud.telemetry.TelemetryProperties;
import com.azure.spring.cloud.telemetry.TelemetrySender;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
diff --git a/sdk/spring/azure-spring-cloud-test-eventhubs/pom.xml b/sdk/spring/azure-spring-cloud-test-eventhubs/pom.xml
index c7474240c24be..ffefb6c5b99cd 100644
--- a/sdk/spring/azure-spring-cloud-test-eventhubs/pom.xml
+++ b/sdk/spring/azure-spring-cloud-test-eventhubs/pom.xml
@@ -42,12 +42,6 @@
org.springframework.boot
spring-boot-starter-actuator
-
- junit
- junit
- 4.13.2
- test
-
com.google.code.gson
gson
@@ -58,18 +52,6 @@
azure-spring-cloud-stream-binder-test
2.6.0-beta.1
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.2
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
- test
-
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/DefaultEventHubClientFactoryTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/DefaultEventHubClientFactoryTest.java
index 1eaad2325405a..247acda80ea70 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/DefaultEventHubClientFactoryTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/DefaultEventHubClientFactoryTest.java
@@ -22,15 +22,21 @@
import java.util.Optional;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.*;
@RunWith(PowerMockRunner.class)
-@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
-@PrepareForTest({DefaultEventHubClientFactory.class})
+@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" })
+@PrepareForTest({ DefaultEventHubClientFactory.class })
public class DefaultEventHubClientFactoryTest {
+ //TODO (Xiaobing Zhu): Due to Powermock, it is currently impossible to upgrade JUnit 4 to JUnit 5.
@Mock
EventHubConsumerAsyncClient eventHubConsumerClient;
@@ -134,8 +140,8 @@ public void testGetOrCreateEventProcessorClient() throws Exception {
assertNotNull(client);
clientFactory.createEventProcessorClient(eventHubName, consumerGroup, eventHubProcessor);
- verifyPrivate(clientFactory).invoke("createEventProcessorClientInternal", eventHubName, consumerGroup,
- eventHubProcessor);
+ verifyPrivate(clientFactory, times(1))
+ .invoke("createEventProcessorClientInternal", eventHubName, consumerGroup, eventHubProcessor);
}
@Test
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubOperationSendSubscribeTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubOperationSendSubscribeTest.java
index 51abd0205821b..63ef08c7107af 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubOperationSendSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubOperationSendSubscribeTest.java
@@ -14,18 +14,21 @@
import com.azure.spring.integration.eventhub.support.EventHubTestOperation;
import com.azure.spring.integration.test.support.pojo.User;
import com.azure.spring.integration.test.support.reactor.SendSubscribeByGroupOperationTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.messaging.Message;
import reactor.core.publisher.Mono;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class EventHubOperationSendSubscribeTest extends SendSubscribeByGroupOperationTest {
@Mock
@@ -34,9 +37,12 @@ public class EventHubOperationSendSubscribeTest extends SendSubscribeByGroupOper
@Mock
PartitionContext partitionContext;
- @Before
+ private AutoCloseable closeable;
+
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
when(this.eventContext.updateCheckpointAsync()).thenReturn(Mono.empty());
when(this.eventContext.getPartitionContext()).thenReturn(this.partitionContext);
when(this.partitionContext.getPartitionId()).thenReturn(this.partitionId);
@@ -44,6 +50,11 @@ public void setUp() {
this.sendSubscribeOperation = new EventHubTestOperation(null, () -> eventContext);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifyCheckpointSuccessCalled(int times) {
verify(this.eventContext, times(times)).updateCheckpointAsync();
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubRxOperationSendSubscribeTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubRxOperationSendSubscribeTest.java
index ab459e220d92c..460944c361391 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubRxOperationSendSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubRxOperationSendSubscribeTest.java
@@ -12,18 +12,19 @@
import com.azure.spring.integration.eventhub.support.RxEventHubTestOperation;
import com.azure.spring.integration.test.support.pojo.User;
import com.azure.spring.integration.test.support.rx.RxSendSubscribeByGroupOperationTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Mono;
import java.util.Arrays;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class EventHubRxOperationSendSubscribeTest extends RxSendSubscribeByGroupOperationTest {
@Mock
@@ -32,9 +33,12 @@ public class EventHubRxOperationSendSubscribeTest extends RxSendSubscribeByGroup
@Mock
PartitionContext partitionContext;
- @Before
+ private AutoCloseable closeable;
+
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
when(this.eventContext.updateCheckpointAsync()).thenReturn(Mono.empty());
when(this.eventContext.getPartitionContext()).thenReturn(this.partitionContext);
when(this.partitionContext.getPartitionId()).thenReturn(this.partitionId);
@@ -42,6 +46,11 @@ public void setUp() {
this.sendSubscribeOperation = new RxEventHubTestOperation(null, () -> eventContext);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifyCheckpointSuccessCalled(int times) {
verify(this.eventContext, times(times)).updateCheckpointAsync();
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSendTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSendTest.java
index 257f674c97c56..7296c4e4bc5d5 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSendTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSendTest.java
@@ -12,28 +12,33 @@
import com.azure.spring.integration.eventhub.impl.EventHubRuntimeException;
import com.azure.spring.integration.eventhub.impl.EventHubTemplate;
import com.azure.spring.integration.test.support.reactor.SendOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
-@RunWith(MockitoJUnitRunner.class)
public class EventHubTemplateSendTest extends SendOperationTest {
@Mock
EventDataBatch eventDataBatch;
@Mock
- private EventHubClientFactory mockClientFactory;
+ EventHubClientFactory mockClientFactory;
@Mock
- private EventHubProducerAsyncClient mockProducerClient;
+ EventHubProducerAsyncClient mockProducerClient;
+
+ private AutoCloseable closeable;
- @Before
+ @BeforeEach
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
when(this.mockClientFactory.getOrCreateProducerClient(eq(this.destination)))
.thenReturn(this.mockProducerClient);
when(this.mockProducerClient.createBatch(any(CreateBatchOptions.class)))
@@ -44,6 +49,11 @@ public void setUp() {
this.sendOperation = new EventHubTemplate(mockClientFactory);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifySendCalled(int times) {
verify(this.mockProducerClient, times(times)).send(any(EventDataBatch.class));
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSubscribeTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSubscribeTest.java
index abc4c696be690..4e5bf48a71e6e 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/EventHubTemplateSubscribeTest.java
@@ -9,18 +9,22 @@
import com.azure.spring.integration.eventhub.impl.EventHubProcessor;
import com.azure.spring.integration.eventhub.impl.EventHubTemplate;
import com.azure.spring.integration.test.support.SubscribeByGroupOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import java.util.Optional;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class EventHubTemplateSubscribeTest extends SubscribeByGroupOperationTest {
@Mock
@@ -29,8 +33,11 @@ public class EventHubTemplateSubscribeTest extends SubscribeByGroupOperationTest
@Mock
private EventProcessorClient eventProcessorClient;
- @Before
+ private AutoCloseable closeable;
+
+ @BeforeEach
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.subscribeByGroupOperation = new EventHubTemplate(mockClientFactory);
when(this.mockClientFactory.createEventProcessorClient(anyString(), anyString(), isA(EventHubProcessor.class)))
.thenReturn(this.eventProcessorClient);
@@ -40,6 +47,11 @@ public void setUp() {
doNothing().when(this.eventProcessorClient).start();
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifySubscriberCreatorCalled() {
verify(this.mockClientFactory, atLeastOnce()).createEventProcessorClient(anyString(), anyString(),
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/converter/EventHubMessageConverterTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/converter/EventHubMessageConverterTest.java
index 25d559f07fc7a..aecbecba6b5a8 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/converter/EventHubMessageConverterTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/converter/EventHubMessageConverterTest.java
@@ -7,7 +7,7 @@
import com.azure.spring.integration.core.EventHubHeaders;
import com.azure.spring.integration.core.converter.AzureMessageConverter;
import com.azure.spring.integration.test.support.UnaryAzureMessageConverterTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.LinkedMultiValueMap;
@@ -18,9 +18,9 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.messaging.support.NativeMessageHeaderAccessor.NATIVE_HEADERS;
public class EventHubMessageConverterTest extends UnaryAzureMessageConverterTest {
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/inbound/EventHubInboundAdapterTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/inbound/EventHubInboundAdapterTest.java
index 10e76dedbc4ec..c5904098a9a14 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/inbound/EventHubInboundAdapterTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/inbound/EventHubInboundAdapterTest.java
@@ -7,11 +7,11 @@
import com.azure.messaging.eventhubs.models.EventContext;
import com.azure.spring.integration.eventhub.support.EventHubTestOperation;
import com.azure.spring.integration.test.support.InboundChannelAdapterTest;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class EventHubInboundAdapterTest extends InboundChannelAdapterTest {
@Mock
@@ -20,10 +20,19 @@ public class EventHubInboundAdapterTest extends InboundChannelAdapterTest partitionContext),
- consumerGroup);
+ () -> partitionContext),
+ consumerGroup);
+ }
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
}
}
diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/outbound/EventHubMessageHandlerTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/outbound/EventHubMessageHandlerTest.java
index 4995cc63dbef3..a461f3f1a5a1e 100644
--- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/outbound/EventHubMessageHandlerTest.java
+++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhub/outbound/EventHubMessageHandlerTest.java
@@ -9,11 +9,11 @@
import com.azure.spring.integration.eventhub.api.EventHubOperation;
import com.azure.spring.integration.test.support.reactor.MessageHandlerTest;
import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
@@ -31,7 +31,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class EventHubMessageHandlerTest extends MessageHandlerTest {
private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
@@ -42,11 +41,13 @@ public class EventHubMessageHandlerTest extends MessageHandlerTest {
- @Before
+
+ private AutoCloseable closeable;
+
+
+ @BeforeEach
@Override
@SuppressWarnings("unchecked")
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.future.complete(null);
this.sendOperation = mock(ServiceBusQueueOperation.class);
when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class),
@@ -33,4 +37,10 @@ public void setUp() {
.thenReturn(future);
this.handler = new DefaultMessageHandler(this.destination, this.sendOperation);
}
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/ServiceBusTemplateSendTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/ServiceBusTemplateSendTest.java
index 34ac0968d6128..80c865ddb5223 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/ServiceBusTemplateSendTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/ServiceBusTemplateSendTest.java
@@ -8,7 +8,7 @@
import com.azure.spring.integration.core.api.SendOperation;
import com.azure.spring.integration.servicebus.factory.ServiceBusSenderFactory;
import com.azure.spring.integration.test.support.SendOperationTest;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import reactor.core.publisher.Mono;
import static org.mockito.ArgumentMatchers.anyString;
@@ -30,7 +30,7 @@ public abstract class ServiceBusTemplateSendTest this.messageConverter.toMessage(this.receivedMessage, byte[].class));
}
@Test
@@ -168,8 +176,8 @@ public void testConvertSpringNativeMessageHeaders() {
@Test
public void testAzureMessageHeader() {
Message springMessage = MessageBuilder.withPayload(PAYLOAD)
- .setHeader(AzureHeaders.RAW_ID, AZURE_MESSAGE_RAW_ID)
- .build();
+ .setHeader(AzureHeaders.RAW_ID, AZURE_MESSAGE_RAW_ID)
+ .build();
ServiceBusMessage serviceBusMessage = this.messageConverter.fromMessage(springMessage, ServiceBusMessage.class);
@@ -188,21 +196,22 @@ public void testAzureMessageHeader() {
public void testServiceBusMessageHeadersSet() {
Instant scheduledEnqueueInstant = Instant.now().plusSeconds(5);
final OffsetDateTime scheduledEnqueueOffsetDateTime = OffsetDateTime
- .ofInstant(scheduledEnqueueInstant, systemDefault())
- .toInstant()
- .atOffset(ZoneOffset.UTC);
+ .ofInstant(scheduledEnqueueInstant, systemDefault())
+ .toInstant()
+ .atOffset(ZoneOffset.UTC);
Message springMessage = MessageBuilder.withPayload(PAYLOAD)
- .setHeader(AzureHeaders.RAW_ID, AZURE_MESSAGE_RAW_ID)
- .setHeader(MESSAGE_ID, SERVICE_BUS_MESSAGE_ID)
- .setHeader(TIME_TO_LIVE, SERVICE_BUS_TTL)
- .setHeader(SCHEDULED_ENQUEUE_TIME, scheduledEnqueueInstant)
- .setHeader(SESSION_ID, SERVICE_BUS_SESSION_ID)
- .setHeader(CORRELATION_ID, SERVICE_BUS_CORRELATION_ID)
- .setHeader(TO, SERVICE_BUS_TO)
- .setHeader(REPLY_TO_SESSION_ID, SERVICE_BUS_REPLY_TO_SESSION_ID)
- .setHeader(PARTITION_KEY, SERVICE_BUS_SESSION_ID) // when session id set, the partition key equals to session id
- .build();
+ .setHeader(AzureHeaders.RAW_ID, AZURE_MESSAGE_RAW_ID)
+ .setHeader(MESSAGE_ID, SERVICE_BUS_MESSAGE_ID)
+ .setHeader(TIME_TO_LIVE, SERVICE_BUS_TTL)
+ .setHeader(SCHEDULED_ENQUEUE_TIME, scheduledEnqueueInstant)
+ .setHeader(SESSION_ID, SERVICE_BUS_SESSION_ID)
+ .setHeader(CORRELATION_ID, SERVICE_BUS_CORRELATION_ID)
+ .setHeader(TO, SERVICE_BUS_TO)
+ .setHeader(REPLY_TO_SESSION_ID, SERVICE_BUS_REPLY_TO_SESSION_ID)
+ .setHeader(PARTITION_KEY, SERVICE_BUS_SESSION_ID) // when
+ // session id set, the partition key equals to session id
+ .build();
ServiceBusMessage serviceBusMessage = this.messageConverter.fromMessage(springMessage, ServiceBusMessage.class);
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSendTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSendTest.java
index 5bf0845091b57..0901841df7378 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSendTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSendTest.java
@@ -8,22 +8,24 @@
import com.azure.spring.integration.servicebus.ServiceBusTemplateSendTest;
import com.azure.spring.integration.servicebus.converter.ServiceBusMessageConverter;
import com.azure.spring.integration.servicebus.factory.ServiceBusQueueClientFactory;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.mockito.MockitoAnnotations;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class QueueTemplateSendTest
extends ServiceBusTemplateSendTest {
- @Before
+ private AutoCloseable closeable;
+
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.mockClientFactory = mock(ServiceBusQueueClientFactory.class);
this.mockClient = mock(ServiceBusSenderAsyncClient.class);
@@ -32,4 +34,11 @@ public void setUp() {
this.sendOperation = new ServiceBusQueueTemplate(mockClientFactory, new ServiceBusMessageConverter());
}
+
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSubscribeTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSubscribeTest.java
index 263cec4ac3005..2b0652dffb3c2 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/QueueTemplateSubscribeTest.java
@@ -8,12 +8,12 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusQueueClientFactory;
import com.azure.spring.integration.servicebus.support.ServiceBusProcessorClientWrapper;
import com.azure.spring.integration.test.support.SubscribeOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -22,7 +22,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class QueueTemplateSubscribeTest extends SubscribeOperationTest {
@Mock
@@ -30,13 +29,20 @@ public class QueueTemplateSubscribeTest extends SubscribeOperationTest {
@Mock
ServiceBusQueueClientFactory clientFactory;
+ private AutoCloseable closeable;
+
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.adapter = new ServiceBusQueueInboundChannelAdapter(destination,
new ServiceBusQueueTestOperation(clientFactory));
}
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationDeadLetterQueueTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationDeadLetterQueueTest.java
index 0c7157b031663..e90b7076ed7e9 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationDeadLetterQueueTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationDeadLetterQueueTest.java
@@ -6,13 +6,25 @@
import com.azure.spring.integration.core.api.CheckpointConfig;
import com.azure.spring.integration.core.api.CheckpointMode;
import com.azure.spring.integration.test.support.pojo.User;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class ServiceBusQueueOperationDeadLetterQueueTest extends ServiceBusQueueOperationSendSubscribeTest {
+ private AutoCloseable closeable;
+
+ @BeforeEach
+ public void setup() {
+ this.closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Test
public void testSendDeadLetterQueueWithoutManualCheckpointModel() {
subscribe(destination, m -> sendSubscribeOperation.deadLetter(destination, m, "reason", "desc"), User.class);
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationSendSubscribeTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationSendSubscribeTest.java
index 272272860c2a5..14d8126fa7cd1 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationSendSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/queue/ServiceBusQueueOperationSendSubscribeTest.java
@@ -7,30 +7,38 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusQueueClientFactory;
import com.azure.spring.integration.servicebus.support.ServiceBusQueueTestOperation;
import com.azure.spring.integration.test.support.SendSubscribeWithoutGroupOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.messaging.Message;
import static com.azure.spring.integration.servicebus.converter.ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
-@RunWith(MockitoJUnitRunner.class)
public class ServiceBusQueueOperationSendSubscribeTest
extends SendSubscribeWithoutGroupOperationTest {
+ private AutoCloseable closeable;
+
@Mock
ServiceBusQueueClientFactory clientFactory;
- @Before
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.sendSubscribeOperation = new ServiceBusQueueTestOperation(clientFactory);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifyCheckpointSuccessCalled(int times) {
verifyCompleteCalledTimes(times);
@@ -51,7 +59,7 @@ protected void manualCheckpointHandler(Message> message) {
assertTrue(message.getHeaders().containsKey(RECEIVED_MESSAGE_CONTEXT));
final ServiceBusReceivedMessageContext receivedMessageContext = message.getHeaders()
.get(RECEIVED_MESSAGE_CONTEXT,
- ServiceBusReceivedMessageContext.class);
+ ServiceBusReceivedMessageContext.class);
assertNotNull(receivedMessageContext);
receivedMessageContext.complete();
@@ -65,20 +73,20 @@ protected void manualCheckpointHandler(Message> message) {
}
protected void verifyCompleteCalledTimes(int times) {
- waitMillis(25);
+ waitMillis(250);
final int actualTimes = ((ServiceBusQueueTestOperation) sendSubscribeOperation).getCompleteCalledTimes();
if (actualTimes != times) {
- assertEquals("Complete called times", times, actualTimes);
+ assertEquals(times, actualTimes, "Complete called times");
}
}
protected void verifyAbandonCalledTimes(int times) {
- waitMillis(25);
+ waitMillis(250);
final int actualTimes = ((ServiceBusQueueTestOperation) sendSubscribeOperation).getCompleteCalledTimes();
if (actualTimes != times) {
- assertEquals("Complete called times", times, actualTimes);
+ assertEquals(times, actualTimes, "Complete called times");
}
}
@@ -86,7 +94,7 @@ protected void verifyDeadLetterCalledTimes(int times) {
final int actualTimes = ((ServiceBusQueueTestOperation) sendSubscribeOperation).getDeadLetterCalledTimes();
if (actualTimes != times) {
- assertEquals("Complete called times", times, actualTimes);
+ assertEquals(times, actualTimes, "Complete called times");
}
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicInboundAdapterTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicInboundAdapterTest.java
index 884d50c3bbfc3..4454c9b862759 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicInboundAdapterTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicInboundAdapterTest.java
@@ -7,18 +7,26 @@
import com.azure.spring.integration.servicebus.inbound.ServiceBusTopicInboundChannelAdapter;
import com.azure.spring.integration.servicebus.support.ServiceBusTopicTestOperation;
import com.azure.spring.integration.test.support.InboundChannelAdapterTest;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-@RunWith(MockitoJUnitRunner.class)
public class ServiceBusTopicInboundAdapterTest extends InboundChannelAdapterTest {
@Mock
ServiceBusTopicClientFactory clientFactory;
+ private AutoCloseable closeable;
+
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.adapter = new ServiceBusTopicInboundChannelAdapter(destination,
new ServiceBusTopicTestOperation(clientFactory),
consumerGroup);
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicOperationSendSubscribeTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicOperationSendSubscribeTest.java
index 4426062dee530..e94f2a4a82de7 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicOperationSendSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/ServiceBusTopicOperationSendSubscribeTest.java
@@ -7,30 +7,36 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusTopicClientFactory;
import com.azure.spring.integration.servicebus.support.ServiceBusTopicTestOperation;
import com.azure.spring.integration.test.support.SendSubscribeWithGroupOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.messaging.Message;
import static com.azure.spring.integration.servicebus.converter.ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@RunWith(MockitoJUnitRunner.class)
public class ServiceBusTopicOperationSendSubscribeTest
extends SendSubscribeWithGroupOperationTest {
@Mock
ServiceBusTopicClientFactory clientFactory;
- @Before
- @Override
+ private AutoCloseable closeable;
+
+ @BeforeEach
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.sendSubscribeOperation = new ServiceBusTopicTestOperation(clientFactory);
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifyCheckpointSuccessCalled(int times) {
verifyCompleteCalledTimes(times);
@@ -51,7 +57,7 @@ protected void manualCheckpointHandler(Message> message) {
assertTrue(message.getHeaders().containsKey(RECEIVED_MESSAGE_CONTEXT));
final ServiceBusReceivedMessageContext receivedMessageContext = message.getHeaders()
.get(RECEIVED_MESSAGE_CONTEXT,
- ServiceBusReceivedMessageContext.class);
+ ServiceBusReceivedMessageContext.class);
assertNotNull(receivedMessageContext);
receivedMessageContext.complete();
@@ -62,20 +68,20 @@ protected void manualCheckpointHandler(Message> message) {
}
protected void verifyCompleteCalledTimes(int times) {
- waitMillis(25);
+ waitMillis(250);
final int actualTimes = ((ServiceBusTopicTestOperation) sendSubscribeOperation).getCompleteCalledTimes();
if (actualTimes != times) {
- assertEquals("Complete called times", times, actualTimes);
+ assertEquals(times, actualTimes, "Complete called times");
}
}
protected void verifyAbandonCalledTimes(int times) {
- waitMillis(25);
+ waitMillis(250);
final int actualTimes = ((ServiceBusTopicTestOperation) sendSubscribeOperation).getCompleteCalledTimes();
if (actualTimes != times) {
- assertEquals("Complete called times", times, actualTimes);
+ assertEquals(times, actualTimes, "Complete called times");
}
}
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSendTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSendTest.java
index 1873a4754166a..9feed4aa9d68b 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSendTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSendTest.java
@@ -8,22 +8,24 @@
import com.azure.spring.integration.servicebus.ServiceBusTemplateSendTest;
import com.azure.spring.integration.servicebus.converter.ServiceBusMessageConverter;
import com.azure.spring.integration.servicebus.factory.ServiceBusTopicClientFactory;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.mockito.MockitoAnnotations;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class TopicTemplateSendTest
extends ServiceBusTemplateSendTest {
- @Before
+ private AutoCloseable closeable;
+
+ @BeforeEach
@Override
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.mockClientFactory = mock(ServiceBusTopicClientFactory.class);
this.mockClient = mock(ServiceBusSenderAsyncClient.class);
@@ -33,4 +35,9 @@ public void setUp() {
this.sendOperation = new ServiceBusTopicTemplate(mockClientFactory, new ServiceBusMessageConverter());
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
}
diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSubscribeTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSubscribeTest.java
index 6e298a5c0853c..297d2e317219c 100644
--- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSubscribeTest.java
+++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/topic/TopicTemplateSubscribeTest.java
@@ -7,12 +7,12 @@
import com.azure.spring.integration.servicebus.factory.ServiceBusTopicClientFactory;
import com.azure.spring.integration.servicebus.support.ServiceBusProcessorClientWrapper;
import com.azure.spring.integration.test.support.SubscribeByGroupOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
@@ -20,15 +20,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class TopicTemplateSubscribeTest extends SubscribeByGroupOperationTest {
@Mock
private ServiceBusTopicClientFactory mockClientFactory;
private ServiceBusProcessorClientWrapper processorClientWrapper;
-
- @Before
+ private AutoCloseable closeable;
+ @BeforeEach
public void setUp() {
+ this.closeable = MockitoAnnotations.openMocks(this);
this.processorClientWrapper = new ServiceBusProcessorClientWrapper();
ServiceBusProcessorClientWrapper anotherProcessorClientWrapper = new ServiceBusProcessorClientWrapper();
@@ -44,6 +44,11 @@ public void setUp() {
any())).thenReturn(anotherProcessorClientWrapper.getClient());
}
+ @AfterEach
+ public void close() throws Exception {
+ closeable.close();
+ }
+
@Override
protected void verifySubscriberCreatorCalled() {
verify(this.mockClientFactory, atLeastOnce()).getOrCreateProcessor(eq(this.destination),
diff --git a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueMessageSourceTest.java b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueMessageSourceTest.java
index 0ecce8645e77e..c947299866d97 100644
--- a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueMessageSourceTest.java
+++ b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueMessageSourceTest.java
@@ -5,21 +5,24 @@
import com.azure.spring.integration.storage.queue.inbound.StorageQueueMessageSource;
import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
import reactor.core.publisher.Mono;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class StorageQueueMessageSourceTest {
@Mock
@@ -29,23 +32,34 @@ public class StorageQueueMessageSourceTest {
private String destination = "test-destination";
private StorageQueueMessageSource messageSource;
+ private AutoCloseable closeable;
- @Before
+ @BeforeAll
+ public void init() {
+ this.closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @BeforeEach
public void setup() {
messageSource = new StorageQueueMessageSource(destination, mockOperation);
}
+ @AfterAll
+ public void close() throws Exception {
+ this.closeable.close();
+ }
+
@Test
public void testDoReceiveWhenHaveNoMessage() {
when(this.mockOperation.receiveAsync(eq(destination))).thenReturn(Mono.empty());
assertNull(messageSource.doReceive());
}
- @Test(expected = StorageQueueRuntimeException.class)
+ @Test
public void testReceiveFailure() {
when(this.mockOperation.receiveAsync(eq(destination))).thenReturn(Mono.error(
new StorageQueueRuntimeException("Failed to receive message.")));
- messageSource.doReceive();
+ assertThrows(StorageQueueRuntimeException.class, () -> messageSource.doReceive());
}
@Test
diff --git a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateReceiveTest.java b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateReceiveTest.java
index a58bc43fc57c9..88537d5d68d53 100644
--- a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateReceiveTest.java
+++ b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateReceiveTest.java
@@ -8,19 +8,19 @@
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.util.IterableStream;
-import com.azure.storage.queue.QueueAsyncClient;
-import com.azure.storage.queue.models.QueueMessageItem;
-import com.azure.storage.queue.models.QueueStorageException;
-import com.google.common.collect.Lists;
import com.azure.spring.integration.core.AzureHeaders;
import com.azure.spring.integration.core.api.CheckpointMode;
import com.azure.spring.integration.core.api.reactor.Checkpointer;
import com.azure.spring.integration.storage.queue.factory.StorageQueueClientFactory;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import com.azure.storage.queue.QueueAsyncClient;
+import com.azure.storage.queue.models.QueueMessageItem;
+import com.azure.storage.queue.models.QueueStorageException;
+import com.google.common.collect.Lists;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.springframework.messaging.Message;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -30,12 +30,16 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class StorageQueueTemplateReceiveTest {
private final String messageId = "1";
@@ -49,9 +53,11 @@ public class StorageQueueTemplateReceiveTest {
private QueueMessageItem queueMessage;
private int visibilityTimeoutInSeconds = 30;
private String destination = "queue";
+ private AutoCloseable closeable;
- @Before
+ @BeforeEach
public void setup() {
+ this.closeable = MockitoAnnotations.openMocks(this);
queueMessage = new QueueMessageItem();
queueMessage.setMessageText(messageText);
queueMessage.setMessageId(messageId);
@@ -100,6 +106,11 @@ public IterableStream getElements() {
this.operation = new StorageQueueTemplate(this.mockClientFactory);
}
+ @AfterEach
+ public void close() throws Exception {
+ this.closeable.close();
+ }
+
@Test
public void testReceiveFailure() {
when(this.mockClient.receiveMessages(eq(1), eq(Duration.ofSeconds(visibilityTimeoutInSeconds))))
diff --git a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateSendTest.java b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateSendTest.java
index 0ec4ccdf1925b..9b3981a560269 100644
--- a/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateSendTest.java
+++ b/sdk/spring/azure-spring-integration-storage-queue/src/test/java/com/azure/spring/integration/storage/queue/StorageQueueTemplateSendTest.java
@@ -3,20 +3,24 @@
package com.azure.spring.integration.storage.queue;
-import com.azure.storage.queue.QueueAsyncClient;
-import com.azure.storage.queue.models.SendMessageResult;
import com.azure.spring.integration.storage.queue.factory.StorageQueueClientFactory;
import com.azure.spring.integration.test.support.reactor.SendOperationTest;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import com.azure.storage.queue.QueueAsyncClient;
+import com.azure.storage.queue.models.SendMessageResult;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Mono;
-import static org.mockito.ArgumentMatchers.*;
-import static org.mockito.Mockito.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public class StorageQueueTemplateSendTest extends SendOperationTest {
@Mock
@@ -25,7 +29,19 @@ public class StorageQueueTemplateSendTest extends SendOperationTestspring-boot-starter-test
2.5.0
-
- org.junit.vintage
- junit-vintage-engine
- 5.7.2
-
org.hibernate.validator
hibernate-validator
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/InboundChannelAdapterTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/InboundChannelAdapterTest.java
index 68ffb814866dc..c438cdce148df 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/InboundChannelAdapterTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/InboundChannelAdapterTest.java
@@ -4,8 +4,8 @@
package com.azure.spring.integration.test.support;
import com.azure.spring.integration.core.AbstractInboundChannelAdapter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -17,8 +17,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class InboundChannelAdapterTest {
@@ -49,14 +49,14 @@ public void sendAndReceive() throws InterruptedException {
});
this.messages.forEach(this.adapter::receiveMessage);
- assertTrue("Failed to receive message", latch.await(5L, TimeUnit.SECONDS));
+ assertTrue(latch.await(5L, TimeUnit.SECONDS), "Failed to receive message");
for (int i = 0; i < receivedMessages.size(); i++) {
assertEquals(receivedMessages.get(i), payloads[i]);
}
}
- @Before
+ @BeforeEach
public abstract void setUp();
public A getAdapter() {
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/MessageHandlerTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/MessageHandlerTest.java
index 12fa2854d1f23..27658fb377b8b 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/MessageHandlerTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/MessageHandlerTest.java
@@ -8,9 +8,7 @@
import com.azure.spring.integration.core.DefaultMessageHandler;
import com.azure.spring.integration.core.api.PartitionSupplier;
import com.azure.spring.integration.core.api.SendOperation;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.messaging.Message;
@@ -25,8 +23,8 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.spy;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(MockitoJUnitRunner.class)
public abstract class MessageHandlerTest {
@SuppressWarnings("unchecked")
@@ -113,13 +111,13 @@ public void testSendSync() {
}
@SuppressWarnings("unchecked")
- @Test(expected = MessageTimeoutException.class)
+ @Test
public void testSendTimeout() {
when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class), isA(PartitionSupplier.class)))
.thenReturn(new CompletableFuture<>());
this.handler.setSync(true);
this.handler.setSendTimeout(1);
- this.handler.handleMessage(this.message);
+ assertThrows(MessageTimeoutException.class, () -> this.handler.handleMessage(this.message));
}
@Test
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendOperationTest.java
index a6f0824b4c36e..ad485b8b23f22 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendOperationTest.java
@@ -6,7 +6,7 @@
import com.azure.spring.integration.core.api.PartitionSupplier;
import com.azure.spring.integration.core.api.SendOperation;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.NestedRuntimeException;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
@@ -15,15 +15,16 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Fail.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public abstract class SendOperationTest {
protected String destination = "event-hub";
protected Message> message = new GenericMessage<>("testPayload",
- ImmutableMap.of("key1", "value1", "key2", "value2"));
+ ImmutableMap.of("key1", "value1", "key2", "value2"));
protected Mono mono = Mono.empty();
protected String partitionKey = "key";
protected String payload = "payload";
@@ -32,15 +33,12 @@ public abstract class SendOperationTest {
protected abstract void setupError(String errorMessage);
- @Test(expected = NestedRuntimeException.class)
+ @Test
public void testSendCreateSenderFailure() throws Throwable {
whenSendWithException();
- try {
- this.sendOperation.sendAsync(destination, this.message, null).get();
- } catch (ExecutionException e) {
- throw e.getCause();
- }
+ assertThrows(NestedRuntimeException.class,
+ () -> this.sendOperation.sendAsync(destination, this.message, null).get());
}
@Test
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendSubscribeOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendSubscribeOperationTest.java
index 4220f1aaa2c93..817f401d62648 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendSubscribeOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SendSubscribeOperationTest.java
@@ -9,8 +9,8 @@
import com.azure.spring.integration.core.api.Checkpointer;
import com.azure.spring.integration.core.api.SendOperation;
import com.azure.spring.integration.test.support.pojo.User;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
@@ -22,9 +22,9 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class SendSubscribeOperationTest {
@@ -45,7 +45,7 @@ public abstract class SendSubscribeOperationTest {
private final Message stringMessage = new GenericMessage<>(payload, headers);
private final Message byteMessage = new GenericMessage<>(payload.getBytes(StandardCharsets.UTF_8), headers);
- @Before
+ @BeforeEach
public abstract void setUp() throws Exception;
@Test
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeByGroupOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeByGroupOperationTest.java
index 66063a1fb71dd..1137465f407a9 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeByGroupOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeByGroupOperationTest.java
@@ -4,11 +4,11 @@
package com.azure.spring.integration.test.support;
import com.azure.spring.integration.core.api.SubscribeByGroupOperation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class SubscribeByGroupOperationTest {
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeOperationTest.java
index d48e594e2ba49..32224a070d2a5 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/SubscribeOperationTest.java
@@ -4,11 +4,11 @@
package com.azure.spring.integration.test.support;
import com.azure.spring.integration.core.api.SubscribeOperation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class SubscribeOperationTest {
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/UnaryAzureMessageConverterTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/UnaryAzureMessageConverterTest.java
index ca4d41ec08b1c..25efc3caa2e62 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/UnaryAzureMessageConverterTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/UnaryAzureMessageConverterTest.java
@@ -5,15 +5,15 @@
import com.azure.spring.integration.core.converter.AzureMessageConverter;
import com.azure.spring.integration.test.support.pojo.User;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public abstract class UnaryAzureMessageConverterTest {
@@ -28,7 +28,7 @@ public abstract class UnaryAzureMessageConverterTest {
protected abstract void assertMessageHeadersEqual(T azureMessage, Message> message);
- @Before
+ @BeforeEach
public void setUp() {
converter = getConverter();
}
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/MessageHandlerTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/MessageHandlerTest.java
index f02e8bd50ce2d..874bbab823cb4 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/MessageHandlerTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/MessageHandlerTest.java
@@ -8,9 +8,7 @@
import com.azure.spring.integration.core.api.reactor.DefaultMessageHandler;
import com.azure.spring.integration.core.api.reactor.SendOperation;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.messaging.Message;
@@ -24,8 +22,8 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(MockitoJUnitRunner.class)
public abstract class MessageHandlerTest {
protected String destination = "dest";
@@ -34,7 +32,7 @@ public abstract class MessageHandlerTest {
protected Mono mono = Mono.empty();
protected O sendOperation;
private Message> message = new GenericMessage<>("testPayload",
- ImmutableMap.of("key1", "value1", "key2", "value2"));
+ ImmutableMap.of("key1", "value1", "key2", "value2"));
private String payload = "payload";
public abstract void setUp();
@@ -44,7 +42,7 @@ public abstract class MessageHandlerTest {
public void testSend() {
this.handler.handleMessage(this.message);
verify(this.sendOperation, times(1)).sendAsync(eq(destination), isA(Message.class),
- isA(PartitionSupplier.class));
+ isA(PartitionSupplier.class));
}
@Test
@@ -70,10 +68,10 @@ public void onSuccess(Void v) {
@SuppressWarnings("unchecked")
public void testSendDynamicTopic() {
Message> dynamicMessage = new GenericMessage<>(payload,
- ImmutableMap.of(AzureHeaders.NAME, dynamicDestination));
+ ImmutableMap.of(AzureHeaders.NAME, dynamicDestination));
this.handler.handleMessage(dynamicMessage);
verify(this.sendOperation, times(1)).sendAsync(eq(dynamicDestination), isA(Message.class),
- isA(PartitionSupplier.class));
+ isA(PartitionSupplier.class));
}
@Test
@@ -86,15 +84,15 @@ public void testSendSync() {
verify(timeout, times(1)).getValue(eq(null), eq(this.message), eq(Long.class));
}
- @Test(expected = MessageTimeoutException.class)
+ @Test
@SuppressWarnings("unchecked")
public void testSendTimeout() {
when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class),
- isA(PartitionSupplier.class))).thenReturn(Mono.empty().timeout(Mono.empty()));
+ isA(PartitionSupplier.class))).thenReturn(Mono.empty().timeout(Mono.empty()));
this.handler.setSync(true);
this.handler.setSendTimeout(1);
- this.handler.handleMessage(this.message);
+ assertThrows(MessageTimeoutException.class, () -> this.handler.handleMessage(this.message));
}
public Mono getMono() {
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendOperationTest.java
index bc88a53a62cfd..1a5409d578543 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendOperationTest.java
@@ -5,29 +5,30 @@
import com.azure.spring.integration.core.api.reactor.SendOperation;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.NestedRuntimeException;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
import reactor.core.publisher.Mono;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
+import static org.assertj.core.api.Fail.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public abstract class SendOperationTest {
protected String consumerGroup = "consumer-group";
protected String destination = "event-hub";
protected Message> message = new GenericMessage<>("testPayload",
- ImmutableMap.of("key1", "value1", "key2", "value2"));
+ ImmutableMap.of("key1", "value1", "key2", "value2"));
protected Mono mono = Mono.empty();
protected String payload = "payload";
protected O sendOperation;
protected abstract void setupError(String errorMessage);
+
@Test
public void testSend() {
final Mono mono = this.sendOperation.sendAsync(destination, message, null);
@@ -36,11 +37,12 @@ public void testSend() {
verifySendCalled(1);
}
- @Test(expected = NestedRuntimeException.class)
+ @Test
public void testSendCreateSenderFailure() {
whenSendWithException();
- this.sendOperation.sendAsync(destination, this.message, null).block();
+ assertThrows(NestedRuntimeException.class, () -> this.sendOperation.sendAsync(destination, this.message,
+ null).block());
}
@Test
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendSubscribeOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendSubscribeOperationTest.java
index 30169dc8420d1..0b2de2fc1bd6a 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendSubscribeOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/reactor/SendSubscribeOperationTest.java
@@ -9,8 +9,8 @@
import com.azure.spring.integration.core.api.reactor.Checkpointer;
import com.azure.spring.integration.core.api.reactor.SendOperation;
import com.azure.spring.integration.test.support.pojo.User;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
@@ -22,9 +22,10 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public abstract class SendSubscribeOperationTest {
@@ -45,7 +46,7 @@ public abstract class SendSubscribeOperationTest {
protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig);
- @Before
+ @BeforeEach
public abstract void setUp();
protected abstract void subscribe(String destination, Consumer> consumer, Class> payloadType);
diff --git a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/rx/RxSendSubscribeOperationTest.java b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/rx/RxSendSubscribeOperationTest.java
index 322a4e4e42869..1af31743a2fea 100644
--- a/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/rx/RxSendSubscribeOperationTest.java
+++ b/sdk/spring/azure-spring-integration-test/src/main/java/com/azure/spring/integration/test/support/rx/RxSendSubscribeOperationTest.java
@@ -7,8 +7,8 @@
import com.azure.spring.integration.core.api.CheckpointMode;
import com.azure.spring.integration.core.api.RxSendOperation;
import com.azure.spring.integration.test.support.pojo.User;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
import rx.Observable;
@@ -40,7 +40,7 @@ public abstract class RxSendSubscribeOperationTest {
protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig);
- @Before
+ @BeforeEach
public abstract void setUp();
protected abstract Observable> subscribe(String destination, Class> payloadType);