-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4775 from eclipse/jetty-10.0.x-4771-WebSocketMess…
…ageHandlerTests Issue #4771 - cleanup and add tests for the unused ws message handlers
- Loading branch information
Showing
45 changed files
with
1,231 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../test/java/org/eclipse/jetty/websocket/javax/tests/handlers/AbstractAnnotatedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under | ||
// the terms of the Eclipse Public License 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// This Source Code may also be made available under the following | ||
// Secondary Licenses when the conditions for such availability set | ||
// forth in the Eclipse Public License, v. 2.0 are satisfied: | ||
// the Apache License v2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.websocket.javax.tests.handlers; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
import javax.websocket.EndpointConfig; | ||
import javax.websocket.OnError; | ||
import javax.websocket.OnOpen; | ||
import javax.websocket.Session; | ||
import javax.websocket.server.ServerEndpoint; | ||
|
||
@ServerEndpoint("/") | ||
public class AbstractAnnotatedHandler | ||
{ | ||
protected Session _session; | ||
|
||
@OnOpen | ||
public void onOpen(Session session, EndpointConfig config) | ||
{ | ||
_session = session; | ||
} | ||
|
||
@OnError | ||
public void onError(Session session, Throwable thr) | ||
{ | ||
thr.printStackTrace(); | ||
} | ||
|
||
public void sendText(String message, boolean last) | ||
{ | ||
try | ||
{ | ||
_session.getBasicRemote().sendText(message, last); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void sendBinary(ByteBuffer message, boolean last) | ||
{ | ||
try | ||
{ | ||
_session.getBasicRemote().sendBinary(message, last); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/handlers/AbstractHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under | ||
// the terms of the Eclipse Public License 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// This Source Code may also be made available under the following | ||
// Secondary Licenses when the conditions for such availability set | ||
// forth in the Eclipse Public License, v. 2.0 are satisfied: | ||
// the Apache License v2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.websocket.javax.tests.handlers; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
import javax.websocket.Endpoint; | ||
import javax.websocket.EndpointConfig; | ||
import javax.websocket.MessageHandler; | ||
import javax.websocket.Session; | ||
|
||
public class AbstractHandler extends Endpoint implements MessageHandler | ||
{ | ||
protected Session _session; | ||
|
||
@Override | ||
public void onOpen(Session session, EndpointConfig config) | ||
{ | ||
_session = session; | ||
_session.addMessageHandler(this); | ||
} | ||
|
||
@Override | ||
public void onError(Session session, Throwable thr) | ||
{ | ||
thr.printStackTrace(); | ||
} | ||
|
||
public void sendText(String message, boolean last) | ||
{ | ||
try | ||
{ | ||
_session.getBasicRemote().sendText(message, last); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void sendBinary(ByteBuffer message, boolean last) | ||
{ | ||
try | ||
{ | ||
_session.getBasicRemote().sendBinary(message, last); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.