Start AssertJ Migration
Issue gh-3175
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package org.springframework.security.integration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class HttpNamespaceWithMultipleInterceptorsTests {
|
||||
request.setSession(createAuthenticatedSession("ROLE_0", "ROLE_1", "ROLE_2"));
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
fcp.doFilter(request, response, new MockFilterChain());
|
||||
assertEquals(200, response.getStatus());
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,7 +45,7 @@ public class HttpNamespaceWithMultipleInterceptorsTests {
|
||||
request.setSession(createAuthenticatedSession("ROLE_0"));
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
fcp.doFilter(request, response, new MockFilterChain());
|
||||
assertEquals(403, response.getStatus());
|
||||
assertThat(response.getStatus()).isEqualTo(403);
|
||||
}
|
||||
|
||||
public HttpSession createAuthenticatedSession(String... roles) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.security.integration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -33,7 +33,7 @@ public class HttpPathParameterStrippingTests {
|
||||
request.setSession(createAuthenticatedSession("ROLE_USER"));
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
fcp.doFilter(request, response, new MockFilterChain());
|
||||
assertEquals(403, response.getStatus());
|
||||
assertThat(response.getStatus()).isEqualTo(403);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,7 +43,7 @@ public class HttpPathParameterStrippingTests {
|
||||
request.setSession(createAuthenticatedSession("ROLE_USER"));
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
fcp.doFilter(request, response, new MockFilterChain());
|
||||
assertEquals(403, response.getStatus());
|
||||
assertThat(response.getStatus()).isEqualTo(403);
|
||||
|
||||
// Try with pathInfo
|
||||
request = new MockHttpServletRequest();
|
||||
@@ -52,7 +52,7 @@ public class HttpPathParameterStrippingTests {
|
||||
request.setSession(createAuthenticatedSession("ROLE_USER"));
|
||||
response = new MockHttpServletResponse();
|
||||
fcp.doFilter(request, response, new MockFilterChain());
|
||||
assertEquals(403, response.getStatus());
|
||||
assertThat(response.getStatus()).isEqualTo(403);
|
||||
}
|
||||
|
||||
public HttpSession createAuthenticatedSession(String... roles) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.security.integration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -18,6 +18,6 @@ public class SEC933ApplicationContextTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleApplicationContextBootstrap() throws Exception {
|
||||
assertNotNull(userDetailsService);
|
||||
assertThat(userDetailsService).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ProtectPointcutPerformanceTests implements ApplicationContextAware
|
||||
}
|
||||
}
|
||||
sw.stop();
|
||||
// assertTrue(sw.getTotalTimeMillis() < 1000);
|
||||
// assertThat(sw.getTotalTimeMillis() < 1000).isTrue();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SessionRegistryImplMTTests extends TestCase {
|
||||
pause(250);
|
||||
}
|
||||
|
||||
assertFalse("Thread errors detected; review log output for details", errorOccurred);
|
||||
assertThat(errorOccurred).as("Thread errors detected; review log output for details").isFalse();
|
||||
}
|
||||
|
||||
public void testConcurrentRemovalIsSafe() {
|
||||
|
||||
@@ -27,17 +27,17 @@ public class SecurityContextHolderMTTests extends TestCase{
|
||||
|
||||
public void testSynchronizationCustomStrategyLoading() {
|
||||
SecurityContextHolder.setStrategyName(InheritableThreadLocalSecurityContextHolderStrategy.class.getName());
|
||||
assertTrue(new SecurityContextHolder().toString()
|
||||
assertThat(new SecurityContextHolder().toString().isTrue()
|
||||
.lastIndexOf("SecurityContextHolder[strategy='org.springframework.security.context.InheritableThreadLocalSecurityContextHolderStrategy'") != -1);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, true);
|
||||
assertEquals("Thread errors detected; review log output for details", 0, errors);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
}
|
||||
|
||||
public void testSynchronizationGlobal() throws Exception {
|
||||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, true, false);
|
||||
assertEquals("Thread errors detected; review log output for details", 0, errors);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
}
|
||||
|
||||
public void testSynchronizationInheritableThreadLocal()
|
||||
@@ -45,14 +45,14 @@ public class SecurityContextHolderMTTests extends TestCase{
|
||||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, true);
|
||||
assertEquals("Thread errors detected; review log output for details", 0, errors);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
}
|
||||
|
||||
public void testSynchronizationThreadLocal() throws Exception {
|
||||
SecurityContextHolder.clearContext();
|
||||
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_THREADLOCAL);
|
||||
loadStartAndWaitForThreads(true, "Main_", NUM_THREADS, false, false);
|
||||
assertEquals("Thread errors detected; review log output for details", 0, errors);
|
||||
assertThat(errors).as("Thread errors detected; review log output for details").isEqualTo(0);
|
||||
}
|
||||
|
||||
private void startAndRun(Thread[] threads) {
|
||||
|
||||
@@ -2,7 +2,8 @@ package org.springframework.security.integration;
|
||||
|
||||
import net.sourceforge.jwebunit.junit.WebTester;
|
||||
|
||||
import org.junit.Assert;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.springframework.security.core.session.SessionRegistry;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -29,8 +30,8 @@ public class CustomConcurrentSessionManagementTests extends
|
||||
tester2.setTextField("password", "jimispassword");
|
||||
tester2.setIgnoreFailingStatusCodes(true);
|
||||
tester2.submit();
|
||||
Assert.assertTrue(tester2.getServerResponse().contains(
|
||||
"Maximum sessions of 1 for this principal exceeded"));
|
||||
assertThat(tester2.getServerResponse()).contains(
|
||||
"Maximum sessions of 1 for this principal exceeded");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,6 +51,6 @@ public class CustomConcurrentSessionManagementTests extends
|
||||
tester2.setTextField("password", "bessiespassword");
|
||||
tester2.setIgnoreFailingStatusCodes(true);
|
||||
tester2.submit();
|
||||
Assert.assertTrue(tester2.getServerResponse().contains("A secure page"));
|
||||
assertThat(tester2.getServerResponse()).contains("A secure page");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.springframework.security.integration;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import net.sourceforge.jwebunit.junit.WebTester;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -65,7 +64,7 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes
|
||||
tester.checkCheckbox("remember-me");
|
||||
login("jimi", "jimispassword");
|
||||
Cookie rememberMe = getRememberMeCookie();
|
||||
assertNotNull(rememberMe);
|
||||
assertThat(rememberMe).isNotNull();
|
||||
tester.closeBrowser();
|
||||
|
||||
tester.getTestContext().addCookie(rememberMe);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springframework.security.integration;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -20,14 +21,14 @@ public final class JspTaglibTests extends AbstractWebServerIntegrationTests {
|
||||
beginAt("secure/authenticationTagTestPage.jsp");
|
||||
login("theescapist<>&.", "theescapistspassword");
|
||||
String response = tester.getServerResponse();
|
||||
assertTrue(response
|
||||
.contains("This is the unescaped authentication name: theescapist<>&."));
|
||||
assertTrue(response
|
||||
.contains("This is the unescaped principal.username: theescapist<>&."));
|
||||
assertTrue(response
|
||||
.contains("This is the authentication name: theescapist<>&."));
|
||||
assertTrue(response
|
||||
.contains("This is the principal.username: theescapist<>&."));
|
||||
assertThat(response)
|
||||
.contains("This is the unescaped authentication name: theescapist<>&.");
|
||||
assertThat(response)
|
||||
.contains("This is the unescaped principal.username: theescapist<>&.");
|
||||
assertThat(response)
|
||||
.contains("This is the authentication name: theescapist<>&.");
|
||||
assertThat(response)
|
||||
.contains("This is the principal.username: theescapist<>&.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -35,10 +36,10 @@ public final class JspTaglibTests extends AbstractWebServerIntegrationTests {
|
||||
beginAt("secure/authorizationTagTestPage.jsp");
|
||||
login("bessie", "bessiespassword");
|
||||
String response = tester.getServerResponse();
|
||||
assertTrue(response
|
||||
.contains("Users can see this and 'allowed' variable is true."));
|
||||
assertFalse(response.contains("Role X users (nobody) can see this."));
|
||||
assertTrue(response.contains("Role X expression evaluates to false"));
|
||||
assertThat(response)
|
||||
.contains("Users can see this and 'allowed' variable is true.");
|
||||
assertThat(response).doesNotContain("Role X users (nobody) can see this.");
|
||||
assertThat(response).contains("Role X expression evaluates to false");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user