jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1604746 - in /jena/Experimental/jena-fuseki2/src: main/java/org/apache/jena/fuseki/mgt/ test/java/org/apache/jena/fuseki/
Date Mon, 23 Jun 2014 11:01:00 GMT
Author: andy
Date: Mon Jun 23 11:00:59 2014
New Revision: 1604746

URL: http://svn.apache.org/r1604746
Log:
JENA-722 : Include dataset offline/active state in its description.

Modified:
    jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
    jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
    jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
    jena/Experimental/jena-fuseki2/src/test/java/org/apache/jena/fuseki/TestAdmin.java

Modified: jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java?rev=1604746&r1=1604745&r2=1604746&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
(original)
+++ jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
Mon Jun 23 11:00:59 2014
@@ -143,9 +143,9 @@ public class ActionDatasets extends Acti
             
             // Keep a persistent copy.
             String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString()
;
-            OutputStream outCopy = new FileOutputStream(filename) ;
-            RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
-            IO.close(outCopy) ;
+            try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+                RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+            }
             
             Statement stmt = getOne(model, null, pServiceName, null) ;
             if ( stmt == null ) {

Modified: jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java?rev=1604746&r1=1604745&r2=1604746&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
(original)
+++ jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
Mon Jun 23 11:00:59 2014
@@ -40,6 +40,7 @@ public class JsonConst
     public static final String endpoints    = "endpoints" ;
 
     public static final String dsName       = "ds.name" ;
+    public static final String dsState      = "ds.state" ;
     public static final String dsService    = "ds.services" ;
 
     public static final String srvType      = "srv.type" ;

Modified: jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java?rev=1604746&r1=1604745&r2=1604746&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
(original)
+++ jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
Mon Jun 23 11:00:59 2014
@@ -42,6 +42,8 @@ public class JsonDescription {
         builder.startObject() ;
         builder.key(JsonConst.dsName).value(access.getName()) ;
         
+        builder.key(JsonConst.dsState).value(access.getDataService().isAcceptingRequests())
;
+        
         builder.key(JsonConst.dsService) ;
         builder.startArray() ;
         

Modified: jena/Experimental/jena-fuseki2/src/test/java/org/apache/jena/fuseki/TestAdmin.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/test/java/org/apache/jena/fuseki/TestAdmin.java?rev=1604746&r1=1604745&r2=1604746&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/test/java/org/apache/jena/fuseki/TestAdmin.java (original)
+++ jena/Experimental/jena-fuseki2/src/test/java/org/apache/jena/fuseki/TestAdmin.java Mon
Jun 23 11:00:59 2014
@@ -20,7 +20,10 @@ package org.apache.jena.fuseki;
 
 import static org.apache.jena.fuseki.ServerTest.datasetPath ;
 import static org.apache.jena.fuseki.ServerTest.urlRoot ;
-import static org.apache.jena.fuseki.mgt.MgtConst.* ;
+import static org.apache.jena.fuseki.mgt.MgtConst.opDatasets ;
+import static org.apache.jena.fuseki.mgt.MgtConst.opPing ;
+import static org.apache.jena.fuseki.mgt.MgtConst.opServer ;
+import static org.apache.jena.fuseki.mgt.MgtConst.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 ;
@@ -37,7 +40,6 @@ import org.apache.http.NameValuePair ;
 import org.apache.http.client.entity.UrlEncodedFormEntity ;
 import org.apache.http.entity.FileEntity ;
 import org.apache.http.message.BasicNameValuePair ;
-import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.json.JSON ;
 import org.apache.jena.atlas.json.JsonArray ;
 import org.apache.jena.atlas.json.JsonObject ;
@@ -106,19 +108,17 @@ public class TestAdmin extends BaseTest 
     
     @Test public void list_datasets_1() {
         try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets) ; ) { }
-        catch (IOException e) { IO.exception(e); }
     }
     
     @Test public void list_datasets_2() {
-        TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets) ;
-        try {
+        try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets) ) {
             assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
-            JsonValue v = JSON.parse(in) ;
+            JsonValue v = JSON.parseAny(in) ;
             assertNotNull(v.getAsObject().get("datasets")) ; 
             checkJsonDatasetsAll(v);
-        } finally { IO.close(in) ; }
+        }
     }
-
+    
     // Specific dataset
     @Test public void list_datasets_3() {
         checkExists(datasetPath) ;
@@ -127,7 +127,7 @@ public class TestAdmin extends BaseTest 
     // Specific dataset
     @Test public void list_datasets_4() {
         try {
-            TypedInputStream in = execHttpGet(ServerTest.urlRoot+"$/"+opDatasets+"/does-not-exist")
;
+            getDatasetDescription("does-not-exist") ;
         } catch (HttpException ex) {
             assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode()) ;
         }
@@ -135,10 +135,18 @@ public class TestAdmin extends BaseTest 
     
     // Specific dataset
     @Test public void list_datasets_5() {
-        JsonValue v = execGetJSON(urlRoot+"$/"+opDatasets+datasetPath) ;
+        JsonValue v = getDatasetDescription(datasetPath) ;
         checkJsonDatasetsOne(v.getAsObject()) ;
     }
 
+    private static JsonValue getDatasetDescription(String dsName) {
+        try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+dsName) ) {
+            assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
+            JsonValue v = JSON.parse(in) ;
+            return v ;
+        }
+    }
+
     // -- Add
     
     private static void addTestDataset() {
@@ -351,10 +359,9 @@ public class TestAdmin extends BaseTest 
         
         @Override
         public void handle(String baseIRI, HttpResponse response) throws IOException {
-            InputStream in = response.getEntity().getContent() ;
-            try {
+            try ( InputStream in = response.getEntity().getContent() ) {
                 result = JSON.parseAny(in) ;
-            } finally { IO.close(in) ; }
+            }
         }
         
     }
@@ -426,13 +433,11 @@ public class TestAdmin extends BaseTest 
     private static void askPing(String name) {
         if ( name.startsWith("/") )
             name = name.substring(1) ;
-        TypedInputStream in = execHttpGet(urlRoot+name+"/sparql?query=ASK%7B%7D") ; 
-        IO.close(in) ;
+        try ( TypedInputStream in = execHttpGet(urlRoot+name+"/sparql?query=ASK%7B%7D") )
{}  
     }
     
     private static void adminPing(String name) {
-        TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+name) ; 
-        IO.close(in) ;
+        try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+name) ) {} 
     }
 
     private static void checkExists(String name)  {
@@ -445,6 +450,8 @@ public class TestAdmin extends BaseTest 
         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) {
@@ -474,6 +481,7 @@ public class TestAdmin extends BaseTest 
         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()) ;
     }
     
@@ -497,11 +505,10 @@ public class TestAdmin extends BaseTest 
     }
 
     private static JsonValue execGetJSON(String url) {
-        TypedInputStream in = execHttpGet(url) ;
-        try { 
+        try ( TypedInputStream in = execHttpGet(url) ) {
             assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
             return JSON.parse(in) ; 
-        } finally { IO.close(in) ; }
+        }
     }
     
     /*



Mime
View raw message