Skip to content

Instantly share code, notes, and snippets.

@frogcat
Created July 1, 2016 03:42
Show Gist options
  • Save frogcat/36eca151d015f76cb39bc96913baaa85 to your computer and use it in GitHub Desktop.
Save frogcat/36eca151d015f76cb39bc96913baaa85 to your computer and use it in GitHub Desktop.
SPARQL Endpoint への HTTP/HTTPS 接続テスト

SPARQL Endpoint への HTTP/HTTPS 接続テスト

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>HTTPS and HTTPS SPARQL Endpoint Connection test</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script>
<script>
QUnit.test("a test", function(assert) {
var done1 = assert.async();
var done2 = assert.async();
fetch("https://data.e-stat.go.jp/lod/sparql/query?query=" +
encodeURIComponent("select * where {?s ?p ?o.}limit 1"))
.then(a => a.json())
.then(a => {
assert.ok(true, "get result from HTTPS sparql endoint");
done1();
}).catch(ex => {
assert.ok(false, "get result from HTTPS sparql endoint");
console.log(ex);
done1();
});
fetch("http://data.e-stat.go.jp/lod/sparql/query?query=" +
encodeURIComponent("select * where {?s ?p ?o.}limit 1"))
.then(a => a.json())
.then(a => {
assert.ok(true, "get result from HTTP sparql endoint");
done2();
}).catch(ex => {
assert.ok(false, "get result from HTTP sparql endoint");
console.log(ex);
done2();
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment