generated from BudDavis/TicTacToe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package uta.cse3310; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.Map; | ||
|
||
import org.java_websocket.client.WebSocketClient; | ||
import org.java_websocket.drafts.Draft; | ||
import org.java_websocket.handshake.ServerHandshake; | ||
|
||
public class AppClient extends WebSocketClient { | ||
public String msg; | ||
|
||
public AppClient(URI serverUri, Draft draft) { | ||
super(serverUri, draft); | ||
} | ||
|
||
public AppClient(URI serverURI) throws URISyntaxException { | ||
super(serverURI); | ||
} | ||
|
||
public AppClient(URI serverUri, Map<String, String> httpHeaders) { | ||
super(serverUri, httpHeaders); | ||
} | ||
|
||
@Override | ||
public void onOpen(ServerHandshake handshake) { | ||
send("Testing open"); | ||
System.out.println("new connection opened"); | ||
|
||
} | ||
|
||
@Override | ||
public void onMessage(String message) { | ||
System.out.println("received: " + message); | ||
msg = message; | ||
} | ||
|
||
@Override | ||
public void onClose(int code, String reason, boolean remote) { | ||
|
||
} | ||
|
||
@Override | ||
public void onError(Exception ex) { | ||
|
||
} | ||
|
||
public static void main(String[] args) throws URISyntaxException { | ||
WebSocketClient ac = new AppClient(new URI("ws://localhost:8000")); | ||
ac.connect(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,38 +1,45 @@ | ||
package uta.cse3310; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
import static org.junit.Assert.*; | ||
import org.junit.*; | ||
|
||
import com.google.gson.Gson; | ||
|
||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
extends TestCase | ||
{ | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public AppTest( String testName ) | ||
{ | ||
super( testName ); | ||
public class AppTest { | ||
private int HTTP_PORT = 8000; | ||
private int WEBSOCKET_PORT = 9000; | ||
private int TEST_GRID ; | ||
private App app = null; | ||
private UserEvent U; | ||
private Gson gson; | ||
private String jsonString; | ||
|
||
|
||
@Before | ||
public void setUp() { | ||
app = new App(WEBSOCKET_PORT); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() | ||
{ | ||
return new TestSuite( AppTest.class ); | ||
@Test | ||
public void test_valid_player() { | ||
String bad_handle = "this handle is too long"; | ||
String good_handle = "good"; | ||
|
||
U.Handle = bad_handle; | ||
U.ready = -2; | ||
|
||
jsonString = gson.toJson(U); | ||
|
||
assertTrue( false ); | ||
// assertTrue(ac.msg == "disapproved"); | ||
} | ||
|
||
/** | ||
* Rigourous Test :-) | ||
*/ | ||
public void testApp() | ||
{ | ||
assertTrue( true ); | ||
public static void main(String[] args) { | ||
int port = 8100; | ||
App app = new App(port); | ||
} | ||
} |