Use AssertJ in spring-boot-samples

See gh-5083
This commit is contained in:
Phillip Webb
2016-02-06 14:53:10 -08:00
parent 962a598531
commit 1cc1fc6431
97 changed files with 580 additions and 733 deletions

View File

@@ -35,7 +35,7 @@ import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Basic integration tests for demo application.
@@ -70,25 +70,25 @@ public class SampleSecureApplicationTests {
@Test(expected = AuthenticationException.class)
public void secure() throws Exception {
assertEquals(this.service.secure(), "Hello Security");
assertThat("Hello Security").isEqualTo(this.service.secure());
}
@Test
public void authenticated() throws Exception {
SecurityContextHolder.getContext().setAuthentication(this.authentication);
assertEquals(this.service.secure(), "Hello Security");
assertThat("Hello Security").isEqualTo(this.service.secure());
}
@Test
public void preauth() throws Exception {
SecurityContextHolder.getContext().setAuthentication(this.authentication);
assertEquals(this.service.authorized(), "Hello World");
assertThat("Hello World").isEqualTo(this.service.authorized());
}
@Test(expected = AccessDeniedException.class)
public void denied() throws Exception {
SecurityContextHolder.getContext().setAuthentication(this.authentication);
assertEquals(this.service.denied(), "Goodbye World");
assertThat("Goodbye World").isEqualTo(this.service.denied());
}
@PropertySource("classpath:test.properties")