Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Hnj0 committed May 1, 2024
1 parent 185b045 commit 4020b01
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 26 deletions.
53 changes: 53 additions & 0 deletions src/test/java/AppClient.java
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();
}
}
59 changes: 33 additions & 26 deletions src/test/java/AppTest.java
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);
}
}

0 comments on commit 4020b01

Please sign in to comment.