Remove Compiler Warnings
* Fixes Generics * Remove unused imports * Ignore serialize warnings in tests Fixes gh-40
This commit is contained in:
@@ -19,7 +19,6 @@ import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.session.MapSession;
|
||||
import org.springframework.session.Session;
|
||||
import org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession;
|
||||
|
||||
|
||||
@@ -122,6 +121,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getSessionNotFound() {
|
||||
String id = "abc";
|
||||
when(redisOperations.boundHashOps(getKey(id))).thenReturn(boundHashOperations);
|
||||
@@ -131,6 +131,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSessionFound() {
|
||||
String attrName = "attrName";
|
||||
MapSession expected = new MapSession();
|
||||
@@ -155,6 +156,7 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Map map(Object...objects) {
|
||||
Map<String,Object> result = new HashMap<String,Object>();
|
||||
if(objects == null) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -19,56 +20,57 @@ import java.util.List;
|
||||
import static org.fest.assertions.Assertions.*;
|
||||
|
||||
public class OncePerRequestFilterTests {
|
||||
private MockHttpServletRequest request;
|
||||
private MockHttpServletResponse response;
|
||||
private MockFilterChain chain;
|
||||
private OncePerRequestFilter filter;
|
||||
private HttpServlet servlet;
|
||||
private MockHttpServletRequest request;
|
||||
private MockHttpServletResponse response;
|
||||
private MockFilterChain chain;
|
||||
private OncePerRequestFilter filter;
|
||||
private HttpServlet servlet;
|
||||
|
||||
|
||||
private List<OncePerRequestFilter> invocations;
|
||||
private List<OncePerRequestFilter> invocations;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
servlet = new HttpServlet() {};
|
||||
request = new MockHttpServletRequest();
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
invocations = new ArrayList<OncePerRequestFilter>();
|
||||
filter = new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
invocations.add(this);
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Before
|
||||
@SuppressWarnings("serial")
|
||||
public void setup() {
|
||||
servlet = new HttpServlet() {};
|
||||
request = new MockHttpServletRequest();
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
invocations = new ArrayList<OncePerRequestFilter>();
|
||||
filter = new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
invocations.add(this);
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doFilterOnce() throws ServletException, IOException {
|
||||
filter.doFilter(request, response, chain);
|
||||
@Test
|
||||
public void doFilterOnce() throws ServletException, IOException {
|
||||
filter.doFilter(request, response, chain);
|
||||
|
||||
assertThat(invocations).containsOnly(filter);
|
||||
}
|
||||
assertThat(invocations).containsOnly(filter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doFilterMultiOnlyIvokesOnce() throws ServletException, IOException {
|
||||
filter.doFilter(request, response, new MockFilterChain(servlet, filter));
|
||||
@Test
|
||||
public void doFilterMultiOnlyIvokesOnce() throws ServletException, IOException {
|
||||
filter.doFilter(request, response, new MockFilterChain(servlet, filter));
|
||||
|
||||
assertThat(invocations).containsOnly(filter);
|
||||
}
|
||||
assertThat(invocations).containsOnly(filter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doFilterOtherSubclassInvoked() throws ServletException, IOException {
|
||||
OncePerRequestFilter filter2 = new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
invocations.add(this);
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
};
|
||||
filter.doFilter(request, response, new MockFilterChain(servlet, filter2));
|
||||
@Test
|
||||
public void doFilterOtherSubclassInvoked() throws ServletException, IOException {
|
||||
OncePerRequestFilter filter2 = new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
invocations.add(this);
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
};
|
||||
filter.doFilter(request, response, new MockFilterChain(servlet, filter2));
|
||||
|
||||
assertThat(invocations).containsOnly(filter, filter2);
|
||||
}
|
||||
assertThat(invocations).containsOnly(filter, filter2);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user