|
| 1 | +import com.azure.spring.cloud.autoconfigure.implementation.context.AzureGlobalPropertiesAutoConfiguration; |
| 2 | +import com.azure.spring.cloud.autoconfigure.implementation.storage.queue.AzureStorageQueueAutoConfiguration; |
| 3 | +import com.azure.storage.queue.QueueClient; |
| 4 | +import org.junit.jupiter.api.Test; |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; |
| 6 | +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; |
| 7 | +import org.springframework.boot.test.context.SpringBootTest; |
| 8 | +import org.springframework.context.annotation.Configuration; |
| 9 | + |
| 10 | +import static org.assertj.core.api.Assertions.assertThat; |
| 11 | + |
| 12 | +@SpringBootTest(properties = { |
| 13 | + "spring.docker.compose.skip.in-tests=false", |
| 14 | + "spring.docker.compose.file=classpath:storage-compose.yaml", |
| 15 | + "spring.docker.compose.stop.command=down", |
| 16 | + "spring.cloud.azure.storage.queue.queue-name=devstoreaccount1/tc-queue" |
| 17 | +}) |
| 18 | +class StorageQueueDockerComposeTest { |
| 19 | + |
| 20 | + @Autowired |
| 21 | + private QueueClient queueClient; |
| 22 | + |
| 23 | + @Test |
| 24 | + void test() { |
| 25 | + String message = "Hello World!"; |
| 26 | + this.queueClient.create(); |
| 27 | + this.queueClient.sendMessage(message); |
| 28 | + var messageItem = this.queueClient.receiveMessage(); |
| 29 | + assertThat(messageItem.getBody().toString()).isEqualTo(message); |
| 30 | + } |
| 31 | + |
| 32 | + @Configuration |
| 33 | + @ImportAutoConfiguration(classes = { |
| 34 | + AzureGlobalPropertiesAutoConfiguration.class, |
| 35 | + AzureStorageQueueAutoConfiguration.class}) |
| 36 | + static class Config { |
| 37 | + } |
| 38 | + |
| 39 | +} |
0 commit comments