-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 #850 from Andreas-Bur/bug-834
Fix issue #834 by starting WebSocketWorker of the WebSocketServer in the start function
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 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
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
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,50 @@ | ||
package org.java_websocket.issues; | ||
|
||
import org.java_websocket.WebSocket; | ||
import org.java_websocket.handshake.ClientHandshake; | ||
import org.java_websocket.server.WebSocketServer; | ||
import org.java_websocket.util.SocketUtil; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.util.Set; | ||
|
||
public class Issue834Test { | ||
|
||
@Test(timeout = 1000) | ||
public void testNoNewThreads() throws IOException { | ||
|
||
Set<Thread> threadSet1 = Thread.getAllStackTraces().keySet(); | ||
|
||
new WebSocketServer(new InetSocketAddress(SocketUtil.getAvailablePort())) { | ||
@Override | ||
public void onOpen(WebSocket conn, ClientHandshake handshake) { | ||
} | ||
|
||
@Override | ||
public void onClose(WebSocket conn, int code, String reason, boolean remote) { | ||
} | ||
|
||
@Override | ||
public void onMessage(WebSocket conn, String message) { | ||
} | ||
|
||
@Override | ||
public void onError(WebSocket conn, Exception ex) { | ||
} | ||
|
||
@Override | ||
public void onStart() { | ||
} | ||
}; | ||
|
||
Set<Thread> threadSet2 = Thread.getAllStackTraces().keySet(); | ||
|
||
//checks that no threads are started in the constructor | ||
Assert.assertEquals(threadSet1, threadSet2); | ||
|
||
} | ||
|
||
} |