checkstyle fixes.

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
olivier lamy 2019-08-23 13:09:15 +10:00
parent 80d513e979
commit cf592469aa
10 changed files with 38 additions and 39 deletions

View File

@ -107,18 +107,18 @@ public class WriteTimeoutTest
@ServerEndpoint("/logSocket") @ServerEndpoint("/logSocket")
public static class LoggingSocket public static class LoggingSocket
{ {
private final Logger LOG = Log.getLogger(LoggingSocket.class); private final Logger log = Log.getLogger(LoggingSocket.class);
@OnMessage @OnMessage
public void onMessage(String msg) public void onMessage(String msg)
{ {
LOG.debug("onMessage(): {}", msg); log.debug("onMessage(): {}", msg);
} }
@OnError @OnError
public void onError(Throwable t) public void onError(Throwable t)
{ {
LOG.debug("onError(): {}", t); log.debug("onError(): {}", t);
} }
} }
} }

View File

@ -30,7 +30,7 @@ import javax.websocket.EndpointConfig;
*/ */
public class TimeEncoder implements Encoder.Text<Date> public class TimeEncoder implements Encoder.Text<Date>
{ {
private TimeZone GMT = TimeZone.getTimeZone("GMT"); private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
@Override @Override
public String encode(Date object) throws EncodeException public String encode(Date object) throws EncodeException

View File

@ -324,14 +324,14 @@ public class PrimitivesTextEchoTest
addCase(data, LongEchoSocket.class, Long.toString(0), "0"); addCase(data, LongEchoSocket.class, Long.toString(0), "0");
addCase(data, LongEchoSocket.class, Long.toString(100_000), "100000"); addCase(data, LongEchoSocket.class, Long.toString(100_000), "100000");
addCase(data, LongEchoSocket.class, Long.toString(-2_000_000), "-2000000"); addCase(data, LongEchoSocket.class, Long.toString(-2_000_000), "-2000000");
addCase(data, LongEchoSocket.class, Long.toString(300_000_000_000l), "300000000000"); addCase(data, LongEchoSocket.class, Long.toString(300_000_000_000L), "300000000000");
addCase(data, LongEchoSocket.class, Long.toString(Long.MAX_VALUE), Long.toString(Long.MAX_VALUE)); addCase(data, LongEchoSocket.class, Long.toString(Long.MAX_VALUE), Long.toString(Long.MAX_VALUE));
addCase(data, LongEchoSocket.class, Long.toString(Long.MIN_VALUE), Long.toString(Long.MIN_VALUE)); addCase(data, LongEchoSocket.class, Long.toString(Long.MIN_VALUE), Long.toString(Long.MIN_VALUE));
addCase(data, LongObjEchoSocket.class, Long.toString(0), "0"); addCase(data, LongObjEchoSocket.class, Long.toString(0), "0");
addCase(data, LongObjEchoSocket.class, Long.toString(100_000), "100000"); addCase(data, LongObjEchoSocket.class, Long.toString(100_000), "100000");
addCase(data, LongObjEchoSocket.class, Long.toString(-2_000_000), "-2000000"); addCase(data, LongObjEchoSocket.class, Long.toString(-2_000_000), "-2000000");
addCase(data, LongObjEchoSocket.class, Long.toString(300_000_000_000l), "300000000000"); addCase(data, LongObjEchoSocket.class, Long.toString(300_000_000_000L), "300000000000");
addCase(data, LongObjEchoSocket.class, Long.toString(Long.MAX_VALUE), Long.toString(Long.MAX_VALUE)); addCase(data, LongObjEchoSocket.class, Long.toString(Long.MAX_VALUE), Long.toString(Long.MAX_VALUE));
addCase(data, LongObjEchoSocket.class, Long.toString(Long.MIN_VALUE), Long.toString(Long.MIN_VALUE)); addCase(data, LongObjEchoSocket.class, Long.toString(Long.MIN_VALUE), Long.toString(Long.MIN_VALUE));

View File

@ -98,7 +98,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.2 * From Autobahn WebSocket Server Testcase 1.2.2
*/ */
@Test @Test
public void testParse_Binary_125BytePayload() throws InterruptedException public void testParseBinary125BytePayload() throws InterruptedException
{ {
int length = 125; int length = 125;
@ -128,7 +128,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.3 * From Autobahn WebSocket Server Testcase 1.2.3
*/ */
@Test @Test
public void testParse_Binary_126BytePayload() throws InterruptedException public void testParseBinary126BytePayload() throws InterruptedException
{ {
int length = 126; int length = 126;
@ -161,7 +161,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.4 * From Autobahn WebSocket Server Testcase 1.2.4
*/ */
@Test @Test
public void testParse_Binary_127BytePayload() throws InterruptedException public void testParseBinary127BytePayload() throws InterruptedException
{ {
int length = 127; int length = 127;
@ -193,7 +193,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.5 * From Autobahn WebSocket Server Testcase 1.2.5
*/ */
@Test @Test
public void testParse_Binary_128BytePayload() throws InterruptedException public void testParseBinary128BytePayload() throws InterruptedException
{ {
int length = 128; int length = 128;
@ -225,7 +225,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.6 * From Autobahn WebSocket Server Testcase 1.2.6
*/ */
@Test @Test
public void testParse_Binary_65535BytePayload() throws InterruptedException public void testParseBinary65535BytePayload() throws InterruptedException
{ {
int length = 65535; int length = 65535;
@ -257,7 +257,7 @@ public class ParserTest
* From Autobahn WebSocket Server Testcase 1.2.7 * From Autobahn WebSocket Server Testcase 1.2.7
*/ */
@Test @Test
public void testParse_Binary_65536BytePayload() throws InterruptedException public void testParseBinary65536BytePayload() throws InterruptedException
{ {
int length = 65536; int length = 65536;

View File

@ -39,7 +39,7 @@ public class RawFrameBuilder
buf.put(b); buf.put(b);
} }
public static void putLengthAndMask(ByteBuffer buf, int length, byte mask[]) public static void putLengthAndMask(ByteBuffer buf, int length, byte[] mask)
{ {
if (mask != null) if (mask != null)
{ {
@ -53,7 +53,7 @@ public class RawFrameBuilder
} }
} }
public static void mask(final byte[] data, final byte mask[]) public static void mask(final byte[] data, final byte[] mask)
{ {
assertThat("Mask.length", mask.length, is(4)); assertThat("Mask.length", mask.length, is(4));
int len = data.length; int len = data.length;
@ -96,7 +96,7 @@ public class RawFrameBuilder
} }
} }
public static void putMask(ByteBuffer buf, byte mask[]) public static void putMask(ByteBuffer buf, byte[] mask)
{ {
assertThat("Mask.length", mask.length, is(4)); assertThat("Mask.length", mask.length, is(4));
buf.put(mask); buf.put(mask);

View File

@ -76,7 +76,7 @@ public class TestAsyncFrameHandler implements FrameHandler
@Override @Override
public void onError(Throwable cause, Callback callback) public void onError(Throwable cause, Callback callback)
{ {
LOG.info("[{}] onError {} ", name, cause == null?null:cause.toString()); LOG.info("[{}] onError {} ", name, cause == null ? null : cause.toString());
error = cause; error = cause;
errorLatch.countDown(); errorLatch.countDown();
callback.succeeded(); callback.succeeded();

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.util.log.Logger;
public class TestMessageHandler extends MessageHandler public class TestMessageHandler extends MessageHandler
{ {
protected final Logger LOG = Log.getLogger(TestMessageHandler.class); protected static final Logger LOG = Log.getLogger(TestMessageHandler.class);
public CoreSession coreSession; public CoreSession coreSession;
public BlockingQueue<String> textMessages = new BlockingArrayQueue<>(); public BlockingQueue<String> textMessages = new BlockingArrayQueue<>();

View File

@ -79,7 +79,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block * Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block
*/ */
@Test @Test
public void testDraft21_Hello_UnCompressedBlock() public void testDraft21HelloUnCompressedBlock()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -100,7 +100,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block (with fragmentation) * Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block (with fragmentation)
*/ */
@Test @Test
public void testDraft21_Hello_UnCompressedBlock_Fragmented() public void testDraft21HelloUnCompressedBlockFragmented()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -123,7 +123,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.2: Sharing LZ77 Sliding Window * Section 8.2.3.2: Sharing LZ77 Sliding Window
*/ */
@Test @Test
public void testDraft21_SharingL77SlidingWindow_ContextTakeover() public void testDraft21SharingL77SlidingWindowContextTakeover()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -146,7 +146,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.2: Sharing LZ77 Sliding Window * Section 8.2.3.2: Sharing LZ77 Sliding Window
*/ */
@Test @Test
public void testDraft21_SharingL77SlidingWindow_NoContextTakeover() public void testDraft21SharingL77SlidingWindowNoContextTakeover()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -170,7 +170,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.3: Using a DEFLATE Block with No Compression * Section 8.2.3.3: Using a DEFLATE Block with No Compression
*/ */
@Test @Test
public void testDraft21_DeflateBlockWithNoCompression() public void testDraft21DeflateBlockWithNoCompression()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -189,7 +189,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.4: Using a DEFLATE Block with BFINAL Set to 1 * Section 8.2.3.4: Using a DEFLATE Block with BFINAL Set to 1
*/ */
@Test @Test
public void testDraft21_DeflateBlockWithBFinal1() public void testDraft21DeflateBlockWithBFinal1()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -209,7 +209,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Section 8.2.3.5: Two DEFLATE Blocks in 1 Message * Section 8.2.3.5: Two DEFLATE Blocks in 1 Message
*/ */
@Test @Test
public void testDraft21_TwoDeflateBlocksOneMessage() public void testDraft21TwoDeflateBlocksOneMessage()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -227,7 +227,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* Decode fragmented message (3 parts: TEXT, CONTINUATION, CONTINUATION) * Decode fragmented message (3 parts: TEXT, CONTINUATION, CONTINUATION)
*/ */
@Test @Test
public void testParseFragmentedMessage_Good() public void testParseFragmentedMessageGood()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -256,7 +256,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
* </p> * </p>
*/ */
@Test @Test
public void testParseFragmentedMessage_BadRsv1() public void testParseFragmentedMessageBadRsv1()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate");
@ -489,7 +489,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
} }
@Test @Test
public void testPyWebSocket_Client_NoContextTakeover_ThreeOra() public void testPyWebSocketClientNoContextTakeoverThreeOra()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate; client_max_window_bits; client_no_context_takeover"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate; client_max_window_bits; client_no_context_takeover");
@ -497,7 +497,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
// Captured from Pywebsocket (r790) - 3 messages with similar parts. // Captured from Pywebsocket (r790) - 3 messages with similar parts.
tester.parseIncomingHex( // context takeover (3 messages) tester.parseIncomingHex(// context takeover (3 messages)
"c1 09 0a c9 2f 4a 0c 01 62 00 00", // ToraTora "c1 09 0a c9 2f 4a 0c 01 62 00 00", // ToraTora
"c1 0b 72 2c c9 2f 4a 74 cb 01 12 00 00", // AtoraFlora "c1 0b 72 2c c9 2f 4a 74 cb 01 12 00 00", // AtoraFlora
"c1 0b 0a c8 c8 c9 2f 4a 0c 01 62 00 00" // PhloraTora "c1 0b 0a c8 c8 c9 2f 4a 0c 01 62 00 00" // PhloraTora
@ -507,7 +507,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
} }
@Test @Test
public void testPyWebSocket_Client_ToraToraTora() public void testPyWebSocketClientToraToraTora()
{ {
ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate; client_max_window_bits"); ExtensionTool.Tester tester = clientExtensions.newTester("permessage-deflate; client_max_window_bits");
@ -525,7 +525,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
} }
@Test @Test
public void testPyWebSocket_Server_NoContextTakeover_ThreeOra() public void testPyWebSocketServerNoContextTakeoverThreeOra()
{ {
ExtensionTool.Tester tester = serverExtensions.newTester("permessage-deflate; client_max_window_bits; client_no_context_takeover"); ExtensionTool.Tester tester = serverExtensions.newTester("permessage-deflate; client_max_window_bits; client_no_context_takeover");
@ -533,7 +533,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
// Captured from Pywebsocket (r790) - 3 messages with similar parts. // Captured from Pywebsocket (r790) - 3 messages with similar parts.
tester.parseIncomingHex( // context takeover (3 messages) tester.parseIncomingHex(// context takeover (3 messages)
"c1 89 88 bc 1b b1 82 75 34 fb 84 bd 79 b1 88", // ToraTora "c1 89 88 bc 1b b1 82 75 34 fb 84 bd 79 b1 88", // ToraTora
"c1 8b 50 86 88 b2 22 aa 41 9d 1a f2 43 b3 42 86 88", // AtoraFlora "c1 8b 50 86 88 b2 22 aa 41 9d 1a f2 43 b3 42 86 88", // AtoraFlora
"c1 8b e2 3e 05 53 e8 f6 cd 9a cd 74 09 52 80 3e 05" // PhloraTora "c1 8b e2 3e 05 53 e8 f6 cd 9a cd 74 09 52 80 3e 05" // PhloraTora
@ -543,7 +543,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
} }
@Test @Test
public void testPyWebSocket_Server_ToraToraTora() public void testPyWebSocketServerToraToraTora()
{ {
ExtensionTool.Tester tester = serverExtensions.newTester("permessage-deflate; client_max_window_bits"); ExtensionTool.Tester tester = serverExtensions.newTester("permessage-deflate; client_max_window_bits");
@ -551,7 +551,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
// Captured from Pywebsocket (r790) - "tora" sent 3 times. // Captured from Pywebsocket (r790) - "tora" sent 3 times.
tester.parseIncomingHex( // context takeover (3 messages) tester.parseIncomingHex(// context takeover (3 messages)
"c1 86 69 39 fe 91 43 f0 d1 db 6d 39", // tora 1 "c1 86 69 39 fe 91 43 f0 d1 db 6d 39", // tora 1
"c1 85 2d f3 eb 96 07 f2 89 96 2d", // tora 2 "c1 85 2d f3 eb 96 07 f2 89 96 2d", // tora 2
"c1 84 53 ad a5 34 51 cc a5 34" // tora 3 "c1 84 53 ad a5 34 51 cc a5 34" // tora 3

View File

@ -188,7 +188,7 @@ class WebSocketProxy
// the callback is saved until a close response comes in sendFrame from Server2Proxy // the callback is saved until a close response comes in sendFrame from Server2Proxy
// if the callback was completed here then core would send its own close response // if the callback was completed here then core would send its own close response
closeCallback = callback; closeCallback = callback;
sendCallback = Callback.from(()->{}, callback::failed); sendCallback = Callback.from(() -> {}, callback::failed);
} }
break; break;
@ -383,7 +383,7 @@ class WebSocketProxy
try try
{ {
state = State.CONNECTING; state = State.CONNECTING;
client.connect(this, serverUri).whenComplete((s,t)-> client.connect(this, serverUri).whenComplete((s,t) ->
{ {
if (t != null) if (t != null)
onConnectFailure(t, callback); onConnectFailure(t, callback);
@ -526,7 +526,7 @@ class WebSocketProxy
{ {
state = State.ISHUT; state = State.ISHUT;
closeCallback = callback; closeCallback = callback;
sendCallback = Callback.from(()->{}, callback::failed); sendCallback = Callback.from(() -> {}, callback::failed);
} }
break; break;
@ -686,4 +686,4 @@ class WebSocketProxy
return "Server2Proxy:" + getState(); return "Server2Proxy:" + getState();
} }
} }
} }

View File

@ -221,7 +221,6 @@ public class WebSocketProxyTest
assertThat(closeStatus.getReason(), containsString("Failed to upgrade to websocket: Unexpected HTTP Response Status Code:")); assertThat(closeStatus.getReason(), containsString("Failed to upgrade to websocket: Unexpected HTTP Response Status Code:"));
} }
@Test @Test
public void testClientError() throws Exception public void testClientError() throws Exception
{ {
@ -241,7 +240,7 @@ public class WebSocketProxyTest
ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(_client, new URI("ws://localhost:8080/proxy/"), clientFrameHandler); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(_client, new URI("ws://localhost:8080/proxy/"), clientFrameHandler);
upgradeRequest.setConfiguration(defaultCustomizer); upgradeRequest.setConfiguration(defaultCustomizer);
CompletableFuture<CoreSession> response = _client.connect(upgradeRequest); CompletableFuture<CoreSession> response = _client.connect(upgradeRequest);
Exception e = assertThrows(ExecutionException.class, ()->response.get(5, TimeUnit.SECONDS)); Exception e = assertThrows(ExecutionException.class, () -> response.get(5, TimeUnit.SECONDS));
assertThat(e.getMessage(), containsString("simulated client onOpen error")); assertThat(e.getMessage(), containsString("simulated client onOpen error"));
assertTrue(clientFrameHandler.closeLatch.await(5, TimeUnit.SECONDS)); assertTrue(clientFrameHandler.closeLatch.await(5, TimeUnit.SECONDS));
assertTrue(serverFrameHandler.closeLatch.await(5, TimeUnit.SECONDS)); assertTrue(serverFrameHandler.closeLatch.await(5, TimeUnit.SECONDS));