Skip to content

Commit 2428595

Browse files
committed
Polish
1 parent 80767ff commit 2428595

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,13 +26,19 @@
2626
import org.springframework.mock.web.test.MockHttpServletRequest;
2727
import org.springframework.mock.web.test.MockHttpServletResponse;
2828

29-
import static org.hamcrest.Matchers.*;
30-
import static org.junit.Assert.*;
31-
import static org.mockito.BDDMockito.*;
29+
import static org.hamcrest.Matchers.containsString;
30+
import static org.junit.Assert.assertEquals;
31+
import static org.junit.Assert.assertFalse;
32+
import static org.junit.Assert.assertNotNull;
33+
import static org.junit.Assert.assertSame;
34+
import static org.junit.Assert.assertThat;
35+
import static org.junit.Assert.assertTrue;
36+
import static org.junit.Assert.fail;
37+
import static org.mockito.BDDMockito.mock;
38+
import static org.mockito.BDDMockito.verify;
3239

3340
/**
3441
* A test fixture with a {@link StandardServletAsyncWebRequest}.
35-
*
3642
* @author Rossen Stoyanchev
3743
*/
3844
public class StandardServletAsyncWebRequestTests {
@@ -43,6 +49,7 @@ public class StandardServletAsyncWebRequestTests {
4349

4450
private MockHttpServletResponse response;
4551

52+
4653
@Before
4754
public void setup() {
4855
this.request = new MockHttpServletRequest();
@@ -52,10 +59,10 @@ public void setup() {
5259
this.asyncRequest.setTimeout(44*1000L);
5360
}
5461

62+
5563
@Test
5664
public void isAsyncStarted() throws Exception {
5765
assertFalse(this.asyncRequest.isAsyncStarted());
58-
5966
this.asyncRequest.startAsync();
6067
assertTrue(this.asyncRequest.isAsyncStarted());
6168
}
@@ -64,12 +71,11 @@ public void isAsyncStarted() throws Exception {
6471
public void startAsync() throws Exception {
6572
this.asyncRequest.startAsync();
6673

67-
MockAsyncContext asyncContext = (MockAsyncContext) this.request.getAsyncContext();
68-
69-
assertNotNull(asyncContext);
70-
assertEquals("Timeout value not set", 44 * 1000, asyncContext.getTimeout());
71-
assertEquals(1, asyncContext.getListeners().size());
72-
assertSame(this.asyncRequest, asyncContext.getListeners().get(0));
74+
MockAsyncContext context = (MockAsyncContext) this.request.getAsyncContext();
75+
assertNotNull(context);
76+
assertEquals("Timeout value not set", 44 * 1000, context.getTimeout());
77+
assertEquals(1, context.getListeners().size());
78+
assertSame(this.asyncRequest, context.getListeners().get(0));
7379
}
7480

7581
@Test
@@ -79,10 +85,9 @@ public void startAsyncMultipleTimes() throws Exception {
7985
this.asyncRequest.startAsync();
8086
this.asyncRequest.startAsync(); // idempotent
8187

82-
MockAsyncContext asyncContext = (MockAsyncContext) this.request.getAsyncContext();
83-
84-
assertNotNull(asyncContext);
85-
assertEquals(1, asyncContext.getListeners().size());
88+
MockAsyncContext context = (MockAsyncContext) this.request.getAsyncContext();
89+
assertNotNull(context);
90+
assertEquals(1, context.getListeners().size());
8691
}
8792

8893
@Test
@@ -118,10 +123,8 @@ public void onTimeoutDefaultBehavior() throws Exception {
118123
@Test
119124
public void onTimeoutTimeoutHandler() throws Exception {
120125
Runnable timeoutHandler = mock(Runnable.class);
121-
122126
this.asyncRequest.addTimeoutHandler(timeoutHandler);
123127
this.asyncRequest.onTimeout(new AsyncEvent(null));
124-
125128
verify(timeoutHandler).run();
126129
}
127130

0 commit comments

Comments
 (0)