A calculator application that uses Java RMI to implement server and client sides, and JUnit Jupiter framework for automated testing. The server contains a map that links each client's ID to their respective stack. The methods include:
void pushValue(int val, int clientID);
: adds integerval
to the client's (withclientID
) stack.void pushOperation(String operator, int clientID);
: computes the desired operationoperator
on the client's stack values.
- This will remove all values on the client stack and push the result of the operation onto the stack.
- The operations are
min
,max
,lcm
, andgcd
. - To perform an operation, the client stack must have at least 2 values. Otherwise an error message is returned.
- Operators
lcm
andgcd
assume all values as absolute values. - Operator
lcm
does not work for value 0.
int pop(int clientID);
: Returns the top-most value on the client's stack.boolean isEmpty(int clientID);
: Returns true if the client stack is empty.int delayPop(int millis, int clientID);
: Waitsmillis
milliseconds before returning the top-most value on the client's stack.
- In the project folder run the instruction below. This will compile the files and create the corresponding
.class
files in thebin
folder.
make
- Navigate to the
bin
folder using the below command. This is where we will start the Java RMI Registry, start the server, and run the client.
cd bin
- In the
bin
directory, run the instruction below to start Java RMI Registry (for Solaris(tm) Operating System)
rmiregistry &
or if you're using Windows, run this:
start rmiregistry
The default port the registry runs on is 1099.
- Next, start the server using the following command (for Solaris(tm) Operating System)
java -classpath ./ CalculatorServer &
or for Windows, run this:
start java -classpath ./ CalculatorServer
The output should be the following:
Server ready
- Finally, run the client using the command below. To run multiple clients parallelly, run the command below in each terminal for each client.
java -classpath ./ CalculatorClient
- The test script is located in the
tests
folder. To run the tests in Visual Studio Code, you will need:
- JDK (version 1.8 or later)
- Visual Studio Code (version 1.59.0 or later)
- Visual Studio Code Extension Pack for Java
- Follow the 'Get Started with Java Development' instructions on Visual Studio Code by clicking the
Install JDK
button (on the left of the screenshot below) and blueDownload
button (on the right of the screenshot below).
-
Open the project folder and select the test script
CalculatorImplementationTest.java
. -
Click on the testing button on the left sidebar.
- Select Enable Java Tests
- In the dropdown menu, select JUnit Jupiter.
- To run the tests, select the play button next to the JavaRMI title as shown in the video link below. Alternatively, you can run each test individually by clicking the play button next to each test title. https://github.com/clariechek/JavaRMI/assets/44283405/0ff80949-5b6b-4d0e-a4d6-f8239762fa63
For more information on Java testing in VS Code: https://code.visualstudio.com/docs/java/java-testing