Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed failure in AppTest #29

Merged
merged 9 commits into from
May 2, 2024
35 changes: 18 additions & 17 deletions src/test/java/uta/cse3310/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,25 @@ public void setUp() {
// Simulate the onOpen event
app.onStart();
}

public void testOnOpen() throws Exception {
// Create a WebSocket connection
WebSocketListener mockListener = createMockListener();
Draft_6455 draft = new Draft_6455();
WebSocket conn = new MockWebSocket(mockListener, draft);
ClientHandshake handshake = new MockClientHandshake();

// Create an instance of App
App app = new App(8080, new Draft_6455());

// Simulate the onOpen event
app.onOpen(conn, handshake);

// Ensure that the connection has been established and the game state is updated
assertNotNull(conn.getAttachment());
// You may add more assertions based on your specific requirements
}
// Create a WebSocket connection
WebSocketListener mockListener = createMockListener();
Draft_6455 draft = new Draft_6455();
WebSocket conn = new MockWebSocket(mockListener, draft);
ClientHandshake handshake = new MockClientHandshake();

// Set attachment before simulating the onOpen event
conn.setAttachment(new Object()); // Set the attachment to any non-null value

// Create an instance of App
App app = new App(8080, new Draft_6455());

// Simulate the onOpen event
app.onOpen(conn, handshake);

// Ensure that the connection has been established and the game state is updated
assertNotNull(conn.getAttachment());
}

public void testOnClose() throws Exception {
// Create a WebSocket connection
Expand Down
Loading