Our project is a simple chatroom application developed in Java 8, with communications between clients and server handled by the socket.io library, natively in JavaScript. We used this Java port to develop the Server and this to develop the Client. Messages are stored in a MongoDB database and the GUI is implemented with Java Swing.
N.B. The Server is bound to TCP port 3000, make sure that it is available before continuing.
- Clone the repo:
git clone https://github.com/marcodiri/java_socketio_chatroom.git
- Navigate inside the root project directory:
cd java_socketio_chatroom
You can build the Server and Client jars with Maven using the command (we suggest using the provided wrapper mvnw on Unix or mvnw.cmd on Windows):
./mvnw -f java_socketio_chatroom_aggregator/pom.xml clean package -Dmaven.test.skip
You'll find the jars in the target folder of the corresponding module.
You can run the tests with Maven using the command:
./mvnw -f java_socketio_chatroom_aggregator/pom.xml clean verify
The following profiles can be enabled with the -P
Maven switch:
jacoco
to check the code coveragemutation-testing
to run mutation testing with PIT
E2E tests are enabled by default. If you wish to skip it, set the variable -DskipE2E
in the Maven command.
For IT and E2E tests you'll need to have a running instance of MongoDB, either on your PC on port 27017 or in a Docker container with the command:
docker run --rm -p 27017:27017 mongo:4.2.15
Then you can manually run the tests from your favourite IDE.
Build the modules following the steps in the Building section. To launch the application run the generated *-jar-with-dependencies.jar in the target folder of the corresponding module, with the command:
cd java_socketio_chatroom_server
java -jar ./target/*-jar-with-dependencies.jar
cd java_socketio_chatroom_client
java -jar ./target/*-jar-with-dependencies.jar hostname
The hostname or IP address of the Server must be indicated in the hostname parameter.
It seems that sometimes the socket.io library is not able to send or receive the events correctly, resulting in tests failure or undefined behaviours by the Client application. We reported the issue to the library maintainers.