Class AbstractResourceIT

    • Method Detail

      • decodeDigestHeader

        protected static Map<String,​StringdecodeDigestHeader​(String digestHeader)
        Decode the Digest header
        Parameters:
        digestHeader - the digest header value.
        Returns:
        Map with keys of algorithms and values of hashes.
      • createClient

        protected static org.apache.http.impl.client.CloseableHttpClient createClient()
      • createClient

        protected static org.apache.http.impl.client.CloseableHttpClient createClient​(boolean disableRedirects)
      • postObjMethod

        protected static org.apache.http.client.methods.HttpPost postObjMethod()
      • postObjMethod

        protected static org.apache.http.client.methods.HttpPost postObjMethod​(String id)
      • putObjMethod

        protected static org.apache.http.client.methods.HttpPut putObjMethod​(String id)
      • getObjMethod

        protected static org.apache.http.client.methods.HttpGet getObjMethod​(String id)
      • headObjMethod

        protected static org.apache.http.client.methods.HttpHead headObjMethod​(String id)
      • deleteObjMethod

        protected static org.apache.http.client.methods.HttpDelete deleteObjMethod​(String id)
      • patchObjMethod

        protected static org.apache.http.client.methods.HttpPatch patchObjMethod​(String id)
      • execute

        protected static org.apache.http.client.methods.CloseableHttpResponse execute​(org.apache.http.client.methods.HttpUriRequest req)
                                                                               throws IOException
        Execute an HTTP request and return the open response.
        Parameters:
        req - Request to execute
        Returns:
        the open response
        Throws:
        IOException - in case of an IOException
      • executeAndClose

        protected static void executeAndClose​(org.apache.http.client.methods.HttpUriRequest req)
        Execute an HTTP request and close the response.
        Parameters:
        req - the request to execute
      • executeWithBasicAuth

        protected org.apache.http.client.methods.CloseableHttpResponse executeWithBasicAuth​(org.apache.http.client.methods.HttpUriRequest request,
                                                                                            String username,
                                                                                            String password)
                                                                                     throws IOException
        Execute an HTTP request with preemptive basic authentication.
        Parameters:
        request - the request to execute
        username - usename to use
        password - password to use
        Returns:
        the open responses
        Throws:
        IOException - in case of IOException
      • getStatus

        protected static int getStatus​(org.apache.http.HttpResponse response)
        Retrieve the HTTP status code from an open response.
        Parameters:
        response - the open response
        Returns:
        the HTTP status code of the response
      • getStatus

        protected static int getStatus​(org.apache.http.client.methods.HttpUriRequest req)
        Executes an HTTP request and returns the status code of the response, closing the response.
        Parameters:
        req - the request to execute
        Returns:
        the HTTP status code of the response
      • getLocation

        protected static String getLocation​(org.apache.http.client.methods.HttpUriRequest req)
                                     throws IOException
        Executes an HTTP request and returns the first Location header in the response, then closes the response.
        Parameters:
        req - the request to execute
        Returns:
        the value of the first Location header in the response
        Throws:
        IOException - in case of IOException
      • getLocation

        protected static String getLocation​(org.apache.http.HttpResponse response)
        Retrieve the value of the first Location header from an open HTTP response.
        Parameters:
        response - the open response
        Returns:
        the value of the first Location header in the response
      • getContentLocation

        protected static String getContentLocation​(org.apache.http.HttpResponse response)
        Retrieve the value of the first Content-Location header from an open HTTP response.
        Parameters:
        response - the open response
        Returns:
        the value of the first Content-Location header in the response
      • getEtag

        protected String getEtag​(String uri)
                          throws IOException
        Get the etag of the given URI, as returned from a HEAD request
        Parameters:
        uri - uri of the resource
        Returns:
        etag
        Throws:
        IOException - if the uri is invalid
      • getEtag

        protected String getEtag​(org.apache.http.client.methods.HttpUriRequest method)
                          throws IOException
        Get the etag returned when executing the provided method
        Parameters:
        method - method to execute
        Returns:
        etag
        Throws:
        IOException - in case of a problem or the connection was aborted
      • getEtag

        protected String getEtag​(org.apache.http.HttpResponse response)
        Get the etag header value present in the provided response
        Parameters:
        response - response
        Returns:
        etag header value or null
      • getDataset

        protected org.fcrepo.http.commons.test.util.CloseableDataset getDataset​(org.apache.http.HttpResponse response)
                                                                         throws IOException
        Parses the RDF found in and HTTP response, returning it in a CloseableDataset.
        Parameters:
        response - the response to parse
        Returns:
        the graph retrieved
        Throws:
        IOException - in case of IOException
      • getDataset

        protected org.fcrepo.http.commons.test.util.CloseableDataset getDataset​(org.apache.http.client.methods.HttpUriRequest req)
                                                                         throws IOException
        Executes an HTTP request and parses the RDF found in the response, returning it in a CloseableDataset, then closes the response.
        Parameters:
        req - the request to execute
        Returns:
        the constructed graph
        Throws:
        IOException - in case of IOException
      • getModel

        protected org.apache.jena.rdf.model.Model getModel​(String txUri,
                                                           String pid,
                                                           boolean omitSMTs)
                                                    throws IOException
        Get a model of the triples for the resource.
        Parameters:
        txUri - id of the transaction
        pid - id of the resource
        omitSMTs - whether to omit server managed triples from the response.
        Returns:
        the model of the resource triples.
        Throws:
        IOException - on problems getting response.
      • createObject

        protected org.apache.http.client.methods.CloseableHttpResponse createObject()
      • createObject

        protected org.apache.http.client.methods.CloseableHttpResponse createObject​(String pid)
      • createTransaction

        protected String createTransaction()
                                    throws IOException
        Creates a transaction, asserts that it's successful and returns the transaction location.
        Returns:
        string containing transaction location
        Throws:
        IOException - exception thrown during the function
      • addTxTo

        protected <T extends org.apache.http.client.methods.HttpRequestBase> T addTxTo​(T req,
                                                                                       String txId)
        Add a transaction id to a http request.
        Parameters:
        req - a http request object.
        txId - the transaction id.
        Returns:
        the http request object with the transaction id added as a header.
      • getRandomUniqueId

        protected static String getRandomUniqueId()
        Gets a random (but valid) id for use in testing. This id is guaranteed to be unique within runs of this application.
        Returns:
        string containing new id
      • assertNoLinkHeader

        protected static void assertNoLinkHeader​(org.apache.http.HttpResponse response,
                                                 String uri,
                                                 String rel)
        Test a response for the absence of a specific LINK header
        Parameters:
        response - the HTTP response
        uri - the URI not to exist in the LINK header
        rel - the rel argument to check for
      • checkForLinkHeader

        protected static void checkForLinkHeader​(org.apache.http.HttpResponse response,
                                                 String uri,
                                                 String rel)
        Test a response for a specific LINK header
        Parameters:
        response - the HTTP response
        uri - the URI expected in the LINK header
        rel - the rel argument to check for
      • getOriginalResourceUri

        protected static String getOriginalResourceUri​(org.apache.http.client.methods.CloseableHttpResponse response)
      • assertConstrainedByPresent

        protected static void assertConstrainedByPresent​(org.apache.http.client.methods.CloseableHttpResponse response)
      • preferLink

        protected static String preferLink​(String includes,
                                           String omits)
        Create a Prefer header
        Parameters:
        includes - String of include URIs or null if none
        omits - String of omit URIs or null if none
        Returns:
        The Prefer header.
      • confirmResponseBodyNTriplesAreEqual

        protected static void confirmResponseBodyNTriplesAreEqual​(String responseBodyA,
                                                                  String responseBodyB)
        Compare two N-Triple response bodies to determine if they are identical
        Parameters:
        responseBodyA - the first n-triple body
        responseBodyB - the second n-triple body