From b72d182ff8a3a62395e220f5fcf29e4c7ec5f46f Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 3 Jan 2019 11:09:49 +0900 Subject: [PATCH] Polish tests --- .../security/config/InvalidConfigurationTests.java | 6 ++++-- .../oauth2/client/registration/ClientRegistrationsTest.java | 2 +- .../security/oauth2/jwt/JwtDecodersTests.java | 2 +- .../rememberme/AbstractRememberMeServicesTests.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java b/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java index 5240b012419..447825c483f 100644 --- a/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/InvalidConfigurationTests.java @@ -16,6 +16,7 @@ package org.springframework.security.config; import static org.assertj.core.api.Assertions.*; +import static org.junit.Assert.fail; import org.junit.After; import org.junit.Test; @@ -57,14 +58,15 @@ public void authenticationProviderCannotAppearAtTopLevel() { public void missingAuthenticationManagerGivesSensibleErrorMessage() { try { setContext(""); + fail(); } catch (BeanCreationException e) { Throwable cause = ultimateCause(e); assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue(); NoSuchBeanDefinitionException nsbe = (NoSuchBeanDefinitionException) cause; assertThat(nsbe.getBeanName()).isEqualTo(BeanIds.AUTHENTICATION_MANAGER); - assertThat(nsbe.getMessage().endsWith( - AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE)); + assertThat(nsbe.getMessage()).endsWith( + AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE); } } diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java index 5ec0e07a8fe..7c61537c51c 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java @@ -140,7 +140,7 @@ public void issuerWhenAllInformationThenSuccess() throws Exception { @Test public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception { assertThat(registration("")).isNotNull(); - assertThat(this.issuer.endsWith("/")).isTrue(); + assertThat(this.issuer).endsWith("/"); } /** diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java index ffee56264fd..c42a00ce3d9 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java @@ -97,7 +97,7 @@ public void issuerWhenContainsTrailingSlashThenSuccess() { prepareOpenIdConfigurationResponse(); this.server.enqueue(new MockResponse().setBody(JWK_SET)); assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull(); - assertThat(this.issuer.endsWith("/")).isTrue(); + assertThat(this.issuer).endsWith("/"); } @Test diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java index ae569f2e494..0520590f682 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServicesTests.java @@ -92,7 +92,7 @@ public void cookieShouldBeCorrectlyEncodedAndDecoded() throws Exception { String encoded = services.encodeCookie(cookie); // '=' aren't allowed in version 0 cookies. - assertThat(encoded.endsWith("=")).isFalse(); + assertThat(encoded).doesNotEndWith("="); String[] decoded = services.decodeCookie(encoded); assertThat(decoded).containsExactly("name:with:colon", "cookie", "tokens", "blah");