/** * Get the version reported by the remote Fedora server. */ public String getServerVersion() throws IOException { // only do this once -- future invocations will use the known value if (m_serverVersion == null) { // Make the APIA call for describe repository // and make sure that HTTP 302 status is handled. String desc = getResponseAsString("/describe?xml=true", true, true); logger.debug("describeRepository response:\n" + desc); String[] parts = desc.split("<repositoryVersion>"); if (parts.length < 2) { throw new IOException("Could not find repositoryVersion element in content of /describe?xml=true"); } int i = parts[1].indexOf("<"); if (i == -1) { throw new IOException("Could not find end of repositoryVersion element in content of /describe?xml=true"); } m_serverVersion = parts[1].substring(0, i).trim(); logger.debug("Server version is " + m_serverVersion); } return m_serverVersion; }
private static int getCount(FedoraClient client, String path, String query) { String response = null; try { path = path + URLEncoder.encode(query, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); fail("Encoding error while querying resource index. See stack trace"); } try { response = client.getResponseAsString(path, true, true).trim(); } catch (IOException e) { e.printStackTrace(); fail("Error while querying resource index (is it enabled?). " + "See stack trace"); } int count = 0; try { count = Integer.parseInt(response); } catch (NumberFormatException e) { fail("Expected numeric plaintext response body from RI query, but " + "got the following: " + response); } return count; }
/** * Check for SPARQL_W3C result format * */ @Test public void testRISearchSparqlW3cResult() throws Exception{ /* skip if MPTTriplestore implementation */ Assume.assumeTrue(! "localPostgresMPTTriplestore".equals(ri_impl)); String query="select $object $modified from <#ri> where " + "$object <fedora-model:hasModel> " + "<info:fedora/fedora-system:ServiceDefinition-3.0> and " + "$object <fedora-view:lastModifiedDate> $modified"; String xml=s_client.getResponseAsString("/risearch?lang=itql&format=Sparql_W3C&query=" + URLEncoder.encode(query,"UTF-8"), true, true).trim(); validateXML(xml,this.getClass().getClassLoader().getResourceAsStream("schema/sparql/sparql_result.xsd")); }