JENA-812 : Correctly test command line arguments

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/45549158
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/45549158
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/45549158

Branch: refs/heads/eliminate-assignments
Commit: 455491582eaf8e744514e393c90d8a8fb9f2c04c
Parents: bc6c1fb
Author: Andy Seaborne <a...@apache.org>
Authored: Sat Nov 8 22:16:49 2014 +0000
Committer: Andy Seaborne <a...@apache.org>
Committed: Sat Nov 8 22:23:48 2014 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/jena/fuseki/FusekiCmd.java | 12 ++++++++----
 .../src/main/java/org/apache/jena/fuseki/FusekiCmd.java | 12 ++++++------
 2 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/45549158/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java 
b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
index 59d705f..77bafe8 100644
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
+++ b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
@@ -242,15 +242,19 @@ public class FusekiCmd extends CmdARQ
 
         if ( fusekiConfigFile != null )
         {
-            if ( x > 1 )
-                throw new CmdException("Dataset specified on the command line 
and also a configuration file specified.") ;
+            if ( x >= 1 )
+                throw new CmdException("Dataset specified on the command line 
but a configuration file also given.") ;
         }
         else
         {
-            if ( x == 0 )
+            if ( x != 1 )
                 throw new CmdException("Required: either --config=FILE or one 
of --mem, --file, --loc or --desc") ;
         }
         
+        // One of:
+        // argMem, argFile, argMemTDB, argTDB, 
+        
+        
         if ( contains(argMem) )
         {
             log.info("Dataset: in-memory") ;
@@ -308,7 +312,7 @@ public class FusekiCmd extends CmdARQ
         if ( contains(argFusekiConfig) )
         {
             if ( dsg != null )
-                throw new CmdException("Dataset specificed on the command line 
and also a configuration file specificed.") ;
+                throw new CmdException("(internal error) Dataset specificed on 
the command line but a a configuration file also given.") ;
             fusekiConfigFile = getValue(argFusekiConfig) ;
         }
         

http://git-wip-us.apache.org/repos/asf/jena/blob/45549158/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiCmd.java 
b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
index 7ac8b1d..5394bea 100644
--- a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
+++ b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
@@ -159,7 +159,7 @@ public class FusekiCmd {
 
             // ---- Datasets
 
-            if ( contains(argMem) )
+            if ( contains(argMem) )             
                 x++ ;
             if ( contains(argFile) )
                 x++ ;
@@ -171,18 +171,18 @@ public class FusekiCmd {
                 x++ ;
 
             if ( cmdLineDataset.fusekiConfigFile != null ) {
-                if ( x > 1 )
-                    throw new CmdException("Dataset specified on the command 
line and also a configuration file specified.") ;
+                if ( x >= 1 )
+                    throw new CmdException("Dataset specified on the command 
line but a configuration file also given.") ;
             } else {
-                //            if ( x == 0 )
-                //                throw new CmdException("Required: either 
--config=FILE or one of --mem, --file, --loc or --desc") ;
+                // No configuration file.  0 or 1 legal.
+                if ( x > 1 )
+                    throw new CmdException("Multiple ways providing a dataset. 
Only one of --mem, --file, --loc or --desc") ;
             }
 
             if ( contains(argMem) ) {
                 log.info("Dataset: in-memory") ;
                 cmdLineDataset = new ServerInitialConfig() ;
                 cmdLineDataset.templateFile = Template.templateMemFN ; 
-                //
             }
 
             if ( contains(argFile) ) {

Reply via email to