-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserClientTestServer.java
More file actions
75 lines (70 loc) · 2.66 KB
/
Copy pathUserClientTestServer.java
File metadata and controls
75 lines (70 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.io.*;
import java.net.Socket;
import java.net.ServerSocket;
import java.nio.file.*;
import java.util.Arrays;
import java.util.Objects;
/**
* Team Project -- UserClientTestServer
*
* This file tests the UserClient class.
*
* @author Jai Menon
*
* @version November 8, 2024
*
*/
public class UserClientTestServer {
public static void main(String[] args) throws Exception {
ServerSocket server = new ServerSocket(8080);
Socket socket = server.accept();
BufferedReader serverReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
String confirmation = serverReader.readLine();
boolean outputChecker = true;
if (!confirmation.equals("SEND_MESSAGE|" + "johnDoe" + "|" + "johnDoe" + "|" + "Hi, how are you?")) {
outputChecker = false;
}
// Checks if deleteMessage works
confirmation = serverReader.readLine();
if (!confirmation.equals("DELETE_MESSAGE|" + "johnDoe|Password1|John|Doe|null|null|null|true" + "|" + "0")) {
outputChecker = false;
}
// Checks if editMessage works
confirmation = serverReader.readLine();
if (!confirmation.equals("EDIT_MESSAGE|" + "0" + "|" + "new content")) {
outputChecker = false;
}
// Checks if blockUser works
confirmation = serverReader.readLine();
if (!confirmation.equals("BLOCK|" + "johnDoe" + "|" + "johnDoe")) {
outputChecker = false;
}
// Checks if unblockUser works
confirmation = serverReader.readLine();
if (!confirmation.equals("UNBLOCK|" + "johnDoe" + "|" + "johnDoe")) {
outputChecker = false;
}
// Checks if addFriend works
confirmation = serverReader.readLine();
if (!confirmation.equals("ADD_FRIEND|" + "johnDoe" + "|" + "johnDoe")) {
outputChecker = false;
}
// Checks if removeFriend works
confirmation = serverReader.readLine();
if (!confirmation.equals("REMOVE_FRIEND|" + "johnDoe" + "|" + "johnDoe")) {
outputChecker = false;
}
// Checks if setUserName works
confirmation = serverReader.readLine();
if (!confirmation.equals("CHANGE_USERNAME|" + "johnDoe" + "|" + "johnDoe")) {
outputChecker = false;
}
// Checks if setPassword works
confirmation = serverReader.readLine();
if (!confirmation.equals("CHANGE_PASSWORD|" + "johnDoe" + "|" + "newPassword")) {
outputChecker = false;
}
writer.println(""+outputChecker);
}
}