Skip to content

Commit

Permalink
Change application port to 8080
Browse files Browse the repository at this point in the history
(to match Quarkus and Spring default ports)
  • Loading branch information
SvenWoltmann committed Oct 11, 2023
1 parent bb54ef0 commit 6418bc6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ The following `curl` commands assume that you have installed `jq`, a tool for pr
The following queries return one and two results, respectively:

```shell
curl localhost:8081/products/?query=plastic | jq
curl localhost:8081/products/?query=monitor | jq
curl localhost:8080/products/?query=plastic | jq
curl localhost:8080/products/?query=monitor | jq
```

The response of the second query looks like this:
Expand Down Expand Up @@ -95,7 +95,7 @@ The response of the second query looks like this:
To show the cart of user 61157 (this cart is empty when you begin):

```shell
curl localhost:8081/carts/61157 | jq
curl localhost:8080/carts/61157 | jq
```

The response should look like this:
Expand All @@ -113,10 +113,10 @@ The response should look like this:
Each of the following commands adds a product to the cart and returns the contents of the cart after the product is added (note that on Windows, you have to replace the single quotes with double quotes):

```shell
curl -X POST 'localhost:8081/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
curl -X POST 'localhost:8081/carts/61157/line-items?productId=K3SR7PBX&quantity=2' | jq
curl -X POST 'localhost:8081/carts/61157/line-items?productId=Q3W43CNC&quantity=1' | jq
curl -X POST 'localhost:8081/carts/61157/line-items?productId=WM3BPG3E&quantity=3' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=K3SR7PBX&quantity=2' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=Q3W43CNC&quantity=1' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=WM3BPG3E&quantity=3' | jq
```

After executing two of the four commands, you can see that the cart contains the two products. You also see the total number of items and the sub-total:
Expand Down Expand Up @@ -153,15 +153,15 @@ After executing two of the four commands, you can see that the cart contains the

This will increase the number of plastic sheetings to 40:
```shell
curl -X POST 'localhost:8081/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
```

### Producing an Error Message

Trying to add another 20 plastic sheetings will result in error message saying that there are only 55 items in stock:

```shell
curl -X POST 'localhost:8081/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
curl -X POST 'localhost:8080/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20' | jq
```

This is how the error response looks like:
Expand All @@ -177,12 +177,12 @@ This is how the error response looks like:
To empty the cart, send a DELETE command to its URL:

```shell
curl -X DELETE localhost:8081/carts/61157
curl -X DELETE localhost:8080/carts/61157
```

To verify it's empty:
```shell
curl localhost:8081/carts/61157 | jq
curl localhost:8080/carts/61157 | jq
```

You'll see an empty cart again.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public final class HttpTestCommons {

// So the tests can run when the application runs on port 8081:
// So the tests can run when the application runs on port 8080:
public static final int TEST_PORT = 8082;

private HttpTestCommons() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
*/
public class Launcher {

private static final int PORT = 8080;

private UndertowJaxrsServer server;

public static void main(String[] args) {
new Launcher().startOnDefaultPort();
}

public void startOnDefaultPort() {
server = new UndertowJaxrsServer();
startServer();
new Launcher().startOnPort(PORT);
}

public void startOnPort(int port) {
Expand Down
18 changes: 9 additions & 9 deletions doc/sample-requests.http
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
### Search for products containing "plastic"
GET http://localhost:8081/products/?query=plastic
GET http://localhost:8080/products/?query=plastic

### Search for products containing "monitor"
GET http://localhost:8081/products/?query=monitor
GET http://localhost:8080/products/?query=monitor

### Invalid search (search query too short)
GET http://localhost:8081/products/?query=x
GET http://localhost:8080/products/?query=x

### Get cart
GET http://localhost:8081/carts/61157
GET http://localhost:8080/carts/61157

### Add "Plastic Sheeting" to cart
POST http://localhost:8081/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20
POST http://localhost:8080/carts/61157/line-items?productId=TTKQ8NJZ&quantity=20

### Add "27-Inch Curved Computer Monitor" to cart
POST http://localhost:8081/carts/61157/line-items?productId=K3SR7PBX&quantity=2
POST http://localhost:8080/carts/61157/line-items?productId=K3SR7PBX&quantity=2

### Add "Dual Monitor Desk Mount" to cart
POST http://localhost:8081/carts/61157/line-items?productId=Q3W43CNC&quantity=1
POST http://localhost:8080/carts/61157/line-items?productId=Q3W43CNC&quantity=1

### Add "50ft Led Lights" to cart
POST http://localhost:8081/carts/61157/line-items?productId=WM3BPG3E&quantity=3
POST http://localhost:8080/carts/61157/line-items?productId=WM3BPG3E&quantity=3

### Empty cart
DELETE http://localhost:8081/carts/61157
DELETE http://localhost:8080/carts/61157

0 comments on commit 6418bc6

Please sign in to comment.