Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions chess/3-web-api/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
The Starter Code has four folders: `dataAccess`, `passoff`, `resources`, and `server`. Complete the following steps to move the starter code into your project for this phase.

1. Open your chess project directory.
1. Copy the `starter-code/3-web-api/server` folder into the `server/src/main/java` folder. This contains a basic implementation of an HTTP server that allows the pass off tests to programmatically start and stop your server, as well as the code to host a web browser interface for experimenting with your endpoints.
1. Copy the `starter-code/3-web-api/server/Server.java` file into the `server/src/main/java/server` folder. This contains a basic implementation of an HTTP server that allows the pass-off tests to programmatically start and stop your server, as well as the code to host a web browser interface for experimenting with your endpoints.
1. Copy the `starter-code/3-web-api/dataaccess` folder into the `server/src/main/java` folder. This contains an exception class that you will throw whenever there is a data access error.
1. Create the folder `server/src/test/java`. Right click on the folder and select the option to mark the directory as `Test sources root`. This tells IntelliJ where to look for code to run as tests.
1. Create the folder `server/src/test/java`. Right-click on the folder and select the option to mark the directory as `Test sources root`. This tells IntelliJ where to look for code to run as tests.

![mark test root](mark-test-root.png)

1. Copy the `starter-code/3-web-api/passoff` folder into the `server/src/test/java` folder. The `passoff/server` folder contains the server test cases.
1. Create the folder `server/src/main/resources`. Right click on the folder and select the option to mark the directory as `Resources root`. This tells IntelliJ that it should include the directory when compiling the code to your `out` directory.
1. Create the folder `server/src/main/resources`. Right-click on the folder and select the option to mark the directory as `Resources root`. This tells IntelliJ that it should include the directory when compiling the code to your `out` directory.
1. Copy the `starter-code/3-web-api/resources/web` folder to the `server/src/main/resources` folder. The `web` folder contains the files that implement the web browser interface for experimenting with your endpoints.

This should result in the following additions to your project.
This should result in the following structure:

```txt
└── server
   └── src
   ├── main
   │   ├── java
   │   │ ├── Main.java
   │   │ ├── server
   │   │ │   └── Server.java
   │   │ │   ├── Server.java
   │   │ │ └── ServerMain.java
   │   │ └── dataaccess
   │   │    └── DataAccessException.java
│ └── resources
Expand All @@ -40,14 +40,14 @@ This should result in the following additions to your project.

## Getting the Webpage for Testing Setup

Once you have completed **all** of the previous steps you should be able to launch your server and access a testing HTML page. This is a simple frontend that was made to help with basic testing of your server endpoints.
Once you have completed **all** of the previous steps, you should be able to launch your server and access a testing HTML page. This is a simple frontend that was made to help with basic testing of your server endpoints.

Inside of `server/src/main/java/Main.java` in the main method, replace the code that is there with the creation of the Server object. Then call the server's run method. The run method needs the port you will run your server on, which typically for testing is 8080.
Inside of `server/src/main/java/ServerMain.java` in the main method, replace the code that is there with the creation of the Server object. Then call the server's run method. The run method needs the port you will run your server on, which is typically 8080 for testing.

```java
import server.Server;
package server;

public class Main {
public class ServerMain {
public static void main(String[] args) {
Server server = new Server();
server.run(8080);
Expand All @@ -57,9 +57,9 @@ public class Main {
}
```

When you run the main method it will start the server. Intelij will display several informational lines of red text in the **Run** window , but if no errors are reported you should be fine.
When you run the main method, it will start the server. Intelij will display several informational lines of red text in the **Run** window, but if no errors are reported, you should be fine.

Open a browser and go to `localhost:8080` (If you picked another port replace 8080 with that instead). If everything is setup correctly you should be able to see this webpage.
Open a browser and go to `http://localhost:8080` (If you picked another port, replace 8080 with that instead). If everything is set up correctly, you should be able to see this webpage.

![Webpage](chess-server-webpage.png)

Expand Down
2 changes: 1 addition & 1 deletion chess/5-pregame/pregame.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Your tests must be located in the file `client/src/test/java/client/ServerFacade

> [!TIP]
>
> `ServerFacadeTests.java` contains code that will automatically start and shutdown your server on a randomly assigned port as part of the test. However, you will still need to start your server using the `Main.main` function when you manually run your client.
> `ServerFacadeTests.java` contains code that will automatically start and shutdown your server on a randomly assigned port as part of the test. However, you will still need to start your server using the `ServerMain.main` function when you manually run your client.

```java
public class ServerFacadeTests {
Expand Down