Migrates web examples to JUnit 5.

Original pull request #602
Related tickest #583
This commit is contained in:
divya_jnu08
2021-01-26 23:13:46 +05:30
committed by Jens Schauder
parent 64c1eeaf05
commit 9db9632c4b
7 changed files with 34 additions and 26 deletions

View File

@@ -15,15 +15,15 @@
*/
package example.users;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests to bootstrap the application.
*
* @author Oliver Gierke
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest
public abstract class AbstractIntegrationTests {}

View File

@@ -16,9 +16,9 @@
package example.users;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**

View File

@@ -15,7 +15,8 @@
*/
package example.users;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -31,8 +32,10 @@ public class UserRepositoryIntegrationTests extends AbstractIntegrationTests {
/**
* @see #65
*/
@Test(expected = InvalidDataAccessApiUsageException.class)
@Test
public void repositoryRejectsUnencryptedPassword() {
users.save(new User(new Username("olivergierke"), Password.raw("foobar")));
Assertions.assertThrows(InvalidDataAccessApiUsageException.class, () -> {
users.save(new User(new Username("olivergierke"), Password.raw("foobar")));
});
}
}