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 2015/10/26 17:07:03 UTC
[1/4] jena git commit: Tidy argument handling code.
Repository: jena
Updated Branches:
refs/heads/master 5edf18dba -> ab1bfd23e
Tidy argument handling code.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ea21b87c
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ea21b87c
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ea21b87c
Branch: refs/heads/master
Commit: ea21b87cba41dc9472d21412d2af54e9ff1268d5
Parents: 85b722b
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Oct 24 19:10:00 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 24 19:10:00 2015 +0100
----------------------------------------------------------------------
.../org/apache/jena/fuseki/cmd/FusekiCmd.java | 130 ++++++++++---------
1 file changed, 71 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/ea21b87c/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
index 931c6e0..e8f6dd9 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
@@ -69,13 +69,14 @@ public class FusekiCmd {
private static ArgDecl argHome = new ArgDecl(ArgDecl.HasValue, "home") ;
private static ArgDecl argPages = new ArgDecl(ArgDecl.HasValue, "pages") ;
- private static ArgDecl argMem = new ArgDecl(ArgDecl.NoValue, "mem") ;
- private static ArgDecl argAllowUpdate = new ArgDecl(ArgDecl.NoValue, "update", "allowUpdate") ;
+ private static ArgDecl argMem = new ArgDecl(ArgDecl.NoValue, "mem") ;
+ // This does not apply to empty in-memory setups.
+ private static ArgDecl argUpdate = new ArgDecl(ArgDecl.NoValue, "update", "allowUpdate") ;
private static ArgDecl argFile = new ArgDecl(ArgDecl.HasValue, "file") ;
- private static ArgDecl argMemTDB = new ArgDecl(ArgDecl.NoValue, "memtdb", "memTDB") ;
- private static ArgDecl argTDB = new ArgDecl(ArgDecl.HasValue, "loc", "location") ;
+ private static ArgDecl argMemTDB = new ArgDecl(ArgDecl.NoValue, "memtdb", "memTDB", "tdbmem") ;
+ private static ArgDecl argTDB = new ArgDecl(ArgDecl.HasValue, "loc", "location", "tdb") ;
private static ArgDecl argPort = new ArgDecl(ArgDecl.HasValue, "port") ;
- private static ArgDecl argLocalhost = new ArgDecl(ArgDecl.NoValue, "localhost", "local") ;
+ private static ArgDecl argLocalhost = new ArgDecl(ArgDecl.NoValue, "localhost", "local") ;
private static ArgDecl argTimeout = new ArgDecl(ArgDecl.HasValue, "timeout") ;
private static ArgDecl argFusekiConfig = new ArgDecl(ArgDecl.HasValue, "config", "conf") ;
private static ArgDecl argJettyConfig = new ArgDecl(ArgDecl.HasValue, "jetty-config") ;
@@ -87,8 +88,6 @@ public class FusekiCmd {
// private static ModLocation modLocation = new ModLocation() ;
private static ModDatasetAssembler modDataset = new ModDatasetAssembler() ;
- // fuseki [--mem|--desc assembler.ttl] [--port PORT] **** /datasetURI
-
static public void innerMain(String... argv) {
JenaSystem.init() ;
// Do explicitly so it happens after subsystem initialization.
@@ -106,7 +105,7 @@ public class FusekiCmd {
jettyServerConfig.verboseLogging = false ;
}
- private ServerInitialConfig cmdLineDataset = new ServerInitialConfig() ;
+ private final ServerInitialConfig cmdLineConfig = new ServerInitialConfig() ;
public FusekiCmdInner(String... argv) {
super(argv) ;
@@ -117,29 +116,38 @@ public class FusekiCmd {
getUsage().startCategory("Fuseki") ;
addModule(modDataset) ;
- add(argMem, "--mem", "Create an in-memory, non-persistent dataset for the server") ;
+ add(argMem, "--mem",
+ "Create an in-memory, non-persistent dataset for the server") ;
add(argFile, "--file=FILE",
"Create an in-memory, non-persistent dataset for the server, initialised with the contents of the file") ;
- add(argTDB, "--loc=DIR", "Use an existing TDB database (or create if does not exist)") ;
- add(argMemTDB, "--memTDB", "Create an in-memory, non-persistent dataset using TDB (testing only)") ;
- add(argPort, "--port", "Listen on this port number") ;
- add(argPages, "--pages=DIR", "Set of pages to serve as static content") ;
+ add(argTDB, "--loc=DIR",
+ "Use an existing TDB database (or create if does not exist)") ;
+ add(argMemTDB, "--memTDB",
+ "Create an in-memory, non-persistent dataset using TDB (testing only)") ;
+ add(argPort, "--port",
+ "Listen on this port number") ;
+ add(argPages, "--pages=DIR",
+ "Set of pages to serve as static content") ;
// Set via jetty config file.
- add(argLocalhost, "--localhost", "Listen only on the localhost interface") ;
- add(argTimeout, "--timeout=", "Global timeout applied to queries (value in ms) -- format is X[,Y] ") ;
- add(argAllowUpdate, "--update", "Allow updates (via SPARQL Update and SPARQL HTTP Update)") ;
- add(argFusekiConfig, "--config=", "Use a configuration file to determine the services") ;
- add(argJettyConfig, "--jetty-config=FILE", "Set up the server (not services) with a Jetty XML file") ;
+ add(argLocalhost, "--localhost",
+ "Listen only on the localhost interface") ;
+ add(argTimeout, "--timeout=",
+ "Global timeout applied to queries (value in ms) -- format is X[,Y] ") ;
+ add(argUpdate, "--update",
+ "Allow updates (via SPARQL Update and SPARQL HTTP Update)") ;
+ add(argFusekiConfig, "--config=",
+ "Use a configuration file to determine the services") ;
+ add(argJettyConfig, "--jetty-config=FILE",
+ "Set up the server (not services) with a Jetty XML file") ;
add(argBasicAuth) ;
- //add(argMgt, "--mgt", "Enable the management commands") ;
- add(argMgt) ; // Legacy
- add(argMgtPort) ; // Legacy
- //add(argMgtPort, "--mgtPort=port", "Port for management optations") ;
- //add(argHome, "--home=DIR", "Root of Fuseki installation (overrides environment variable FUSEKI_HOME)") ;
- add(argGZip, "--gzip=on|off", "Enable GZip compression (HTTP Accept-Encoding) if request header set") ;
-
- //add(argUber) ;
- // add(argGSP) ;
+ add(argMgt) ; // Legacy
+ add(argMgtPort) ; // Legacy
+// add(argMgt, "--mgt",
+// "Enable the management commands") ;
+// add(argMgtPort, "--mgtPort=port",
+// "Port for management optations") ;
+ add(argGZip, "--gzip=on|off",
+ "Enable GZip compression (HTTP Accept-Encoding) if request header set") ;
super.modVersion.addClass(TDB.class) ;
super.modVersion.addClass(Fuseki.class) ;
@@ -164,7 +172,7 @@ public class FusekiCmd {
Logger log = Fuseki.serverLog ;
if ( contains(argFusekiConfig) )
- cmdLineDataset.fusekiCmdLineConfigFile = getValue(argFusekiConfig) ;
+ cmdLineConfig.fusekiCmdLineConfigFile = getValue(argFusekiConfig) ;
ArgDecl assemblerDescDecl = new ArgDecl(ArgDecl.HasValue, "desc", "dataset") ;
@@ -181,7 +189,7 @@ public class FusekiCmd {
if ( contains(argMemTDB) )
x++ ;
- if ( cmdLineDataset.fusekiCmdLineConfigFile != null ) {
+ if ( cmdLineConfig.fusekiCmdLineConfigFile != null ) {
if ( x >= 1 )
throw new CmdException("Dataset specified on the command line but a configuration file also given.") ;
} else {
@@ -191,11 +199,23 @@ public class FusekiCmd {
}
boolean cmdlineConfigPresent = ( x != 0 ) ;
+ if ( cmdlineConfigPresent && getPositional().size() == 0 )
+ throw new CmdException("Missing service name") ;
+ if ( !cmdlineConfigPresent && getPositional().size() > 0 )
+ throw new CmdException("Service name given but no configuration argument to match (e.g. --mem, --loc/--tdb, --file)") ;
+ if ( cmdlineConfigPresent && getPositional().size() > 1 )
+ throw new CmdException("Multiple dataset path names given") ;
+
+ cmdLineConfig.allowUpdate = contains(argUpdate) ;
if ( contains(argMem) ) {
log.info("Dataset: in-memory") ;
- cmdLineDataset = new ServerInitialConfig() ;
- cmdLineDataset.argTemplateFile = Template.templateMemFN ;
+ // Only one setup should be called by the test above but to be safe
+ // and in case of future changes, clear the configuration.
+ cmdLineConfig.reset();
+ cmdLineConfig.argTemplateFile = Template.templateMemFN ;
+ // Always allow.
+ cmdLineConfig.allowUpdate = true ;
}
if ( contains(argFile) ) {
@@ -205,28 +225,30 @@ public class FusekiCmd {
throw new CmdException("File not found: " + filename) ;
// Directly populate the dataset.
- cmdLineDataset = new ServerInitialConfig() ;
- cmdLineDataset.dsg = DatasetGraphFactory.createMem() ;
+ cmdLineConfig.reset();
+ cmdLineConfig.dsg = DatasetGraphFactory.createMem() ;
// INITIAL DATA.
Lang language = RDFLanguages.filenameToLang(filename) ;
if ( language == null )
throw new CmdException("Can't guess language for file: " + filename) ;
- RDFDataMgr.read(cmdLineDataset.dsg, filename) ;
+ RDFDataMgr.read(cmdLineConfig.dsg, filename) ;
}
if ( contains(argMemTDB) ) {
//log.info("TDB dataset: in-memory") ;
- cmdLineDataset = new ServerInitialConfig() ;
- cmdLineDataset.argTemplateFile = Template.templateTDBMemFN ;
- cmdLineDataset.params.put(Template.DIR, Names.memName) ;
+ cmdLineConfig.reset();
+ cmdLineConfig.argTemplateFile = Template.templateTDBMemFN ;
+ cmdLineConfig.params.put(Template.DIR, Names.memName) ;
+ // Always allow.
+ cmdLineConfig.allowUpdate = true ;
}
if ( contains(argTDB) ) {
- cmdLineDataset = new ServerInitialConfig() ;
- cmdLineDataset.argTemplateFile = Template.templateTDBDirFN ;
+ cmdLineConfig.reset();
+ cmdLineConfig.argTemplateFile = Template.templateTDBDirFN ;
String dir = getValue(argTDB) ;
- cmdLineDataset.params.put(Template.DIR, dir) ;
+ cmdLineConfig.params.put(Template.DIR, dir) ;
}
// Otherwise
@@ -237,24 +259,14 @@ public class FusekiCmd {
//cmdLineDataset.dsg = ds.asDatasetGraph() ;
}
- if ( cmdlineConfigPresent && getPositional().size() == 0 )
- throw new CmdException("Missing service name") ;
- if ( !cmdlineConfigPresent && getPositional().size() > 0 )
- throw new CmdException("Service name given but no configuration argument to match") ;
-
- if ( cmdLineDataset != null ) {
- if ( getPositional().size() > 1 )
- throw new CmdException("Multiple dataset path names given") ;
- if ( getPositional().size() == 1 ) {
- cmdLineDataset.datasetPath = getPositionalArg(0) ;
- if ( cmdLineDataset.datasetPath.length() > 0 && !cmdLineDataset.datasetPath.startsWith("/") )
- throw new CmdException("Dataset path name must begin with a /: " + cmdLineDataset.datasetPath) ;
- cmdLineDataset.allowUpdate = contains(argAllowUpdate) ;
- if ( ! cmdLineDataset.allowUpdate )
- Fuseki.serverLog.info("Running in read-only mode for "+cmdLineDataset.datasetPath) ;
- // Include the dataset name as NAME for any templates.
- cmdLineDataset.params.put(Template.NAME, cmdLineDataset.datasetPath) ;
- }
+ if ( cmdlineConfigPresent ) {
+ cmdLineConfig.datasetPath = getPositionalArg(0) ;
+ if ( cmdLineConfig.datasetPath.length() > 0 && !cmdLineConfig.datasetPath.startsWith("/") )
+ throw new CmdException("Dataset path name must begin with a /: " + cmdLineConfig.datasetPath) ;
+ if ( ! cmdLineConfig.allowUpdate )
+ Fuseki.serverLog.info("Running in read-only mode for "+cmdLineConfig.datasetPath) ;
+ // Include the dataset name as NAME for any templates.
+ cmdLineConfig.params.put(Template.NAME, cmdLineConfig.datasetPath) ;
}
// ---- Jetty server
@@ -335,7 +347,7 @@ public class FusekiCmd {
@Override
protected void exec() {
- FusekiServerListener.initialSetup = cmdLineDataset ;
+ FusekiServerListener.initialSetup = cmdLineConfig ;
// For standalone, command line use ...
JettyFuseki.initializeServer(jettyServerConfig) ;
JettyFuseki.instance.start() ;
[2/4] jena git commit: defaultConfiguration ->
datasetDefaultConfiguration
Posted by an...@apache.org.
defaultConfiguration -> datasetDefaultConfiguration
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3295d029
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3295d029
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3295d029
Branch: refs/heads/master
Commit: 3295d0299f79c8773c238281cf3e81149a2c90f1
Parents: ea21b87
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Oct 24 19:12:10 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 24 19:12:10 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/server/FusekiServer.java | 51 +++++++++++---------
1 file changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/3295d029/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServer.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServer.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServer.java
index 51201f6..32e9bbd 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServer.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServer.java
@@ -246,21 +246,10 @@ public class FusekiServer
datasets.addAll(confDatasets) ;
}
else if ( params.dsg != null ) {
- DataAccessPoint dap = defaultConfiguration(params.datasetPath, params.dsg, params.allowUpdate) ;
+ DataAccessPoint dap = datasetDefaultConfiguration(params.datasetPath, params.dsg, params.allowUpdate) ;
datasets.add(dap) ;
} else if ( params.argTemplateFile != null ) {
- Fuseki.configLog.info("Template file: " + params.argTemplateFile) ;
- String dir = params.params.get(Template.DIR) ;
- if ( dir != null ) {
- if ( Objects.equals(dir, Names.memName) ) {
- Fuseki.configLog.info("TDB dataset: in-memory") ;
- } else {
- if ( !FileOps.exists(dir) )
- throw new CmdException("Directory not found: " + dir) ;
- Fuseki.configLog.info("TDB dataset: directory=" + dir) ;
- }
- }
- DataAccessPoint dap = configFromTemplate(params.argTemplateFile, params.datasetPath, params.params) ;
+ DataAccessPoint dap = configFromTemplate(params.argTemplateFile, params.datasetPath, params.allowUpdate, params.params) ;
datasets.add(dap) ;
}
// No datasets is valid.
@@ -276,12 +265,9 @@ public class FusekiServer
return FusekiConfig.readConfigFile(configFilename) ;
}
- private static DataAccessPoint configFromTemplate(String templateFile,
- String datasetPath,
- Map<String, String> params) {
- datasetPath = DataAccessPoint.canonical(datasetPath) ;
-
- // DRY -- ActionDatasets (and others?)
+ private static DataAccessPoint configFromTemplate(String templateFile, String datasetPath,
+ boolean allowUpdate, Map<String, String> params) {
+ // ---- Setup
if ( params == null ) {
params = new HashMap<>() ;
params.put(Template.NAME, datasetPath) ;
@@ -291,7 +277,23 @@ public class FusekiServer
params.put(Template.NAME, datasetPath) ;
}
}
+ //-- Logging
+ Fuseki.configLog.info("Template file: " + templateFile) ;
+ String dir = params.get(Template.DIR) ;
+ if ( dir != null ) {
+ if ( Objects.equals(dir, Names.memName) ) {
+ Fuseki.configLog.info("TDB dataset: in-memory") ;
+ } else {
+ if ( !FileOps.exists(dir) )
+ throw new CmdException("Directory not found: " + dir) ;
+ Fuseki.configLog.info("TDB dataset: directory=" + dir) ;
+ }
+ }
+ //-- Logging
+
+ datasetPath = DataAccessPoint.canonical(datasetPath) ;
+ // DRY -- ActionDatasets (and others?)
addGlobals(params);
String str = TemplateFunctions.templateFile(templateFile, params, Lang.TTL) ;
@@ -300,7 +302,7 @@ public class FusekiServer
Model model = ModelFactory.createDefaultModel() ;
RDFDataMgr.read(model, sr, datasetPath, lang);
- // Find DataAccessPoint
+ // ---- DataAccessPoint
Statement stmt = getOne(model, null, FusekiVocab.pServiceName, null) ;
if ( stmt == null ) {
StmtIterator sIter = model.listStatements(null, FusekiVocab.pServiceName, (RDFNode)null ) ;
@@ -312,6 +314,11 @@ public class FusekiServer
throw new InternalErrorException("Inconsistent: getOne didn't fail the second time") ;
}
Resource subject = stmt.getSubject() ;
+ if ( ! allowUpdate ) {
+ // Opportunity for more sophisticated "read-only" mode.
+ // 1 - clean model, remove "fu:serviceUpdate", "fu:serviceUpload", "fu:serviceReadGraphStore", "fu:serviceReadWriteGraphStore"
+ // 2 - set a flag on DataAccessPoint
+ }
DataAccessPoint dap = Builder.buildDataAccessPoint(subject) ;
return dap ;
}
@@ -345,10 +352,10 @@ public class FusekiServer
return stmt ;
}
- private static DataAccessPoint defaultConfiguration( String name, DatasetGraph dsg, boolean updatable) {
+ private static DataAccessPoint datasetDefaultConfiguration( String name, DatasetGraph dsg, boolean allowUpdate) {
name = DataAccessPoint.canonical(name) ;
DataAccessPoint dap = new DataAccessPoint(name) ;
- DataService ds = Builder.buildDataService(dsg, updatable) ;
+ DataService ds = Builder.buildDataService(dsg, allowUpdate) ;
dap.setDataService(ds) ;
return dap ;
}
[4/4] jena git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/jena
Posted by an...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/jena
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ab1bfd23
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ab1bfd23
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ab1bfd23
Branch: refs/heads/master
Commit: ab1bfd23e39e50dc5c8cec90411550ba15b4c23d
Parents: 69fcb5f 5edf18d
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Oct 26 16:06:49 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Oct 26 16:06:49 2015 +0000
----------------------------------------------------------------------
.../java/org/apache/jena/reasoner/rulesys/Rule.java | 3 ++-
.../src/main/java/org/apache/jena/util/PrintUtil.java | 8 +++++++-
.../apache/jena/reasoner/rulesys/test/TestBasics.java | 14 +++++++-------
.../test/java/org/apache/jena/util/TestPrintUtil.java | 7 ++++---
4 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
[3/4] jena git commit: Refined timing tests under Windows
Posted by an...@apache.org.
Refined timing tests under Windows
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/69fcb5f5
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/69fcb5f5
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/69fcb5f5
Branch: refs/heads/master
Commit: 69fcb5f59fc796bd34451dfdaed35fc488c5c1f4
Parents: 3295d02
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Oct 26 16:06:29 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Oct 26 16:06:29 2015 +0000
----------------------------------------------------------------------
.../main/java/org/apache/jena/riot/SysRIOT.java | 9 ++++++---
.../sparql/api/TestQueryExecutionTimeout1.java | 17 ++++++++++++----
.../sparql/api/TestQueryExecutionTimeout2.java | 16 +++++++++++----
.../apache/jena/atlas/lib/TestAlarmClock.java | 21 ++++++++++----------
4 files changed, 41 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/69fcb5f5/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
index 5174883..454f27c 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
@@ -18,9 +18,8 @@
package org.apache.jena.riot;
-import java.io.File ;
-
import org.apache.jena.atlas.lib.IRILib ;
+import org.apache.jena.base.Sys ;
import org.apache.jena.riot.system.IRIResolver ;
import org.apache.jena.util.FileUtils ;
import org.slf4j.Logger ;
@@ -37,7 +36,11 @@ public class SysRIOT
public static final String BNodeGenIdPrefix = "genid" ;
- public static final boolean isWindows = (File.pathSeparatorChar == ';' ) ;
+ /**
+ * @deprecated Use Sys.isWindows
+ */
+ @Deprecated
+ public static final boolean isWindows = Sys.isWindows ;
public static void setStrictMode(boolean state) {
SysRIOT.strictMode = state ;
http://git-wip-us.apache.org/repos/asf/jena/blob/69fcb5f5/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout1.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout1.java b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout1.java
index f30194d..9eae9f2 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout1.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout1.java
@@ -23,6 +23,7 @@ import static org.apache.jena.atlas.lib.Lib.sleep ;
import java.util.concurrent.TimeUnit ;
import org.apache.jena.atlas.junit.BaseTest ;
+import org.apache.jena.base.Sys ;
import org.apache.jena.graph.Graph ;
import org.apache.jena.query.* ;
import org.apache.jena.sparql.core.DatasetGraph ;
@@ -54,6 +55,13 @@ public class TestQueryExecutionTimeout1 extends BaseTest
FunctionRegistry.get().remove(ns + "wait") ;
}
+ // Loaded CI.
+ private static boolean mayBeErratic = Sys.isWindows ;
+
+ private int timeout(int time1, int time2) {
+ return mayBeErratic ? time2 : time1 ;
+ }
+
static private String prefix =
"PREFIX f: <http://example/ns#>\n"+
"PREFIX afn: <http://jena.apache.org/ARQ/function#>\n" ;
@@ -65,25 +73,26 @@ public class TestQueryExecutionTimeout1 extends BaseTest
// level checking.
@Test
- public void timeout_01()
- {
+ public void timeout_01() {
+ // Test unstable on loaded Jenkins CI on Windows.
String qs = prefix + "SELECT * { ?s ?p ?o }" ;
QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ;
qExec.setTimeout(50, TimeUnit.MILLISECONDS) ;
ResultSet rs = qExec.execSelect() ;
- sleep(200) ;
+ sleep(timeout(100, 300)) ;
exceptionExpected(rs) ;
}
@Test
public void timeout_02()
{
+ // Test unstable on loaded Jenkins CI on Windows.
String qs = prefix + "SELECT * { ?s ?p ?o }" ;
QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ;
qExec.setTimeout(50, TimeUnit.MILLISECONDS) ;
ResultSet rs = qExec.execSelect() ;
rs.next() ;
- sleep(75) ;
+ sleep(timeout(75, 300)) ;
exceptionExpected(rs) ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/69fcb5f5/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout2.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout2.java b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout2.java
index 3c4a4d2..c4d1e67 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout2.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestQueryExecutionTimeout2.java
@@ -19,6 +19,8 @@
package org.apache.jena.sparql.api;
import static org.apache.jena.atlas.lib.Lib.sleep ;
+
+import org.apache.jena.base.Sys ;
import org.apache.jena.graph.Graph ;
import org.apache.jena.query.* ;
import org.apache.jena.sparql.core.DatasetGraph ;
@@ -63,22 +65,28 @@ public class TestQueryExecutionTimeout2
}
- @Test public void timeout_30() { test2(200, 20, 50, true) ; }
+ // Loaded CI.
+ private static boolean mayBeErratic = Sys.isWindows ;
+
+ private int timeout(int time1, int time2) {
+ return mayBeErratic ? time2 : time1 ;
+ }
+
+ @Test public void timeout_30() { test2(200, 20, timeout(50, 250), true) ; }
@Test public void timeout_31() { test2(200, 50, 20, false) ; }
// Make sure it isn't timeout1 - delay longer than timeout1
@Test public void timeout_32() { test2(100, 500, 200, false) ; }
@Test public void timeout_33() { test2(150, -1, 200, false) ; }
- @Test public void timeout_34() { test2(10, 40, 100, true) ; }
+ @Test public void timeout_34() { test2(10, 40, timeout(100, 250), true) ; }
- @Test public void timeout_35() { test2(-1, 20, 50, true) ; }
+ @Test public void timeout_35() { test2(-1, 20, timeout(50, 250), true) ; }
@Test public void timeout_36() { test2(-1, 50, 20, false) ; }
@Test public void timeout_37() { test2(200, 200, 50, false) ; }
@Test public void timeout_38() { test2(200, -1, 50, false) ; }
-
private static void test2(long timeout1, long timeout2, int delay, boolean exceptionExpected)
{
// Enough rows to keep the iterator pipeline full.
http://git-wip-us.apache.org/repos/asf/jena/blob/69fcb5f5/jena-base/src/test/java/org/apache/jena/atlas/lib/TestAlarmClock.java
----------------------------------------------------------------------
diff --git a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestAlarmClock.java b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestAlarmClock.java
index 67415c4..773e0fd 100644
--- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestAlarmClock.java
+++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestAlarmClock.java
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicInteger ;
import org.apache.jena.atlas.junit.BaseTest ;
import org.apache.jena.base.Sys ;
-import org.junit.Assume ;
import org.junit.Test ;
public class TestAlarmClock extends BaseTest {
@@ -51,7 +50,13 @@ public class TestAlarmClock extends BaseTest {
private AtomicInteger count = new AtomicInteger(0) ;
private Runnable callback = ()->count.getAndIncrement() ;
-
+
+ // Loaded CI.
+ private static boolean mayBeErratic = Sys.isWindows ;
+
+ private int timeout(int time1, int time2) {
+ return mayBeErratic ? time2 : time1 ;
+ }
@Test
public void alarm_01() {
AlarmClock alarmClock = new AlarmClock() ;
@@ -64,12 +69,10 @@ public class TestAlarmClock extends BaseTest {
@Test
public void alarm_02() {
- Assume.assumeTrue( ! Sys.isWindows );
-
AlarmClock alarmClock = new AlarmClock() ;
// Short - happens.
alarmClock.add(callback, 10) ;
- sleep(120) ;
+ sleep(timeout(100, 250)) ;
assertEquals(1, count.get()) ;
// try to cancel anyway.
alarmClock.cancel(callback) ;
@@ -78,12 +81,10 @@ public class TestAlarmClock extends BaseTest {
@Test
public void alarm_03() {
- Assume.assumeTrue( ! Sys.isWindows );
-
AlarmClock alarmClock = new AlarmClock() ;
alarmClock.add(callback, 10) ;
alarmClock.add(callback, 1000000) ;
- sleep(150) ;
+ sleep(timeout(100, 300)) ;
// ping1 went off.
assertEquals(1, count.get()) ;
alarmClock.cancel(callback) ;
@@ -92,12 +93,10 @@ public class TestAlarmClock extends BaseTest {
@Test
public void alarm_04() {
- Assume.assumeTrue( ! Sys.isWindows );
-
AlarmClock alarmClock = new AlarmClock() ;
alarmClock.add(callback, 10) ;
alarmClock.add(callback, 20) ;
- sleep(100) ;
+ sleep(timeout(75, 300)) ;
// ping1 went off. ping2 went off.
assertEquals(2, count.get()) ;
alarmClock.release() ;