You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/09/21 10:15:29 UTC
[18/70] [abbrv] [partial] jena git commit: JENA-1597: separate
jena-fuseki-webapp module
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/main/webapp/manage.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/webapp/manage.html b/jena-fuseki2/jena-fuseki-core/src/main/webapp/manage.html
deleted file mode 100644
index 4c3d369..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/manage.html
+++ /dev/null
@@ -1,110 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Apache Jena Fuseki - manage dataset</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
- <link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
- <link href="css/codemirror.css" rel="stylesheet" media="screen">
- <link href="css/qonsole.css" rel="stylesheet" media="screen">
- <link href="css/jquery.dataTables.css" rel="stylesheet" media="screen">
- <link href="css/fui.css" rel="stylesheet" media="screen">
-
- <script data-main="js/app/main.manage.js" src="js/lib/require.min.js"></script>
-
- <!--[if lt IE 9]>
- <script src="js/lib/html5shiv.js"></script>
- <script src="js/lib/respond.min.js"></script>
- <![endif]-->
- </head>
- <body>
- <nav class="navbar navbar-default" role="navigation">
- <div class="container">
- <div class="row">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="index.html">
- <img src="images/jena-logo-notext-small.png" alt="Apache Jena logo" title="Apache Jena" />
- <div>Apache<br />Jena<br /><strong>Fuseki</strong></div>
- </a>
- </div>
-
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse navbar-ex1-collapse">
- <ul class="nav navbar-nav">
- <li class=""><a href="index.html"><i class="fa fa-home"></i></a></li>
- <li class=""><a href="dataset.html"><i class="fa fa-database"></i> dataset</a></li>
- <li class="active"><a href="manage.html"><i class="fa fa-cogs"></i> manage datasets</a></li>
- <!-- JENA-887 not yet implemented
- <li class=""><a href="services.html"><i class="fa fa-wrench"></i> services</a></li>
- -->
- <li class=""><a href="documentation.html"><i class="fa fa-info-circle"></i> help</a></li>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li class="status-indicator">
- <div>Server<br />status:</div>
- </li>
- <li class="status-indicator">
- <a class="" href="#admin/server-log.html" id="server-status-light" title="current server status">
- <span class="server-up"></span>
- </a>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /row -->
- </div><!-- /container -->
- </nav>
-
- <div class="container">
-
- <div class="row">
- <div class="col-md-12">
- <h2>
- Manage datasets
- </h2>
- <p>Perform management actions on existing datasets, including backup,
- or add a new dataset.
- </p>
- </div>
- </div> <!-- /.row -->
-
- <div class="row">
- <div class="col-md-12">
- <div class="dataset-selector-container"></div>
- </div>
- </div>
-
- <div class="row">
- <div class="col-md-12">
- <div class="content-frame">
- <ul class="nav nav-tabs">
- <li><a href="#datasets" data-toggle="tab"><i class='fa fa-database'></i> existing datasets</a></li>
- <li><a href="#new-dataset" data-toggle="tab"><i class='fa fa-plus-circle'></i> add new dataset</a></li>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content">
- <div class="tab-pane" id="datasets">
- <div id="dataset-management"></div>
- </div> <!-- /.tab-pane -->
-
- <div class="tab-pane" id="new-dataset">
- <div id="dataset-simple-create"></div>
- </div> <!-- /.tab-pane -->
- </div> <!-- /.tab-content -->
- </div> <!-- /.content-frame -->
-
- </div> <!-- /.col-md-12 -->
- </div> <!-- /.row -->
- </div> <!--/.container -->
-
-
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/main/webapp/services.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/webapp/services.html b/jena-fuseki2/jena-fuseki-core/src/main/webapp/services.html
deleted file mode 100644
index 91aab57..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/services.html
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Apache Jena Fuseki - services</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
- <link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
- <link href="css/codemirror.css" rel="stylesheet" media="screen">
- <link href="css/qonsole.css" rel="stylesheet" media="screen">
- <link href="css/jquery.dataTables.css" rel="stylesheet" media="screen">
- <link href="css/fui.css" rel="stylesheet" media="screen">
-
- <script data-main="js/app/main.index.js" src="js/lib/require.min.js"></script>
-
- <!--[if lt IE 9]>
- <script src="js/lib/html5shiv.js"></script>
- <script src="js/lib/respond.min.js"></script>
- <![endif]-->
- </head>
- <body>
- <nav class="navbar navbar-default" role="navigation">
- <div class="container">
- <div class="row">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="index.html">
- <img src="images/jena-logo-notext-small.png" alt="Apache Jena logo" title="Apache Jena" />
- <div>Apache<br />Jena<br /><strong>Fuseki</strong></div>
- </a>
- </div>
-
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse navbar-ex1-collapse">
- <ul class="nav navbar-nav">
- <li class=""><a href="index.html"><i class="fa fa-home"></i></a></li>
- <li class=""><a href="dataset.html"><i class="fa fa-database"></i> dataset</a></li>
- <li class=""><a href="manage.html"><i class="fa fa-cogs"></i> manage datasets</a></li>
- <li class="active"><a href="services.html"><i class="fa fa-wrench"></i> services</a></li>
- <li class=""><a href="documentation.html"><i class="fa fa-info-circle"></i> help</a></li>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li class="status-indicator">
- <div>Server<br />status:</div>
- </li>
- <li class="status-indicator">
- <a class="" href="#admin/server-log.html" id="server-status-light" title="current server status">
- <span class="server-up"></span>
- </a>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /row -->
- </div><!-- /container -->
- </nav>
-
- <div class="container">
-
- <div class="row">
- <div class="col-md-12">
- <h2>
- Inspect dataset
- </h2>
- </div>
- </div>
-
- </div>
-
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/main/webapp/test/test-fuseki-config.ttl
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/webapp/test/test-fuseki-config.ttl b/jena-fuseki2/jena-fuseki-core/src/main/webapp/test/test-fuseki-config.ttl
deleted file mode 100644
index 190676a..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/test/test-fuseki-config.ttl
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
-
-@prefix : <#> .
-@prefix fuseki: <http://jena.apache.org/fuseki#> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
-@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
-
-## ---------------------------------------------------------------
-## Updatable in-memory dataset.
-
-<#service1> rdf:type fuseki:Service ;
- # URI of the dataset -- http://host:port/ds
- fuseki:name "test-service" ;
- fuseki:serviceQuery "sparql" ;
- fuseki:serviceQuery "query" ;
- fuseki:serviceUpdate "update" ;
- fuseki:serviceUpload "upload" ;
- fuseki:serviceReadWriteGraphStore "data" ;
- fuseki:serviceReadGraphStore "get" ;
- fuseki:dataset <#dataset> ;
- .
-
-## In-memory, initially empty.
-<#dataset> rdf:type ja:RDFDataset .
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/main/webapp/validate.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/webapp/validate.html b/jena-fuseki2/jena-fuseki-core/src/main/webapp/validate.html
deleted file mode 100644
index d206576..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/validate.html
+++ /dev/null
@@ -1,147 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Apache Jena Fuseki - validation</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
- <link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
- <link href="css/codemirror.css" rel="stylesheet" media="screen">
- <link href="css/qonsole.css" rel="stylesheet" media="screen">
- <link href="css/jquery.dataTables.css" rel="stylesheet" media="screen">
- <link href="css/fui.css" rel="stylesheet" media="screen">
-
- <script data-main="js/app/main.validation.js" src="js/lib/require.min.js"></script>
-
- <!--[if lt IE 9]>
- <script src="../js/lib/html5shiv.js"></script>
- <script src="../js/lib/respond.min.js"></script>
- <![endif]-->
- </head>
- <body>
- <nav class="navbar navbar-default" role="navigation">
- <div class="container">
- <div class="row">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="index.html">
- <img src="images/jena-logo-notext-small.png" alt="Apache Jena logo" title="Apache Jena" />
- <div>Apache<br />Jena<br /><strong>Fuseki</strong></div>
- </a>
- </div>
-
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse navbar-ex1-collapse">
- <ul class="nav navbar-nav">
- <li class=""><a href="index.html"><i class="fa fa-home"></i></a></li>
- <li class=""><a href="query.html"><i class="fa fa-question-circle"></i> query</a></li>
- <li class="active"><a href="validate.html"><i class="fa fa-check-circle"></i> validate</a></li>
- <li class="admin"><a href="admin-data-management.html"><i class="fa fa-cogs"></i> administer</a></li>
- <li class="admin"><a href="admin-stats.html"><i class="fa fa-dashboard"></i> stats</a></li>
- <li class="admin"><a href="admin-logs.html"><i class="fa fa-book"></i> logs</a></li>
- <li class=""><a href="documentation.html"><i class="fa fa-info-circle"></i> help</a></li>
- </ul>
- <ul class="nav navbar-nav navbar-right">
- <li class="status-indicator">
- <div>Server<br />status:</div>
- </li>
- <li class="status-indicator">
- <a class="" href="#admin/server-log.html" id="server-status-light" title="current server status">
- <span class="server-up"></span>
- </a>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /row -->
- </div><!-- /container -->
- </nav>
-
- <div class="container">
- <div class="row">
- <h1>Fuseki – validation</h1>
- <p>Use this page to validate SPARQL queries or RDF data.</p>
- <p class="text-danger">Forthcoming feature – not yet working.</p>
-
-
- <div class="validation qonsole">
- <div class="col-md-12 well">
- <div class="query-edit">
- <div id="query-edit-cm" class=""></div>
- </div>
- <div class="query-chrome">
- <form class="form-inline" role="form">
- <div class="validate-as-options options-list">
- <h2>Validate as:</h2>
- <ul class="list-inline">
- <li><a class="btn btn-custom2 btn-sm active validate-as-option" data-toggle="button" data-validate-as="sparql">SPARQL</a></li>
- <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="arq">SPARQL extended syntax</a></li>
- <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="Turtle">Turtle</a></li>
- <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="TriG">TriG</a></li>
- <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="N-Triples">N-Triples</a></li>
- <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="N-Quads">N-Quads</a></li>
- </ul>
- </div><!-- /.validate-as-options -->
-
- <div class="output-format-options options-list">
- <h2>Output format:</h2>
- <ul class="list-inline">
- <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="formatted">SPARQL</a></li>
- <li><a class="btn btn-custom2 btn-sm active" data-toggle="button" data-output-format="algebra">SPARQL algebra</a></li>
- <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="algebra-quads">SPARQL algebra (quads)</a></li>
- <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="algebra-opt">SPARQL algebra (with optimizations)</a></li>
- <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="algebra-opt-quads">SPARQL algebra (quads, with optimizations)</a></li>
- </ul>
- </div><!-- /.output-format-options -->
-
- <div class="row">
- <div class="col-md-3 col-md-offset-1">
- <a href="#" class="btn btn-success perform-validation">perform validation</a>
- </div>
- </div>
-
- </form>
- </div>
- </div>
-
- <!-- results -->
- <div id="results-block" class="row validation-output">
- <div class="col-md-12">
- <div class="well">
- <div class="row">
- <div class="col-md-12">
- <span class="loadingSpinner hidden">
- <img src="images/wait30.gif" alt="waiting for server action to complete" />
- </span>
- <span class="timeTaken hidden"></span>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12" id="results">
- <h2 class="col-md-12">Validation output</h2>
- <div class="query-edit">
- <div id="validation-output-cm" class=""></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="row clearfix"></div>
-
- <footer>
- </footer>
- </div><!-- /.validation-->
- </div><!-- /.row -->
- </div><!-- /.container -->
-
- <script src="../js/lib/jquery-1.10.2.min.js"></script>
- <script src="../js/lib/bootstrap.min.js"></script>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/AbstractFusekiTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/AbstractFusekiTest.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/AbstractFusekiTest.java
deleted file mode 100644
index 571b3d9..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/AbstractFusekiTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.atlas.junit.BaseTest ;
-import org.junit.After ;
-import org.junit.AfterClass ;
-import org.junit.Before ;
-import org.junit.BeforeClass ;
-
-/**
- * This package has the Fuseki full server tests. ServerCtl manages a full server for tetsing.
- *
- * Tests on the server also test the client-side operation
- * It is testing various client APIs.
- *
- * jena-integration-tests tests RDFConnection with the basic Fuseki server and
- * RDFConnection calls the different client APIs. So both servers get tested with the
- * client APIs, by different means.
- *
- * See {@link org.apache.jena.fuseki.AbstractFusekiTest}.
- *
- * Framework for tests using client-side operation onto a forked Fuseki server. Not
- * general - some test sets set up their own environment for different, additional
- * requirements.
- */
-
-public class AbstractFusekiTest extends BaseTest
-{
- @BeforeClass public static void ctlBeforeClass() { ServerCtl.ctlBeforeClass(); }
- @AfterClass public static void ctlAfterClass() { ServerCtl.ctlAfterClass(); }
- @Before public void ctlBeforeTest() { ServerCtl.ctlBeforeTest(); }
- @After public void ctlAfterTest() { ServerCtl.ctlAfterTest(); }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/Dummy.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/Dummy.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/Dummy.java
new file mode 100644
index 0000000..50255c0
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/Dummy.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.fuseki;
+
+public class Dummy {
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FileSender.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FileSender.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FileSender.java
deleted file mode 100644
index 58af429..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FileSender.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import java.io.IOException ;
-import java.io.PrintStream ;
-import java.net.HttpURLConnection ;
-import java.net.URL ;
-import java.util.ArrayList ;
-import java.util.List ;
-import java.util.UUID ;
-
-import org.apache.jena.atlas.io.IO ;
-
-public class FileSender {
- // HttpClient 4.3 has MultipartEntity but the 4.2->4.3 change is less
- // than trivial (and it seems some environment fix the HttpClient)
- // so here's some code for testing support.
-// MultipartEntity entity = new MultipartEntity();
-// entity.addPart(...)
-// HttpPost request = new HttpPost(url);
-// request.setEntity(entity);
-// HttpClient client = new DefaultHttpClient();
-// HttpResponse response = client.execute(request);
-
- class Entry {
- String fileName ;
- String content ;
- String contentType ;
- }
-
- private List<Entry> items = new ArrayList<>() ;
-
- private String url ;
-
- public FileSender(String url ) { this.url = url ; }
-
- public void add(String filename, String content, String type) {
- Entry e = new Entry() ;
- e.fileName = filename ;
- e.content = content ;
- e.contentType = type ;
- items.add(e) ;
- }
-
- public void send(String method) {
- try {
- String WNL = "\r\n" ; // Web newline
- String boundary = UUID.randomUUID().toString() ;
-
- HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
- connection.setRequestMethod(method);
- connection.setDoOutput(true) ;
- connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
- try ( PrintStream ps = new PrintStream(connection.getOutputStream()) ; ) {
- for ( Entry e : items ) {
- ps.print("--" + boundary+WNL) ;
- ps.print("Content-Disposition: form-data; name=\"FILE\"; filename=\""+e.fileName+"\""+WNL) ;
- ps.print("Content-Type: "+e.contentType+";charset=UTF-8"+WNL) ;
- ps.print(WNL);
- ps.print(e.content) ;
- ps.print(WNL);
- }
- ps.print("--" + boundary + "--"+WNL);
- }
- connection.connect();
- int responseCode = connection.getResponseCode();
- } catch (IOException ex) { IO.exception(ex); }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FusekiTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FusekiTest.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FusekiTest.java
deleted file mode 100644
index 3cd38da..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/FusekiTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import java.io.IOException ;
-import java.util.Objects ;
-
-import org.apache.http.HttpResponse ;
-import org.apache.http.StatusLine ;
-import org.apache.http.client.methods.HttpOptions ;
-import org.apache.http.client.methods.HttpUriRequest ;
-import org.apache.http.impl.client.CloseableHttpClient ;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.protocol.HttpContext ;
-import org.apache.http.util.EntityUtils ;
-import org.apache.jena.atlas.web.HttpException ;
-import org.apache.jena.riot.web.HttpNames ;
-import org.apache.jena.riot.web.HttpResponseLib ;
-import org.apache.jena.web.HttpSC ;
-import org.junit.Assert ;
-
-public class FusekiTest {
-
- /** Check whether str is a comma separated list of expected (unordered) */
- public static void assertStringList(String str, String... expected) {
- str = str.replace(" ", "") ;
- String[] x = str.split(",") ;
- for ( String ex : expected ) {
- Assert.assertTrue("Got: "+str+" - Does not contain "+ex, containsStr(ex, x)) ;
- }
- for ( String s : x ) {
- Assert.assertTrue("Got: "+str+" - Not expected "+s, containsStr(s, expected)) ;
- }
- }
-
- /** Is v in the list of strings? */
- public static boolean containsStr(String v, String[] strings) {
- for ( String s: strings ) {
- if ( Objects.equals(v, s))
- return true ;
- }
- return false ;
- }
-
- /** Do an HTTP Options. */
- public static String execOptions(String url) {
- // Prepare and execute
- try ( CloseableHttpClient httpClient = HttpClients.createDefault() ) {
- HttpUriRequest request = new HttpOptions(url) ;
- HttpResponse response = httpClient.execute(request, (HttpContext)null);
-
- // Response
- StatusLine statusLine = response.getStatusLine();
- int statusCode = statusLine.getStatusCode();
- if (HttpSC.isClientError(statusCode) || HttpSC.isServerError(statusCode)) {
- // Error responses can have bodies so it is important to clear up.
- String contentPayload = "" ;
- if ( response.getEntity() != null )
- contentPayload = EntityUtils.toString(response.getEntity()) ;
- throw new HttpException(statusCode, statusLine.getReasonPhrase(), contentPayload);
- }
- HttpResponseLib.nullResponse.handle(url, response);
- return response.getFirstHeader(HttpNames.hAllow).getValue() ;
- } catch (IOException ex) {
- throw new HttpException(ex);
- }
- }
-
- public static void exec404(Runnable action) {
- execWithHttpException(HttpSC.NOT_FOUND_404, action) ;
- }
-
- public static void execWithHttpException(int statusCode, Runnable action) {
- try {
- action.run();
- Assert.fail("Expected HttpException") ;
- } catch (HttpException ex) {
- // -1 : any status code in HttpException
- if ( statusCode > 0 )
- Assert.assertEquals(statusCode, ex.getResponseCode()) ;
-
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerCtl.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerCtl.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerCtl.java
deleted file mode 100644
index 8fc4513..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerCtl.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import static org.apache.jena.fuseki.ServerCtl.ServerScope.CLASS ;
-import static org.apache.jena.fuseki.ServerCtl.ServerScope.SUITE ;
-import static org.apache.jena.fuseki.ServerCtl.ServerScope.TEST ;
-
-import java.nio.file.Path;
-import java.nio.file.Paths ;
-import java.util.concurrent.atomic.AtomicInteger ;
-
-import org.apache.http.client.HttpClient ;
-import org.apache.http.impl.client.CloseableHttpClient ;
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.fuseki.cmd.JettyFuseki;
-import org.apache.jena.fuseki.jetty.JettyServerConfig ;
-import org.apache.jena.fuseki.server.* ;
-import org.apache.jena.fuseki.webapp.FusekiEnv;
-import org.apache.jena.fuseki.webapp.FusekiServerListener;
-import org.apache.jena.fuseki.webapp.FusekiSystem;
-import org.apache.jena.fuseki.webapp.SystemState;
-import org.apache.jena.riot.web.HttpOp ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.DatasetGraphFactory ;
-import org.apache.jena.sparql.modify.request.Target ;
-import org.apache.jena.sparql.modify.request.UpdateDrop ;
-import org.apache.jena.system.Txn ;
-import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.update.Update ;
-import org.apache.jena.update.UpdateExecutionFactory ;
-import org.apache.jena.update.UpdateProcessor ;
-
-/**
- * <b>Note:</b>
- * <br/>
- * <em> There is a {@code FusekiTestServer} in the basic Fuseki server which is more
- * appropriate for testing SPARQL protocols. It does not have an on-disk footprint.</em>
- * <br/>
- * This class is
- * primarily for testing the full Fuseki server and has a full on-disk configuration.
- *
- * Manage a single server for use with tests. It supports three modes:
- * <ul>
- * <li>One server for a whole test suite
- * <li>One server per test class
- * <li>One server per individual test
- * </ul>
- * One server per individual test can be troublesome due to connections not closing down
- * fast enough (left in TCP state {@code TIME_WAIT} which is 2 minutes) and also can be
- * slow. One server per test class is a good compromise.
- * <p>
- * The data in the server is always reseet between tests.
- * <p>
- * Using a connection pooling HttpClient (see {@link HttpOp#createPoolingHttpClient()}) is
- * important, both for test performance and for reducing the TCP connection load on the
- * operating system.
- * <p>
- * Usage:
- * </p>
- * <p>
- * In the test suite, put:
- *
- * <pre>
- * {@literal @BeforeClass} static public void beforeSuiteClass() { ServerCtl.ctlBeforeTestSuite(); }
- * {@literal @AfterClass} static public void afterSuiteClass() { ServerCtl.ctlAfterTestSuite(); }
- * </pre>
- * <p>
- * In the test class, put:
- *
- * <pre>
- * {@literal @BeforeClass} public static void ctlBeforeClass() { ServerCtl.ctlBeforeClass(); }
- * {@literal @AfterClass} public static void ctlAfterClass() { ServerCtl.ctlAfterClass(); }
- * {@literal @Before} public void ctlBeforeTest() { ServerCtl.ctlBeforeTest(); }
- * {@literal @After} public void ctlAfterTest() { ServerCtl.ctlAfterTest(); }
- * </pre>
- */
-public class ServerCtl {
- static { Fuseki.init(); }
-
- /* Cut&Paste versions:
-
- Test suite (TS_*)
- @BeforeClass static public void beforeSuiteClass() { ServerCtl.ctlBeforeTestSuite(); }
- @AfterClass static public void afterSuiteClass() { ServerCtl.ctlAfterTestSuite(); }
-
- Test class (Test*)
- @BeforeClass public static void ctlBeforeClass() { ServerCtl.ctlBeforeClass(); }
- @AfterClass public static void ctlAfterClass() { ServerCtl.ctlAfterClass(); }
- @Before public void ctlBeforeTest() { ServerCtl.ctlBeforeTest(); }
- @After public void ctlAfterTest() { ServerCtl.ctlAfterTest(); }
-
- */
-
- // Note: it is important to cleanly close a PoolingHttpClient across server restarts
- // otherwise the pooled connections remain for the old server.
-
- /*package : for import static */ enum ServerScope { SUITE, CLASS, TEST }
- private static ServerScope serverScope = ServerScope.CLASS ;
- private static int currentPort = FusekiLib.choosePort() ;
-
- public static int port() {
- return currentPort ;
- }
-
- // Whether to use a transaction on the dataset or to use SPARQL Update.
- static boolean CLEAR_DSG_DIRECTLY = true ;
- static private DatasetGraph dsgTesting ;
-
- // Abstraction that runs a SPARQL server for tests.
- public static final String urlRoot() { return "http://localhost:"+port()+"/" ; }
- public static final String datasetPath() { return "/dataset" ; }
- public static final String urlDataset() { return "http://localhost:"+port()+datasetPath() ; }
-
- public static final String serviceUpdate() { return "http://localhost:"+port()+datasetPath()+"/update" ; }
- public static final String serviceQuery() { return "http://localhost:"+port()+datasetPath()+"/query" ; }
- public static final String serviceGSP() { return "http://localhost:"+port()+datasetPath()+"/data" ; }
-
-
- public static void ctlBeforeTestSuite() {
- if ( serverScope == SUITE ) {
- setPoolingHttpClient() ;
- allocServer();
- }
- }
-
- public static void ctlAfterTestSuite() {
- if ( serverScope == SUITE ) {
- freeServer();
- resetDefaultHttpClient() ;
- }
- }
-
- /**
- * Setup for the tests by allocating a Fuseki instance to work with
- */
- public static void ctlBeforeClass() {
- if ( serverScope == CLASS ) {
- setPoolingHttpClient() ;
- allocServer();
- }
- }
-
- /**
- * Clean up after tests by de-allocating the Fuseki instance
- */
- public static void ctlAfterClass() {
- if ( serverScope == CLASS ) {
- freeServer();
- resetDefaultHttpClient() ;
- }
- }
-
- /**
- * Placeholder.
- */
- public static void ctlBeforeTest() {
- if ( serverScope == TEST ) {
- setPoolingHttpClient() ;
- allocServer();
- }
- }
-
- /**
- * Clean up after each test by resetting the Fuseki dataset
- */
- public static void ctlAfterTest() {
- if ( serverScope == TEST ) {
- freeServer();
- resetDefaultHttpClient() ;
- } else
- resetServer();
- }
-
- /** Set a PoolingHttpClient */
- private static void setPoolingHttpClient() {
- setHttpClient(HttpOp.createPoolingHttpClient()) ;
- }
-
- /** Restore the original setup */
- private static void resetDefaultHttpClient() {
- setHttpClient(HttpOp.createDefaultHttpClient());
- }
-
- /** Set the HttpClient - close the old one if appropriate */
- /*package*/ static void setHttpClient(HttpClient newHttpClient) {
- HttpClient hc = HttpOp.getDefaultHttpClient() ;
- if ( hc instanceof CloseableHttpClient )
- IO.close((CloseableHttpClient)hc) ;
- HttpOp.setDefaultHttpClient(newHttpClient) ;
- }
-
- // reference count of start/stop server
- private static AtomicInteger countServer = new AtomicInteger() ;
- private static JettyFuseki server = null ;
-
- /*package*/ static void allocServer() {
- if ( countServer.getAndIncrement() == 0 )
- setupServer(true) ;
- }
-
- /*package*/ static void freeServer() {
- if ( countServer.decrementAndGet() == 0 )
- teardownServer() ;
- }
-
- protected static void setupServer(boolean updateable) {
- FusekiEnv.FUSEKI_HOME = Paths.get(TS_Fuseki.FusekiTestHome).toAbsolutePath() ;
- FileOps.ensureDir("target");
- FileOps.ensureDir(TS_Fuseki.FusekiTestHome);
- FileOps.ensureDir(TS_Fuseki.FusekiTestBase) ;
- FusekiEnv.FUSEKI_BASE = Paths.get(TS_Fuseki.FusekiTestBase).toAbsolutePath() ;
- // Must have shiro.ini.
- // This fakes the state after FusekiSystem initialization
- // in the case of starting in the same location. FusekiSystem has statics.
- // Fuseki-full is designed to be the only server, not restartable.
- // Here, we want to reset for testing.
- emptyDirectory(FusekiSystem.dirSystemDatabase);
- emptyDirectory(FusekiSystem.dirBackups);
- emptyDirectory(FusekiSystem.dirLogs);
- emptyDirectory(FusekiSystem.dirConfiguration);
- emptyDirectory(FusekiSystem.dirDatabases);
-
- setupServer(port(), null, datasetPath(), updateable) ;
- }
-
- private static void emptyDirectory(Path directory) {
- if ( directory == null )
- // Server will create.
- return;
- FileOps.clearAll(directory.toString());
- }
-
- public static void setupServer(int port, String authConfigFile, String datasetPath, boolean updateable) {
- SystemState.location = Location.mem() ;
- SystemState.init$() ;
-
- FusekiInitialConfig params = new FusekiInitialConfig() ;
- dsgTesting = DatasetGraphFactory.createTxnMem() ;
- params.dsg = dsgTesting ;
- params.datasetPath = datasetPath ;
- params.allowUpdate = updateable ;
-
- FusekiServerListener.initialSetup = params ;
-
- JettyServerConfig config = make(port, true, true) ;
- config.authConfigFile = authConfigFile ;
- JettyFuseki.initializeServer(config);
- JettyFuseki.instance.start() ;
- server = JettyFuseki.instance ;
- }
-
- /*package*/ static void teardownServer() {
- if ( server != null ) {
- // Clear out the registry.
- server.getDataAccessPointRegistry().clear() ;
- FileOps.clearAll(FusekiSystem.dirConfiguration.toFile()) ;
- server.stop() ;
- }
- server = null ;
- }
-
- /*package*/ static JettyServerConfig make(int port, boolean allowUpdate, boolean listenLocal) {
- JettyServerConfig config = new JettyServerConfig() ;
- // Avoid any persistent record.
- config.port = port ;
- config.contextPath = "/" ;
- config.loopback = listenLocal ;
- config.jettyConfigFile = null ;
- config.enableCompression = true ;
- config.verboseLogging = false ;
- return config ;
- }
-
- /*package*/ static void resetServer() {
- if (countServer.get() == 0)
- throw new RuntimeException("No server started!");
- if ( CLEAR_DSG_DIRECTLY ) {
- Txn.executeWrite(dsgTesting, ()->dsgTesting.clear()) ;
- } else {
- Update clearRequest = new UpdateDrop(Target.ALL) ;
- UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, serviceUpdate()) ;
- try {proc.execute() ; }
- catch (Throwable e) {e.printStackTrace(); throw e;}
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
deleted file mode 100644
index b535c1d..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki ;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.sparql.sse.SSE ;
-
-class ServerTest {
- public static final String gn1 = "http://graph/1" ;
- public static final String gn2 = "http://graph/2" ;
- public static final String gn99 = "http://graph/99" ;
-
- public static final Node n1 = NodeFactory.createURI("http://graph/1") ;
- public static final Node n2 = NodeFactory.createURI("http://graph/2") ;
- public static final Node n99 = NodeFactory.createURI("http://graph/99") ;
-
- public static final Graph graph1 = SSE.parseGraph("(base <http://example/> (graph (<x> <p> 1)))") ;
- public static final Graph graph2 = SSE.parseGraph("(base <http://example/> (graph (<x> <p> 2)))") ;
-
- public static final Model model1 = ModelFactory.createModelForGraph(graph1) ;
- public static final Model model2 = ModelFactory.createModelForGraph(graph2) ;
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
deleted file mode 100644
index 42e33df..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.fuseki.system.FusekiLogging;
-import org.apache.jena.fuseki.webapp.FusekiEnv;
-import org.junit.AfterClass ;
-import org.junit.BeforeClass ;
-import org.junit.runner.RunWith ;
-import org.junit.runners.Suite ;
-
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {
- TestHttpOp.class
- , TestSPARQLProtocol.class
- , TestHttpOperations.class
- , TestHttpOptions.class
- , TestDatasetGraphAccessorHTTP.class
- , TestDatasetAccessorHTTP.class
- , TestQuery.class
- , TestAuth.class
- , TestDatasetOps.class
- , TestFileUpload.class
- , TestAdmin.class
- , TestAdminAPI.class
- , TestServerReadOnly.class
- , TestBuilder.class
-})
-
-public class TS_Fuseki extends ServerTest
-{
- public static final String FusekiTestHome = "target/FusekiHome" ;
- public static final String FusekiTestBase = FusekiTestHome+"/run" ;
-
- @BeforeClass public static void setupForFusekiServer() {
- FileOps.ensureDir(FusekiTestHome);
- FileOps.clearDirectory(FusekiTestHome);
- System.setProperty("FUSEKI_HOME", FusekiTestHome) ;
- FusekiEnv.setEnvironment() ;
- FusekiLogging.setLogging();
- // To avoid confusion with log4j.properties in the main part of the server,
- // we modify in place the logging, not try to set it with another
- // Log4j properties file from the classpath.
- LogCtl.setLevel("org.apache.shiro", "WARN") ;
- LogCtl.setLevel("org.eclipse.jetty", "WARN");
-
- LogCtl.setLevel(Fuseki.serverLogName, "WARN");
- LogCtl.setLevel(Fuseki.configLogName, "WARN");
- LogCtl.setLevel(Fuseki.adminLogName, "WARN");
- LogCtl.setLevel(Fuseki.builderLogName, "WARN");
- LogCtl.setLevel(Fuseki.actionLogName, "WARN");
- LogCtl.setLevel(Fuseki.requestLogName, "WARN");
- LogCtl.setLevel(Fuseki.servletRequestLogName,"WARN");
-
- ServerCtl.ctlBeforeTestSuite();
- }
-
- @AfterClass
- static public void afterSuiteClass() {
- ServerCtl.ctlAfterTestSuite() ;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
deleted file mode 100644
index 8ce0947..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import static org.apache.jena.fuseki.mgt.ServerMgtConst.opDatasets ;
-import static org.apache.jena.fuseki.mgt.ServerMgtConst.opListBackups ;
-import static org.apache.jena.fuseki.mgt.ServerMgtConst.opServer ;
-import static org.apache.jena.fuseki.server.ServerConst.opPing;
-import static org.apache.jena.fuseki.server.ServerConst.opStats;
-import static org.apache.jena.riot.web.HttpOp.execHttpDelete ;
-import static org.apache.jena.riot.web.HttpOp.execHttpGet ;
-import static org.apache.jena.riot.web.HttpOp.execHttpPost ;
-
-import java.io.File ;
-import java.io.IOException ;
-import java.io.InputStream ;
-
-import org.apache.http.HttpEntity ;
-import org.apache.http.HttpResponse ;
-import org.apache.http.entity.FileEntity ;
-import org.apache.jena.atlas.json.JSON ;
-import org.apache.jena.atlas.json.JsonArray ;
-import org.apache.jena.atlas.json.JsonObject ;
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.atlas.web.HttpException ;
-import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.fuseki.mgt.ServerMgtConst;
-import org.apache.jena.fuseki.server.ServerConst;
-import org.apache.jena.riot.WebContent ;
-import org.apache.jena.riot.web.HttpOp ;
-import org.apache.jena.riot.web.HttpResponseHandler ;
-import org.apache.jena.web.HttpSC ;
-import org.junit.Test ;
-
-/** Tests of the admin functionality */
-public class TestAdmin extends AbstractFusekiTest {
-
- // Name of the dataset in the assembler file.
- static String dsTest = "test-ds2" ;
- static String fileBase = "testing/" ;
-
- // --- Ping
-
- @Test public void ping_1() {
- execHttpGet(ServerCtl.urlRoot()+"$/"+opPing) ;
- }
-
- @Test public void ping_2() {
- execHttpPost(ServerCtl.urlRoot()+"$/"+opPing, null) ;
- }
-
- // --- Server status
-
- @Test public void server_1() {
- JsonValue jv = httpGetJson(ServerCtl.urlRoot()+"$/"+opServer) ;
- JsonObject obj = jv.getAsObject() ;
- // Now optional : assertTrue(obj.hasKey(JsonConst.admin)) ;
- assertTrue(obj.hasKey(ServerConst.datasets)) ;
- assertTrue(obj.hasKey(ServerMgtConst.uptime)) ;
- assertTrue(obj.hasKey(ServerMgtConst.startDT)) ;
- }
-
- @Test public void server_2() {
- execHttpPost(ServerCtl.urlRoot()+"$/"+opServer, null) ;
- }
-
- // --- List all datasets
-
- @Test public void list_datasets_1() {
- try ( TypedInputStream in = execHttpGet(ServerCtl.urlRoot()+"$/"+opDatasets) ; ) { }
- }
-
- @Test public void list_datasets_2() {
- try ( TypedInputStream in = execHttpGet(ServerCtl.urlRoot()+"$/"+opDatasets) ) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
- JsonValue v = JSON.parseAny(in) ;
- assertNotNull(v.getAsObject().get("datasets")) ;
- checkJsonDatasetsAll(v);
- }
- }
-
- // Specific dataset
- @Test public void list_datasets_3() {
- checkExists(ServerCtl.datasetPath()) ;
- }
-
- // Specific dataset
- @Test public void list_datasets_4() {
- FusekiTest.exec404( () -> getDatasetDescription("does-not-exist") ) ;
- }
-
- // Specific dataset
- @Test public void list_datasets_5() {
- JsonValue v = getDatasetDescription(ServerCtl.datasetPath()) ;
- checkJsonDatasetsOne(v.getAsObject()) ;
- }
-
- // Specific dataset
- @Test public void add_delete_dataset_1() {
- checkNotThere(dsTest) ;
-
- addTestDataset() ;
-
- // Check exists.
- checkExists(dsTest) ;
-
- // Remove it.
- deleteDataset(dsTest) ;
- checkNotThere(dsTest) ;
- }
-
- // Try to add twice
- @Test public void add_delete_dataset_2() {
- checkNotThere(dsTest) ;
-
- File f = new File(fileBase+"config-ds-1.ttl") ;
- {
- org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
- HttpEntity e = new FileEntity(f, ct) ;
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets, e) ;
- }
- // Check exists.
- checkExists(dsTest) ;
- try {
- org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
- HttpEntity e = new FileEntity(f, ct) ;
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets, e) ;
- } catch (HttpException ex) {
- assertEquals(HttpSC.CONFLICT_409, ex.getResponseCode()) ;
- }
- // Check exists.
- checkExists(dsTest) ;
- deleteDataset(dsTest) ;
- }
-
- @Test public void add_delete_dataset_3() throws Exception {
- checkNotThere(dsTest) ;
- addTestDataset() ;
- checkExists(dsTest) ;
- deleteDataset(dsTest) ;
- checkNotThere(dsTest) ;
- addTestDataset() ;
- checkExists(dsTest) ;
- deleteDataset(dsTest) ;
- }
-
- @Test public void add_error_1() {
- FusekiTest.execWithHttpException(HttpSC.BAD_REQUEST_400,
- ()-> addTestDataset(fileBase+"config-ds-bad-name-1.ttl")) ;
- }
-
- @Test public void add_error_2() {
- FusekiTest.execWithHttpException(HttpSC.BAD_REQUEST_400,
- ()-> addTestDataset(fileBase+"config-ds-bad-name-2.ttl")) ;
- }
-
- @Test public void add_error_3() {
- FusekiTest.execWithHttpException(HttpSC.BAD_REQUEST_400,
- ()-> addTestDataset(fileBase+"config-ds-bad-name-3.ttl")) ;
- }
-
- @Test public void add_error_4() {
- FusekiTest.execWithHttpException(HttpSC.BAD_REQUEST_400,
- ()-> addTestDataset(fileBase+"config-ds-bad-name-4.ttl")) ;
- }
-
- @Test public void delete_dataset_1() {
- String name = "NoSuchDataset" ;
- FusekiTest.exec404( ()-> execHttpDelete(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+name) ) ;
- }
-
- // ---- Active/Offline.
-
- @Test public void state_1() {
- // Add one
- addTestDataset() ;
- checkExists(dsTest) ;
-
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+dsTest+"?state=offline", null) ;
-
- checkExistsNotActive(dsTest);
-
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+dsTest+"?state=active", null) ;
-
- checkExists(dsTest) ;
- deleteDataset(dsTest) ;
- }
-
- @Test public void state_2() {
- addTestDataset() ;
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+dsTest+"?state=offline", null) ;
- deleteDataset(dsTest) ;
- checkNotThere(dsTest) ;
- }
-
- @Test public void state_3() {
- addTestDataset() ;
- FusekiTest.exec404(()->execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets+"/DoesNotExist?state=offline", null)) ;
- deleteDataset(dsTest) ;
- }
-
- // ---- Backup
-
- // ---- Server
-
- // ---- Stats
-
- @Test public void stats_1() {
- JsonValue v = execGetJSON(ServerCtl.urlRoot()+"$/"+opStats) ;
- checkJsonStatsAll(v);
- }
-
- @Test public void stats_2() {
- addTestDataset() ;
- JsonValue v = execGetJSON(ServerCtl.urlRoot()+"$/"+opStats+ServerCtl.datasetPath()) ;
- checkJsonStatsAll(v);
- deleteDataset(dsTest) ;
- }
-
- @Test public void stats_3() {
- addTestDataset() ;
- FusekiTest.exec404(()-> execGetJSON(ServerCtl.urlRoot()+"$/"+opStats+"/DoesNotExist")) ;
- deleteDataset(dsTest) ;
- }
-
- // Sync task testing
-
- @Test public void task_1() {
- String x = execSleepTask(null, 10) ;
- assertNotNull(x) ;
- Integer.parseInt(x) ;
- }
-
- @Test public void task_2() {
- String x = "NoSuchTask" ;
- String url = ServerCtl.urlRoot()+"$/tasks/"+x ;
- FusekiTest.exec404(()->httpGetJson(url) ) ;
- try {
- checkInTasks(x) ;
- fail("No failure!") ;
- } catch (AssertionError ex) {}
- }
-
-
- @Test public void task_3() {
- // Timing dependent.
- // Create a "long" running task so we can find it.
- String x = execSleepTask(null, 100) ;
- checkTask(x) ;
- checkInTasks(x) ;
- assertNotNull(x) ;
- Integer.parseInt(x) ;
- }
-
- @Test public void task_4() {
- // Timing dependent.
- // Create a "short" running task
- String x = execSleepTask(null, 1) ;
- // Check exists in the list of all tasks (should be "finished")
- checkInTasks(x) ;
- String url = ServerCtl.urlRoot()+"$/tasks/"+x ;
-
- boolean finished = false ;
- for ( int i = 0 ; i < 10 ; i++ ) {
- if ( i != 0 )
- Lib.sleep(25) ;
- JsonValue v = httpGetJson(url) ;
- checkTask(v) ;
- if ( v.getAsObject().hasKey("finished") ) {
- finished = true ;
- break ;
- }
- }
- if ( ! finished )
- fail("Task has not finished") ;
- }
-
- @Test public void task_5() {
- // Short running task - still in info API call.
- String x = execSleepTask(null, 1) ;
- checkInTasks(x) ;
- }
-
- @Test public void list_backups_1() {
- try ( TypedInputStream in = execHttpGet(ServerCtl.urlRoot()+"$/"+opListBackups) ) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
- JsonValue v = JSON.parseAny(in) ;
- assertNotNull(v.getAsObject().get("backups")) ;
- }
- }
-
- private static JsonValue getTask(String taskId) {
- String url = ServerCtl.urlRoot()+"$/tasks/"+taskId ;
- return httpGetJson(url) ;
- }
-
- private static JsonValue getDatasetDescription(String dsName) {
- try (TypedInputStream in = execHttpGet(ServerCtl.urlRoot() + "$/" + opDatasets + "/" + dsName)) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType());
- JsonValue v = JSON.parse(in);
- return v;
- }
- }
-
- // -- Add
-
- private static void addTestDataset() {
- addTestDataset(fileBase+"config-ds-1.ttl") ;
- }
-
- private static void addTestDataset(String filename) {
- File f = new File(filename) ;
- org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
- HttpEntity e = new FileEntity(f, ct) ;
- execHttpPost(ServerCtl.urlRoot()+"$/"+opDatasets, e) ;
- }
-
- private static void deleteDataset(String name) {
- execHttpDelete(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+name) ;
- }
-
- static class JsonResponseHandler implements HttpResponseHandler {
-
- private JsonValue result = null ;
-
- public JsonValue getJSON() {
- return result ;
- }
-
- @Override
- public void handle(String baseIRI, HttpResponse response) throws IOException {
- try ( InputStream in = response.getEntity().getContent() ) {
- result = JSON.parseAny(in) ;
- }
- }
- }
-
- private static String execSleepTask(String name, int millis) {
- String url = ServerCtl.urlRoot()+"$/sleep" ;
- if ( name != null ) {
- if ( name.startsWith("/") )
- name = name.substring(1) ;
- url = url + "/"+name ;
- }
-
- JsonResponseHandler x = new JsonResponseHandler() ;
- HttpOp.execHttpPost(url+"?interval="+millis, null, WebContent.contentTypeJSON, x) ;
- JsonValue v = x.getJSON() ;
- String id = v.getAsObject().get("taskId").getAsString().value() ;
- return id ;
- }
-
- private static JsonValue httpGetJson(String url) {
- JsonResponseHandler x = new JsonResponseHandler() ;
- HttpOp.execHttpGet(url, WebContent.contentTypeJSON, x) ;
- return x.getJSON() ;
- }
-
- private static void checkTask(String x) {
- String url = ServerCtl.urlRoot()+"$/tasks/"+x ;
- JsonValue v = httpGetJson(url) ;
- checkTask(v) ;
- }
-
- private static void checkTask(JsonValue v) {
- assertNotNull(v) ;
- assertTrue(v.isObject()) ;
- //System.out.println(v) ;
- JsonObject obj = v.getAsObject() ;
- try {
- assertTrue(obj.hasKey("task")) ;
- assertTrue(obj.hasKey("taskId")) ;
- // Not present until it runs : "started"
- } catch (AssertionError ex) {
- System.out.println(obj) ;
- throw ex ;
- }
- }
-
- private static void checkInTasks(String x) {
- String url = ServerCtl.urlRoot()+"$/tasks" ;
- JsonValue v = httpGetJson(url) ;
- assertTrue(v.isArray()) ;
- JsonArray array = v.getAsArray() ;
- int found = 0 ;
- for ( int i = 0 ; i < array.size() ; i++ ) {
- JsonValue jv = array.get(i) ;
- assertTrue(jv.isObject()) ;
- JsonObject obj = jv.getAsObject() ;
- checkTask(obj) ;
- if ( obj.get("taskId").getAsString().value().equals(x) ) {
- found++ ;
- }
- }
- assertEquals("Occurence of taskId count", 1, found) ;
- }
-
- // Auxilary
-
- private static void askPing(String name) {
- if ( name.startsWith("/") )
- name = name.substring(1) ;
- try ( TypedInputStream in = execHttpGet(ServerCtl.urlRoot()+name+"/sparql?query=ASK%7B%7D") ) {}
- }
-
- private static void adminPing(String name) {
- try ( TypedInputStream in = execHttpGet(ServerCtl.urlRoot()+"$/"+opDatasets+"/"+name) ) {}
- }
-
- private static void checkExists(String name) {
- adminPing(name) ;
- askPing(name) ;
- }
-
- private static void checkExistsNotActive(String name) {
- adminPing(name) ;
- try { askPing(name) ;
- fail("askPing did not cause an Http Exception") ;
- } catch ( HttpException ex ) {}
- JsonValue v = getDatasetDescription(name) ;
- assertFalse(v.getAsObject().get("ds.state").getAsBoolean().value()) ;
- }
-
- private static void checkNotThere(String name) {
- String n = (name.startsWith("/")) ? name.substring(1) : name ;
- // Check gone exists.
- FusekiTest.exec404(()-> adminPing(n) ) ;
- FusekiTest.exec404(() -> askPing(n) ) ;
- }
-
- private static void checkJsonDatasetsAll(JsonValue v) {
- assertNotNull(v.getAsObject().get("datasets")) ;
- JsonArray a = v.getAsObject().get("datasets").getAsArray() ;
- for ( JsonValue v2 : a )
- checkJsonDatasetsOne(v2) ;
- }
-
- private static void checkJsonDatasetsOne(JsonValue v) {
- assertTrue(v.isObject()) ;
- JsonObject obj = v.getAsObject() ;
- assertNotNull(obj.get("ds.name")) ;
- assertNotNull(obj.get("ds.services")) ;
- assertNotNull(obj.get("ds.state")) ;
- assertTrue(obj.get("ds.services").isArray()) ;
- }
-
- private static void checkJsonStatsAll(JsonValue v) {
- assertNotNull(v.getAsObject().get("datasets")) ;
- JsonObject a = v.getAsObject().get("datasets").getAsObject() ;
- for ( String dsname : a.keys() ) {
- JsonValue obj = a.get(dsname).getAsObject() ;
- checkJsonStatsOne(obj);
- }
- }
-
- private static void checkJsonStatsOne(JsonValue v) {
- checkJsonStatsCounters(v) ;
- JsonObject obj1 = v.getAsObject().get("endpoints").getAsObject() ;
- for ( String srvName : obj1.keys() ) {
- JsonObject obj2 = obj1.get(srvName).getAsObject() ;
- assertTrue(obj2.hasKey("description"));
- assertTrue(obj2.hasKey("operation"));
- checkJsonStatsCounters(obj2);
- }
- }
-
- private static void checkJsonStatsCounters(JsonValue v) {
- JsonObject obj = v.getAsObject() ;
- assertTrue(obj.hasKey("Requests")) ;
- assertTrue(obj.hasKey("RequestsGood")) ;
- assertTrue(obj.hasKey("RequestsBad")) ;
- }
-
- private static JsonValue execGetJSON(String url) {
- try ( TypedInputStream in = execHttpGet(url) ) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
- return JSON.parse(in) ;
- }
- }
-
- /*
- GET /$/ping
- POST /$/ping
- POST /$/datasets/
- GET /$/datasets/
- DELETE /$/datasets/*{name}*
- GET /$/datasets/*{name}*
- POST /$/datasets/*{name}*?state=offline
- POST /$/datasets/*{name}*?state=active
- POST /$/backup/*{name}*
- GET /$/server
- POST /$/server/shutdown
- GET /$/stats/
- GET /$/stats/*{name}*
- */
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/e8abcbb6/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdminAPI.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdminAPI.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdminAPI.java
deleted file mode 100644
index b578b52..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdminAPI.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import static org.apache.jena.riot.web.HttpOp.execHttpGet;
-
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.http.HttpEntity ;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.jena.atlas.web.HttpException;
-import org.apache.jena.atlas.web.TypedInputStream;
-import org.apache.jena.fuseki.webapp.FusekiSystem;
-import org.apache.jena.query.QueryExecution;
-import org.apache.jena.rdfconnection.RDFConnection;
-import org.apache.jena.rdfconnection.RDFConnectionFactory;
-import org.apache.jena.riot.web.HttpOp ;
-import org.apache.jena.sparql.engine.http.Params;
-import org.apache.jena.web.HttpSC;
-import org.junit.Test ;
-
-/** More tests of the admin functionality
- * See also TestAdmin.
- */
-public class TestAdminAPI extends AbstractFusekiTest {
-
- @Test public void add_delete_api_1() throws Exception {
- testAddDelete("db_mem", "mem", false);
- }
-
- @Test public void add_delete_api_2() throws Exception {
- testAddDelete("db_tdb", "tdb", true);
- }
-
- @Test public void add_delete_api_3() throws Exception {
- testAddDelete("db_tdb2", "tdb2", true);
- }
-
- private static void testAddDelete(String dbName, String dbType, boolean hasFiles) {
- String datasetURL = ServerCtl.urlRoot()+dbName;
- String admin = ServerCtl.urlRoot()+"$/";
- HttpEntity e = createFormEntity(dbName, "tdb");
-
- assertFalse(exists(datasetURL));
-
- HttpOp.execHttpPost(admin+"datasets", e);
-
- RDFConnection conn = RDFConnectionFactory.connect(datasetURL);
- conn.update("INSERT DATA { <x:s> <x:p> 123 }");
- int x1 = count(conn);
- assertEquals(1, x1);
-
- Path pathDB = FusekiSystem.dirDatabases.resolve(dbName);
-
- if ( hasFiles )
- assertTrue(Files.exists(pathDB));
-
- HttpOp.execHttpDelete(admin+"datasets/"+dbName);
-
- assertFalse(exists(datasetURL));
-
- //if ( hasFiles )
- assertFalse(Files.exists(pathDB));
-
- // Recreate : no contents.
- HttpOp.execHttpPost(admin+"datasets", e);
- assertTrue(exists(datasetURL));
- int x2 = count(conn);
- assertEquals(0, x2);
- if ( hasFiles )
- assertTrue(Files.exists(pathDB));
- }
-
- private static boolean exists(String url) {
- try ( TypedInputStream in = execHttpGet(url) ) {
- return true;
- } catch (HttpException ex) {
- if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
- return false;
- throw ex;
- }
- }
-
- static int count(RDFConnection conn) {
- try ( QueryExecution qExec = conn.query("SELECT (count(*) AS ?C) { ?s ?p ?o }")) {
- return qExec.execSelect().next().getLiteral("C").getInt();
- }
- }
-
- static HttpEntity createFormEntity(String dbName, String dbType) {
- List <? extends NameValuePair> parameters =
- Arrays.asList(
- new Params.Pair("dbName", dbName),
- new Params.Pair("dbType", dbType));
- UrlEncodedFormEntity e = new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8);
- return e;
- }
-}
-