# Graph Store Protocol Tests

- Tests
  1. PUT - Initial state
  2. GET of PUT - Initial state
  3. PUT - graph already in store
  4. GET of PUT - graph already in store
  5. PUT - default graph
  6. GET of PUT - default graph
  7. PUT - mismatched payload
  8. PUT - empty graph
  9. GET of PUT - empty graph
  10. DELETE - existing graph
  11. GET of DELETE - existing graph
  12. DELETE - non-existent graph
  13. POST - existing graph
  14. GET of POST - existing graph
  15. POST - multipart/form-data
  16. GET of POST - multipart/form-data
  17. POST - create new graph
  18. GET of POST - create new graph
  19. POST - empty graph to existing graph
  20. GET of POST - after noop
  21. HEAD on an existing graph
  22. HEAD on a non-existing graph

$HOST$ is the host where the Graph Store Protocol implementation is listening

$GRAPHSTORE$ is the path of the URL of the graph store

$NEWPATH$ is the URL returned in the Location HTTP header

HTTP response messages are in the format:

                HTTP Status code
                Headers
                <space>
                Body

## PUT - Initial state

### Request

    PUT $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:fn "John Doe"
        ].

### Response

    201 Created

## GET of PUT - Initial state

### Request

    GET $GRAPHSTORE$?graph=$GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
       foaf:businessCard [
            a v:VCard;
            v:fn "John Doe"
       ].

## PUT - graph already in store

### Request

    PUT $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:fn "Jane Doe"
        ].

### Response

    204 No Content

## GET of PUT - graph already in store

### Request

    GET $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
       foaf:businessCard [
            a v:VCard;
            v:fn "Jane Doe"
       ] .

## PUT - default graph

### Request

    PUT $GRAPHSTORE$?default HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    []  a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:given-name "Alice"
        ] .

### Response

    204 No Content

## GET of PUT - default graph

### Request

    GET $GRAPHSTORE$?default HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    []  a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:given-name "Alice"
        ] .

## PUT - mismatched payload

### Request

    PUT $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Content-Type: application/rdf+xml

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:fn "Jane Doe"
        ].

### Response

    400 Bad Request

## PUT - empty graph

### Request

    PUT $GRAPHSTORE$?graph=$GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

### Response

    200 OK

## GET of PUT - empty graph

### Request

    GET $GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

## DELETE - existing graph

### Request

    DELETE $GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$

### Response

    200 OK

## GET of DELETE - existing graph

### Request

    GET $GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$

### Response

    404 Not Found

## DELETE - non-existent graph

### Request

    DELETE $GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$

### Response

    404 Not Found

## POST - existing graph

### Request

    POST $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .

    <http://$HOST$/$GRAPHSTORE$/person/1> foaf:name "Jane Doe"

### Response

    200 OK

## GET of POST - existing graph

### Request

    GET $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
        foaf:name "Jane Doe";
        foaf:businessCard [
            a v:VCard;
            v:fn "Jane Doe"
        ] .

## POST - multipart/form-data

### Request

    POST $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$
    Content-type: multipart/form-data; boundary=AaB03x

    --AaB03x
    content-disposition: form-data; name="graphs"
    Content-type: multipart/mixed; boundary=BbC04y

    --BbC04y
    Content-disposition: attachment; filename="lastName.ttl"
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    <http://$HOST$/$GRAPHSTORE$/person/1> foaf:familyName "Doe"
    --BbC04y
    Content-disposition: attachment; filename="firstName.ttl"
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    <http://$HOST$/$GRAPHSTORE$/person/1> foaf:givenName  "Jane"
    --BbC04y
    --AaB03x

### Response

    200 OK

## GET of POST - multipart/form-data

### Request

    GET $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    <http://$HOST$/$GRAPHSTORE$/person/1> a foaf:Person;
        foaf:name           "Jane Doe";
        foaf:givenName      "Jane";
        foaf:familyName     "Doe";
        foaf:businessCard [
            a               v:VCard;
            v:fn            "Jane Doe"
        ] .

## POST - create new graph

### Request

    POST $GRAPHSTORE$ HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    []  a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:given-name "Alice"
        ] .

### Response

    201 Created
    Location: $NEWPATH$

## GET of POST - create new graph

### Request

    GET $NEWPATH$ HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    []  a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:given-name "Alice"
        ] .

## POST - empty graph to existing graph

### Request

    POST $NEWPATH$ HTTP/1.1
    Host: $HOST$
    Content-Type: text/turtle; charset=utf-8

### Response

    204 No Content

## GET of POST - after noop

### Request

    GET $NEWPATH$ HTTP/1.1
    Host: $HOST$
    Accept: text/turtle; charset=utf-8

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    @prefix v: <http://www.w3.org/2006/vcard/ns#> .

    []  a foaf:Person;
        foaf:businessCard [
            a v:VCard;
            v:given-name "Alice"
        ] .

## HEAD on an existing graph

### Request

    HEAD $GRAPHSTORE$/person/1.ttl HTTP/1.1
    Host: $HOST$

### Response

    200 OK
    Content-type: text/turtle; charset=utf-8

## HEAD on a non-existing graph

### Request

    HEAD $GRAPHSTORE$/person/2.ttl HTTP/1.1
    Host: $HOST$

### Response

    404 Not Found