Spring Cleaning in December
- Delete unused imports - Delete unused code - Clean up warnings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,9 @@ import java.util.Map;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.junit.Before;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.web.socket.handler.TestPrincipal;
|
||||
@@ -38,16 +39,11 @@ import static org.mockito.BDDMockito.*;
|
||||
*/
|
||||
public class JettyWebSocketSessionTests {
|
||||
|
||||
private Map<String,Object> attributes;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.attributes = new HashMap<>();
|
||||
}
|
||||
private final Map<String, Object> attributes = new HashMap<>();
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalWithConstructorArg() {
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
JettyWebSocketSession session = new JettyWebSocketSession(attributes, user);
|
||||
@@ -56,8 +52,8 @@ public class JettyWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalFromNativeSession() {
|
||||
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
|
||||
UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
|
||||
@@ -80,8 +76,8 @@ public class JettyWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalNotAvailable() {
|
||||
|
||||
UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
|
||||
given(request.getUserPrincipal()).willReturn(null);
|
||||
|
||||
@@ -102,8 +98,8 @@ public class JettyWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getAcceptedProtocol() {
|
||||
|
||||
String protocol = "foo";
|
||||
|
||||
UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2002-2014 the original author or authors.
|
||||
/* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -36,19 +36,13 @@ import static org.mockito.BDDMockito.*;
|
||||
*/
|
||||
public class StandardWebSocketSessionTests {
|
||||
|
||||
private HttpHeaders headers;
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
private Map<String,Object> attributes;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.headers = new HttpHeaders();
|
||||
this.attributes = new HashMap<>();
|
||||
}
|
||||
private final Map<String, Object> attributes = new HashMap<>();
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalWithConstructorArg() {
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
StandardWebSocketSession session = new StandardWebSocketSession(this.headers, this.attributes, null, null, user);
|
||||
@@ -57,8 +51,8 @@ public class StandardWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalWithNativeSession() {
|
||||
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
|
||||
Session nativeSession = Mockito.mock(Session.class);
|
||||
@@ -71,8 +65,8 @@ public class StandardWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getPrincipalNone() {
|
||||
|
||||
Session nativeSession = Mockito.mock(Session.class);
|
||||
given(nativeSession.getUserPrincipal()).willReturn(null);
|
||||
|
||||
@@ -86,8 +80,8 @@ public class StandardWebSocketSessionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void getAcceptedProtocol() {
|
||||
|
||||
String protocol = "foo";
|
||||
|
||||
Session nativeSession = Mockito.mock(Session.class);
|
||||
|
||||
Reference in New Issue
Block a user