vivo/utilities/acceptance-tests/suites/LinkedOpenData/TestLinkedOpenData.html

115 lines
3.5 KiB
HTML
Raw Normal View History

<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<script src="js/jquery.js"></script>
<script>
function TestLOD() {
self = this;
this.setup = setupButtons;
this.uri = "lodFacultyMember";
function setupButtons() {
document.getElementById("RDFXML_button").onclick = function() {
requestWithAcceptHeader(self.uri, "application/rdf+xml");
}
document.getElementById("N3_button").onclick = function() {
requestWithAcceptHeader(self.uri, "text/n3");
}
document.getElementById("TTL_button").onclick = function() {
requestWithAcceptHeader(self.uri, "text/turtle");
}
document.getElementById("JSONLD_button").onclick = function() {
requestWithAcceptHeader(self.uri, "application/json");
}
document.getElementById("BOGUS_URI_button").onclick = function() {
requestWithAcceptHeader(self.uri + "XX", "application/rdf+xml");
}
document.getElementById("BOGUS_ACCEPT_button").onclick = function() {
requestWithAcceptHeader(self.uri, "image/png");
}
document.getElementById("BOGUS_FORMAT_button").onclick = function() {
requestWithFormat(self.uri, "bogus");
}
document.getElementById("BOGUS_EXTENSION_button").onclick = function() {
requestWithExtension(self.uri, "bogus");
}
document.getElementById("CLEAR_button").onclick = clearResult
}
function requestWithAcceptHeader(uri, mimetype) {
$.ajax({
url: "individual/" + uri,
headers: {Accept: mimetype},
dataType: "text",
complete: displayResult
});
}
function requestWithFormat(uri, format) {
$.ajax({
url: "individual/" + uri + "?format=" + format,
dataType: "text",
complete: displayResult
});
}
function requestWithExtension(uri, extension) {
$.ajax({
url: "individual/" + uri + "/" + uri + "." + extension,
dataType: "text",
complete: displayResult
});
}
function displayResult(xhr, status) {
$("#responseCode").text(xhr.status);
$("#mimeType").text(getMimeType(xhr));
$("#responseText").text(xhr.responseText);
}
function clearResult() {
$("#responseCode").text("000");
$("#mimeType").text("No type");
$("#responseText").text("No text");
}
function getMimeType(xhr) {
var header = xhr.getResponseHeader("Content-Type");
var where = header.indexOf(";");
if (where == -1) {
return header;
} else {
return header.substring(0, where);
}
}
}
$(document).ready(function() {
new TestLOD().setup();
});
</script>
<h1>Test the Linked Open Data requests</h1>
<h3>Try various accept headers</h3>
<input type="submit" value="get RDFXML" id="RDFXML_button">
<input type="submit" value="get N3" id="N3_button">
<input type="submit" value="get TTL" id="TTL_button">
<input type="submit" value="get JSONLD" id="JSONLD_button">
<h3>Try non-existent URI with RDFXML accept header</h3>
<input type="submit" value="get BOGUS Individual" id="BOGUS_URI_button">
<input type="submit" value="use BOGUS Accept header" id="BOGUS_ACCEPT_button">
<input type="submit" value="use BOGUS format" id="BOGUS_FORMAT_button">
<input type="submit" value="use BOGUS extension" id="BOGUS_EXTENSION_button">
<h3>Response data</h3>
<input type="submit" value="CLEAR response" id="CLEAR_button">
<div>Response code is <b><span id="responseCode">000</span></b></div>
<div>MIME type is <b><span id="mimeType">No type</span></b></div>
<div>Text is:</div>
<div id="responseText" style="font-size:small;">No text</div>