This is an automated email from the ASF dual-hosted git repository. oleewere pushed a commit to branch branch-feature-logsearch-ga in repository https://gitbox.apache.org/repos/asf/ambari.git
commit 8f0a544fd28e987a7febe5517d83c8b23779e01d Author: Oliver Szabo <[email protected]> AuthorDate: Sun Sep 23 21:01:38 2018 +0200 simplify tests --- .../LogsearchFileAuthenticationProviderTest.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProviderTest.java b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProviderTest.java index 1027d77..31cf22b 100644 --- a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProviderTest.java +++ b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProviderTest.java @@ -33,14 +33,14 @@ import org.springframework.security.crypto.password.PasswordEncoder; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertSame; -import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; import static org.easymock.EasyMock.strictMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import java.lang.reflect.Field; -import java.util.Arrays; +import java.util.Collections; import java.util.List; public class LogsearchFileAuthenticationProviderTest { @@ -90,7 +90,7 @@ public class LogsearchFileAuthenticationProviderTest { try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch(BadCredentialsException e) { assertEquals("Username can't be null or empty.", e.getMessage()); } @@ -108,7 +108,7 @@ public class LogsearchFileAuthenticationProviderTest { try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch(BadCredentialsException e) { assertEquals("Username can't be null or empty.", e.getMessage()); } @@ -127,7 +127,7 @@ public class LogsearchFileAuthenticationProviderTest { try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch(BadCredentialsException e) { assertEquals("Password can't be null or empty.", e.getMessage()); } @@ -145,7 +145,7 @@ public class LogsearchFileAuthenticationProviderTest { try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch(BadCredentialsException e) { assertEquals("Password can't be null or empty.", e.getMessage()); } @@ -163,7 +163,7 @@ public class LogsearchFileAuthenticationProviderTest { Authentication authentication = new TestingAuthenticationToken("principal", "credentials"); try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch (BadCredentialsException e) { assertEquals("User not found.", e.getMessage()); } @@ -173,7 +173,7 @@ public class LogsearchFileAuthenticationProviderTest { @Test public void testAuthenticationNoPassword() { - List<GrantedAuthority> grantedAuths = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); + List<GrantedAuthority> grantedAuths = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")); User user = new User("principal", null, grantedAuths); expect(mockAuthPropsConfig.isAuthFileEnabled()).andReturn(true); @@ -184,7 +184,7 @@ public class LogsearchFileAuthenticationProviderTest { Authentication authentication = new TestingAuthenticationToken("principal", "credentials"); try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch (BadCredentialsException e) { assertEquals("Password can't be null or empty.", e.getMessage()); } @@ -194,7 +194,7 @@ public class LogsearchFileAuthenticationProviderTest { @Test public void testAuthenticationWrongPassword() { - List<GrantedAuthority> grantedAuths = Arrays.<GrantedAuthority>asList(new SimpleGrantedAuthority("ROLE_USER")); + List<GrantedAuthority> grantedAuths = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")); User user = new User("principal", passwordEncoder.encode("notCredentials"), grantedAuths); expect(mockAuthPropsConfig.isAuthFileEnabled()).andReturn(true); @@ -205,7 +205,7 @@ public class LogsearchFileAuthenticationProviderTest { Authentication authentication = new TestingAuthenticationToken("principal", "credentials"); try { provider.authenticate(authentication); - assertTrue("Should have thrown BadCredentialsException", false); + fail("Should have thrown BadCredentialsException"); } catch (BadCredentialsException e) { assertEquals("Wrong password.", e.getMessage()); } @@ -215,7 +215,7 @@ public class LogsearchFileAuthenticationProviderTest { @Test public void testAuthenticationSuccessful() { - List<GrantedAuthority> grantedAuths = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); + List<GrantedAuthority> grantedAuths = Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")); String encodedPassword = passwordEncoder.encode("credentials"); User user = new User("principal", encodedPassword, grantedAuths);
