Fixed conflict
This commit is contained in:
@@ -7,6 +7,6 @@ This module contains articles about Hamcrest
|
||||
- [Hamcrest File Matchers](https://www.baeldung.com/hamcrest-file-matchers)
|
||||
- [Hamcrest Object Matchers](https://www.baeldung.com/hamcrest-object-matchers)
|
||||
- [Hamcrest Bean Matchers](https://www.baeldung.com/hamcrest-bean-matchers)
|
||||
- [Hamcrest Number Matchers](https://www.baeldung.com/hamcrest-number-matchers)
|
||||
- [Using Hamcrest Number Matchers](https://www.baeldung.com/hamcrest-number-matchers)
|
||||
- [Hamcrest Common Core Matchers](https://www.baeldung.com/hamcrest-core-matchers)
|
||||
- [Hamcrest Custom Matchers](https://www.baeldung.com/hamcrest-custom-matchers)
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
- [Custom JUnit 4 Test Runners](http://www.baeldung.com/junit-4-custom-runners)
|
||||
- [Introduction to JUnitParams](http://www.baeldung.com/junit-params)
|
||||
- [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java)
|
||||
- [Introduction to Lambda Behave](https://www.baeldung.com/lambda-behave)
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
- [JUnit 5 TestWatcher API](https://www.baeldung.com/junit-testwatcher)
|
||||
- [JUnit Custom Display Name Generator API](https://www.baeldung.com/junit-custom-display-name-generator)
|
||||
- [@TestInstance Annotation in JUnit 5](https://www.baeldung.com/junit-testinstance-annotation)
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
<name>load-testing-comparison</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -34,11 +34,6 @@
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>net.sf.grinder</groupId>-->
|
||||
<!--<artifactId>grinder</artifactId>-->
|
||||
<!--<version>${grinder.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
@@ -47,33 +42,22 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</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-data-jpa</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -143,8 +127,6 @@
|
||||
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
|
||||
<gatling-maven-plugin.version>2.2.1</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
|
||||
<jmeter.version>5.0</jmeter.version>
|
||||
<grinder.version>3.11</grinder.version>
|
||||
<spring.boot.version>2.0.5.RELEASE</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -14,3 +14,5 @@
|
||||
- [Mocking Void Methods with Mockito](https://www.baeldung.com/mockito-void-methods)
|
||||
- [Mock Final Classes and Methods with Mockito](https://www.baeldung.com/mockito-final)
|
||||
- [Testing Callbacks with Mockito](https://www.baeldung.com/mockito-callbacks)
|
||||
- [Mockito – Using Spies](https://www.baeldung.com/mockito-spy)
|
||||
- [Quick Guide to BDDMockito](https://www.baeldung.com/bdd-mockito)
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
- [JMockit Advanced Usage](http://www.baeldung.com/jmockit-advanced-usage)
|
||||
- [Introduction to Jukito](http://www.baeldung.com/jukito)
|
||||
- [A Guide to JavaFaker](https://www.baeldung.com/java-faker)
|
||||
- [File System Mocking with Jimfs](https://www.baeldung.com/jimfs-file-system-mocking)
|
||||
|
||||
@@ -1,55 +1,62 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>mocks</artifactId>
|
||||
<name>mocks</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.javafaker</groupId>
|
||||
<artifactId>javafaker</artifactId>
|
||||
<version>${javafaker.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jukito</groupId>
|
||||
<artifactId>jukito</artifactId>
|
||||
<version>${jukito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>${easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<javafaker.version>0.15</javafaker.version>
|
||||
<jukito.version>1.5</jukito.version>
|
||||
<mockito.version>2.21.0</mockito.version>
|
||||
<easymock.version>3.5.1</easymock.version>
|
||||
<jmockit.version>1.41</jmockit.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>mocks</artifactId>
|
||||
<name>mocks</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.javafaker</groupId>
|
||||
<artifactId>javafaker</artifactId>
|
||||
<version>${javafaker.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jukito</groupId>
|
||||
<artifactId>jukito</artifactId>
|
||||
<version>${jukito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>${easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.jimfs</groupId>
|
||||
<artifactId>jimfs</artifactId>
|
||||
<version>${jimf.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<javafaker.version>0.15</javafaker.version>
|
||||
<jukito.version>1.5</jukito.version>
|
||||
<mockito.version>2.21.0</mockito.version>
|
||||
<easymock.version>3.5.1</easymock.version>
|
||||
<jmockit.version>1.41</jmockit.version>
|
||||
<jimf.version>1.1</jimf.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public class FileManipulation {
|
||||
|
||||
void move(final Path origin, final Path destination) {
|
||||
try {
|
||||
Files.createDirectories(destination);
|
||||
Files.move(origin, destination, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
class FilePathReader {
|
||||
|
||||
String getSystemPath(final Path path) {
|
||||
try {
|
||||
return path
|
||||
.toRealPath()
|
||||
.toString();
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class FileRepository {
|
||||
|
||||
void create(final Path path, final String fileName) {
|
||||
final Path filePath = path.resolve(fileName);
|
||||
try {
|
||||
Files.createFile(filePath);
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
String read(final Path path) {
|
||||
try {
|
||||
return new String(Files.readAllBytes(path));
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
String update(final Path path, final String newContent) {
|
||||
try {
|
||||
Files.write(path, newContent.getBytes());
|
||||
return newContent;
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void delete(final Path path) {
|
||||
try {
|
||||
Files.deleteIfExists(path);
|
||||
} catch (final IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import com.google.common.jimfs.Configuration;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class FileManipulationUnitTest implements FileTestProvider {
|
||||
|
||||
private final FileManipulation fileManipulation = new FileManipulation();
|
||||
|
||||
private static Stream<Arguments> provideFileSystem() {
|
||||
return Stream.of(Arguments.of(Jimfs.newFileSystem(Configuration.unix())), Arguments.of(Jimfs.newFileSystem(Configuration.windows())), Arguments.of(Jimfs.newFileSystem(Configuration.osX())));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@DisplayName("Should move file to new destination")
|
||||
@MethodSource("provideFileSystem")
|
||||
void givenEachSystem_whenMovingFile_thenMovedToNewPath(final FileSystem fileSystem) throws Exception {
|
||||
final Path origin = fileSystem.getPath(RESOURCE_FILE_NAME);
|
||||
Files.copy(getResourceFilePath(), origin);
|
||||
final Path destination = fileSystem.getPath("newDirectory", RESOURCE_FILE_NAME);
|
||||
|
||||
fileManipulation.move(origin, destination);
|
||||
|
||||
assertFalse(Files.exists(origin));
|
||||
assertTrue(Files.exists(destination));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import com.google.common.jimfs.Configuration;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class FilePathReaderUnitTest {
|
||||
|
||||
private static final String DIRECTORY_NAME = "baeldung";
|
||||
|
||||
private final FilePathReader filePathReader = new FilePathReader();
|
||||
|
||||
@Test
|
||||
@DisplayName("Should get path on windows")
|
||||
void givenWindowsSystem_shouldGetPath_thenReturnWindowsPath() throws Exception {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.windows());
|
||||
final Path path = getPathToFile(fileSystem);
|
||||
|
||||
final String stringPath = filePathReader.getSystemPath(path);
|
||||
|
||||
assertEquals("C:\\work\\" + DIRECTORY_NAME, stringPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should get path on unix")
|
||||
void givenUnixSystem_shouldGetPath_thenReturnUnixPath() throws Exception {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix());
|
||||
final Path path = getPathToFile(fileSystem);
|
||||
|
||||
final String stringPath = filePathReader.getSystemPath(path);
|
||||
|
||||
assertEquals("/work/" + DIRECTORY_NAME, stringPath);
|
||||
}
|
||||
|
||||
private Path getPathToFile(final FileSystem fileSystem) throws Exception {
|
||||
final Path path = fileSystem.getPath(DIRECTORY_NAME);
|
||||
Files.createDirectory(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import com.google.common.jimfs.Configuration;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FileRepositoryUnitTest implements FileTestProvider {
|
||||
|
||||
private final FileRepository fileRepository = new FileRepository();
|
||||
|
||||
@Test
|
||||
@DisplayName("Should create a file on a file system")
|
||||
void givenUnixSystem_whenCreatingFile_thenCreatedInPath() {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix());
|
||||
final String fileName = "newFile.txt";
|
||||
final Path pathToStore = fileSystem.getPath("");
|
||||
|
||||
fileRepository.create(pathToStore, fileName);
|
||||
|
||||
assertTrue(Files.exists(pathToStore.resolve(fileName)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should read the content of the file")
|
||||
void givenOSXSystem_whenReadingFile_thenContentIsReturned() throws Exception {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.osX());
|
||||
final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME);
|
||||
Files.copy(getResourceFilePath(), resourceFilePath);
|
||||
|
||||
final String content = fileRepository.read(resourceFilePath);
|
||||
|
||||
assertEquals(FILE_CONTENT, content);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should update the content of the file")
|
||||
void givenWindowsSystem_whenUpdatingFile_thenContentHasChanged() throws Exception {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.windows());
|
||||
final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME);
|
||||
Files.copy(getResourceFilePath(), resourceFilePath);
|
||||
final String newContent = "I'm updating you.";
|
||||
|
||||
final String content = fileRepository.update(resourceFilePath, newContent);
|
||||
|
||||
assertEquals(newContent, content);
|
||||
assertEquals(newContent, fileRepository.read(resourceFilePath));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should delete file")
|
||||
void givenCurrentSystem_whenDeletingFile_thenFileHasBeenDeleted() throws Exception {
|
||||
final FileSystem fileSystem = Jimfs.newFileSystem();
|
||||
final Path resourceFilePath = fileSystem.getPath(RESOURCE_FILE_NAME);
|
||||
Files.copy(getResourceFilePath(), resourceFilePath);
|
||||
|
||||
fileRepository.delete(resourceFilePath);
|
||||
|
||||
assertFalse(Files.exists(resourceFilePath));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.jimfs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public interface FileTestProvider {
|
||||
String FILE_CONTENT = "I'm the file content.";
|
||||
String RESOURCE_FILE_NAME = "fileRepositoryRead.txt";
|
||||
|
||||
default Path getResourceFilePath() {
|
||||
final String resourceFilePath = getClass()
|
||||
.getResource("/" + RESOURCE_FILE_NAME)
|
||||
.getPath();
|
||||
return Paths.get(resourceFilePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
I'm the file content.
|
||||
@@ -6,3 +6,4 @@
|
||||
- [How to Test the @Scheduled Annotation](https://www.baeldung.com/spring-testing-scheduled-annotation)
|
||||
- [Using SpringJUnit4ClassRunner with Parameterized](https://www.baeldung.com/springjunit4classrunner-parameterized)
|
||||
- [Override Properties in Spring’s Tests](https://www.baeldung.com/spring-tests-override-properties)
|
||||
- [A Quick Guide to @DirtiesContext](https://www.baeldung.com/spring-dirtiescontext)
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<version>${junit.commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
@@ -112,7 +117,8 @@
|
||||
<!-- testing -->
|
||||
<hamcrest.version>2.0.0.0</hamcrest.version>
|
||||
<awaitility.version>3.1.6</awaitility.version>
|
||||
<junit.jupiter.version>5.4.0</junit.jupiter.version>
|
||||
<junit.jupiter.version>5.5.0</junit.jupiter.version>
|
||||
<junit.commons.version>1.5.2</junit.commons.version>
|
||||
<spring.version>5.1.4.RELEASE</spring.version>
|
||||
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
||||
<javax.persistence.version>2.1.1</javax.persistence.version>
|
||||
|
||||
@@ -10,10 +10,12 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.MethodMode;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = SpringDataRestApplication.class)
|
||||
@EnableWebMvc
|
||||
class DirtiesContextIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
@EnableWebMvc
|
||||
public class ProfilePropertySourceResolverIntegrationTest {
|
||||
|
||||
@Autowired private PropertySourceResolver propertySourceResolver;
|
||||
@Autowired
|
||||
private PropertySourceResolver propertySourceResolver;
|
||||
|
||||
@Test
|
||||
public void shouldProfiledProperty_overridePropertyValues() {
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "example.firstProperty=annotation" })
|
||||
@EnableWebMvc
|
||||
public class SpringBootPropertySourceResolverIntegrationTest {
|
||||
|
||||
@Autowired private PropertySourceResolver propertySourceResolver;
|
||||
@Autowired
|
||||
private PropertySourceResolver propertySourceResolver;
|
||||
|
||||
@Test
|
||||
public void shouldSpringBootTestAnnotation_overridePropertyValues() {
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package com.baeldung.overrideproperties;
|
||||
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import com.baeldung.overrideproperties.resolver.PropertySourceResolver;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@EnableWebMvc
|
||||
public class TestResourcePropertySourceResolverIntegrationTest {
|
||||
|
||||
@Autowired private PropertySourceResolver propertySourceResolver;
|
||||
@Autowired
|
||||
private PropertySourceResolver propertySourceResolver;
|
||||
|
||||
@Test
|
||||
public void shouldTestResourceFile_overridePropertyValues() {
|
||||
|
||||
Reference in New Issue
Block a user