#!/usr/bin/env bash # Starts the packaged jar, makes real curl -i calls against it and stops it again. Raw output, headers included, # goes to output/05-real-curl.txt. # # ./scripts/curl-demo.sh # # Needs the same MySQL as the tests, and wipes the book table first. set -euo pipefail cd "$(dirname "$0")/.." mvn -B -q package -DskipTests java -jar target/crud-mysql-1.0.0.jar --server.port=8080 --logging.level.root=WARN > target/app.log 2>&1 & PID=$! trap 'kill $PID 2>/dev/null || true' EXIT for _ in $(seq 1 60); do curl -s -o /dev/null localhost:8080/api/books && break; sleep 1; done OUT=output/05-real-curl.txt H='Content-Type: application/json' { echo "# Real curl -i output against the packaged jar (java -jar target/crud-mysql-1.0.0.jar), Date header removed" echo for cmd in \ "curl -i -s -X POST localhost:8080/api/books -H '$H' -d '{\"title\":\"Effective Java\",\"author\":\"Joshua Bloch\",\"isbn\":\"9780134685991\",\"price\":45.50}'" \ "curl -i -s localhost:8080/api/books/1" \ "curl -i -s -X DELETE localhost:8080/api/books/1" \ "curl -i -s localhost:8080/api/books/1"; do echo "\$ ${cmd/ -s/}" eval "$cmd" | tr -d '\r' | grep -v '^Date:' echo; echo done } > "$OUT" cat "$OUT"