BAEL-6277 - A Guide To Spring Cloud Azure Key Vault
fix pom.xml
This commit is contained in:
@@ -25,48 +25,23 @@
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- for junit5 to successfully be able to discover junit4 tests, we need 4.12+ version of -->
|
||||
<!-- junit:junit in the classpath. hence forcing the latest 4.13.2 available version -->
|
||||
<!-- for junit5 compatibility -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.7.8</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.azure.spring</groupId>
|
||||
<artifactId>spring-cloud-azure-dependencies</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.azure.spring</groupId>
|
||||
<artifactId>spring-cloud-azure-starter-keyvault-secrets</artifactId>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -5,6 +5,18 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>junit5-annotations</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<name>junit5-annotations</name>
|
||||
<description>Intro to JUnit 5</description>
|
||||
|
||||
@@ -42,10 +54,22 @@
|
||||
<version>${junit-platform.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${spring.boot.test.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<log4j2.version>2.19.0</log4j2.version>
|
||||
<spring.boot.version>3.0.4</spring.boot.version>
|
||||
<spring.boot.test.version>3.0.5</spring.boot.test.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.junit5.activeprofile;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main (String [] args){
|
||||
SpringApplication.run(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
profile:
|
||||
property:
|
||||
value: This the the application-dev.yaml file
|
||||
@@ -0,0 +1,6 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
profile:
|
||||
property:
|
||||
value: This the the application.yaml file
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.junit5.activeprofile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@SpringBootTest
|
||||
public class DevActiveProfileUnitTest {
|
||||
|
||||
@Value("${profile.property.value}")
|
||||
private String propertyString;
|
||||
|
||||
@Test
|
||||
void whenDevIsActive_ThenValueShouldBeKeptFromApplicationDevYaml() {
|
||||
;
|
||||
Assertions.assertEquals("This the the application-dev.yaml file", propertyString, propertyString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.junit5.activeprofile;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.EnabledIf;
|
||||
|
||||
@SpringBootTest
|
||||
@EnabledIf(value = "#{{'dev', 'prod'}.contains(environment.getActiveProfiles()[0])}", loadContext = true)
|
||||
public class MultipleActiveProfileUnitTest {
|
||||
@Value("${profile.property.value}")
|
||||
private String propertyString;
|
||||
|
||||
@Test
|
||||
void whenDevIsActive_ThenValueShouldBeKeptFromApplicationDevYaml() {
|
||||
;
|
||||
Assertions.assertEquals("This the the application-dev.yaml file", propertyString, propertyString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.junit5.activeprofile;
|
||||
|
||||
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;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.EnabledIf;
|
||||
|
||||
@SpringBootTest
|
||||
@EnabledIf(value = "#{environment.getActiveProfiles()[0] == 'prod'}", loadContext = true)
|
||||
@ActiveProfiles(value = "prod")
|
||||
|
||||
public class ProdActiveProfileUnitTest {
|
||||
|
||||
@Value("${profile.property.value}")
|
||||
private String propertyString;
|
||||
|
||||
@Autowired
|
||||
private
|
||||
|
||||
@Test void whenProdIsActive_ThenValueShouldBeKeptFromApplicationYaml() {
|
||||
Assertions.assertEquals("This the the application.yaml file", propertyString, propertyString);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenProdIsASystemVariable_ThenTestShouldRun() {
|
||||
Assertions.assertEquals("This the the application.yaml file", propertyString, propertyString);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user