#!/usr/bin/bash

# Create nested structure
x=0; 
r="localhost:8080/rest/"; 
for x in {0..10};
  do echo $x
  r=`curl -s -H"Slug: $x" -XPOST $r`; 
  echo "r = $r"; 
done

# Ensure expected containment
echo "=========="
echo "Expecting ldp:contains /4"
curl localhost:8080/rest/0/1/2/3

# Add a child to /3
curl -XPUT localhost:8080/rest/0/1/2/3/x

# Ensure expected containment
echo ""
echo "=========="
echo "Expecting ldp:contains /4 and /x"
curl localhost:8080/rest/0/1/2/3

# Remove /5
echo "=========="
echo "Removing /5"
curl -XDELETE localhost:8080/rest/0/1/2/3/4/5

echo "=========="
echo "Still expecting ldp:contains /4 and /x"
curl localhost:8080/rest/0/1/2/3

echo "=========="
echo "Expecting no children of /4"
curl localhost:8080/rest/0/1/2/3/4

echo "=========="
echo "Expecting 404 for /5 through /10"
r="localhost:8080/rest/0/1/2/3/4";
for x in {5..10};
  do r="$r/$x";
  echo ""
  echo "404? for - $r"
  curl $r;
done


