jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1159357 - in /incubator/jena/Jena2/ARQ/trunk: src-dev/dev/ src-test/org/openjena/atlas/lib/ src/org/openjena/atlas/lib/ src/org/openjena/riot/web/
Date Thu, 18 Aug 2011 18:56:12 GMT
Author: andy
Date: Thu Aug 18 18:56:11 2011
New Revision: 1159357

URL: http://svn.apache.org/viewvc?rev=1159357&view=rev
Log:
JENA-104

Added:
    incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java
  (with props)
Modified:
    incubator/jena/Jena2/ARQ/trunk/src-dev/dev/DevARQ.java
    incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java
    incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TS_Lib.java
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/web/HttpOp.java

Modified: incubator/jena/Jena2/ARQ/trunk/src-dev/dev/DevARQ.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src-dev/dev/DevARQ.java?rev=1159357&r1=1159356&r2=1159357&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src-dev/dev/DevARQ.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src-dev/dev/DevARQ.java Thu Aug 18 18:56:11 2011
@@ -3,8 +3,6 @@ package dev ;
 
 public class DevARQ
 {
-    // ResultSetFormat and ResultsFormat - need just one. 
-    
     // FILTER(?x=?y) optimization - at least FILTER(sameTerm(?x,?y))
     // FILTER(?x=<x> && ...) does not push down on the ?x=<x>
     // Do FILTER placement before filter equality -- but dnager of breaking up BGPs.

Modified: incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java?rev=1159357&r1=1159356&r2=1159357&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src-dev/dev/RunARQ.java Thu Aug 18 18:56:11 2011
@@ -135,87 +135,13 @@ public class RunARQ
         System.exit(code) ;
     }
 
-    public static void main2(String ... args) throws Exception
-    {
-        final String queryString1 =  "SELECT * { ?s ?p ?o } LIMIT 1" ;
-        final String queryString2 =  "SELECT * { ?s ?p ?o } LIMIT 10" ;
-        
-        // GET graph
-        Map<String, HttpResponseHandler> handlers = new HashMap<String, HttpResponseHandler>()
;
-        // Chnage to one handler for all graph types.
-        handlers.put(WebContent.contentTypeTurtle, HttpResponseLib.graphReaderTurtle) ;
-        handlers.put(WebContent.contentTypeRDFXML, HttpResponseLib.graphReaderRDFXML) ;
-        handlers.put("*", HttpResponseLib.httpDumpResponse) ;
-
-        // RS support
-//        public static ResultsFormat contentTypeToResultSet(String contentType) { return
mapContentTypeToResultSet.get(contentType) ; }
-        final Map<String, ResultsFormat> mapContentTypeToResultSet = new HashMap<String,
ResultsFormat>() ;
-        {
-            mapContentTypeToResultSet.put(WebContent.contentTypeResultsXML, ResultsFormat.FMT_RS_XML)
;
-            mapContentTypeToResultSet.put(WebContent.contentTypeResultsJSON, ResultsFormat.FMT_RS_JSON)
;
-            mapContentTypeToResultSet.put(WebContent.contentTypeTextTSV, ResultsFormat.FMT_RS_TSV)
;
-        }
-
-        HttpCaptureResponse<ResultSet> captureRS = new HttpCaptureResponse<ResultSet>(){
-            ResultSet rs = null ;
-            //@Override
-            public void handle(String contentType, String baseIRI, HttpResponse response)
throws IOException
-            {
-                MediaType mt = new MediaType(contentType) ;
-                ResultsFormat fmt = mapContentTypeToResultSet.get(contentType) ; // contentTypeToResultSet(contentType)
;
-                InputStream in = response.getEntity().getContent() ;
-                rs = ResultSetFactory.load(in, fmt) ;
-                // Force reading
-                rs = ResultSetFactory.copyResults(rs) ;
-            }
-
-            //@Override
-            public ResultSet get()
-            {
-                return rs ;
-            }} ;
-        
-        handlers.put(WebContent.contentTypeResultsXML, captureRS) ;             
-        handlers.put(WebContent.contentTypeResultsJSON, captureRS) ;            
-        handlers.put(WebContent.contentTypeTextTSV, captureRS) ;     
-        
-        List<String> acceptables = new ArrayList<String>() ;
-        acceptables.add("text/turtle;q=0.8") ;
-        acceptables.add("application/rdf+xml;q=0.1") ;
-        String acceptHeader = Iter.asString(acceptables, " , ") ;
-        
-        HttpOp.execHttpGet("http://localhost:3030/ds/sparql?query="+URLEncoder.encode(queryString1,"UTF-8"),
-                           acceptHeader,
-                           handlers) ;
-        
-        ResultSetFormatter.out(captureRS.get()) ;
-
-        
-        ContentProducer cp = new ContentProducer() {
-            //@Override
-            public void writeTo(OutputStream outstream) throws IOException
-            {
-                outstream.write(StrUtils.asUTF8bytes(queryString2)) ;
-                //outstream.flush() ;
-            }} ;
-         
-        List<String> acceptResultSets = new ArrayList<String>() ;
-        acceptResultSets.add(WebContent.contentTypeResultsJSON+";q=0.9") ;
-        acceptResultSets.add(WebContent.contentTypeResultsXML+";q=0.5") ;
-        acceptResultSets.add(WebContent.contentTypeTextTSV+";q=0.8") ;
-        String acceptResultSet = Iter.asString(acceptResultSets, " , ") ;
-            
-        HttpOp.execHttpPost("http://localhost:3030/ds/sparql",
-                            WebContent.contentTypeSPARQLQuery, cp,
-                            acceptResultSet, handlers) ;
-        ResultSetFormatter.out(captureRS.get()) ;
-        exit(0) ;
-
-    }
-        
     @SuppressWarnings("deprecation")
     public static void main(String[] argv) throws Exception
     {
+        Node n = Node.createLiteral("9", null, XSDDatatype.XSDint) ;
+        System.out.println(FmtUtils.stringForNode(n, (PrefixMapping)null)) ;
+        exit(0) ;
+        
         arq.update.main("--file=U.ru", "--dump") ;
         exit(0) ;
         

Modified: incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TS_Lib.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TS_Lib.java?rev=1159357&r1=1159356&r2=1159357&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TS_Lib.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TS_Lib.java Thu Aug 18
18:56:11 2011
@@ -28,7 +28,8 @@ import org.junit.runners.Suite ;
     , TestStrUtils.class
     , TestXMLLib.class
     , TestAlarmClock.class
-    , TestRefLong.class 
+    , TestRefLong.class
+    , TestReverseComparator.class
 } )
 
 public class TS_Lib

Added: incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java?rev=1159357&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java
Thu Aug 18 18:56:11 2011
@@ -0,0 +1,88 @@
+/**
+ * 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.openjena.atlas.lib;
+
+
+import java.util.ArrayList ;
+import java.util.Arrays ;
+import java.util.Collections ;
+import java.util.Comparator ;
+import java.util.List ;
+
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+
+public class TestReverseComparator extends BaseTest
+{
+    static Comparator<String> normal = new Comparator<String>()
+    {
+        public int compare(String o1, String o2)
+        {
+            return o1.compareTo(o2);
+        }
+    };
+    
+    static Comparator<String> reverse = new ReverseComparator<String>(normal);
+    
+    
+    static Comparator<String> maxMin = new Comparator<String>()
+    {
+        public int compare(String o1, String o2)
+        {
+            int value = o1.compareTo(o2);
+            if (value > 0)
+                return Integer.MAX_VALUE;
+            else if (value < 0)
+                return Integer.MIN_VALUE;
+            else
+                return 0;
+        }
+    };
+    
+    static Comparator<String> reverseMaxMin = new ReverseComparator<String>(maxMin);
+    
+    static List<String> items = Arrays.asList("a", "b", "c", "d");
+    static List<String> itemsReverse = Arrays.asList("d", "c", "b", "a");
+    
+    @Test public void reverse_01()
+    {
+        List<String> modified = new ArrayList<String>(items);
+        Collections.sort(modified, reverse);
+        
+        test(itemsReverse, modified);
+    }
+    
+    @Test public void reverse_02()
+    {
+        List<String> modified = new ArrayList<String>(items);
+        Collections.sort(modified, reverseMaxMin);
+        
+        test(itemsReverse, modified);
+    }
+    
+    private void test(List<?> expected, List<?> actual)
+    {
+        assertEquals(expected.size(), actual.size());
+        
+        for (int i=0; i<expected.size(); i++)
+        {
+            assertEquals(expected.get(i), actual.get(i)) ;
+        }
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src-test/org/openjena/atlas/lib/TestReverseComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java?rev=1159357&r1=1159356&r2=1159357&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java Thu Aug
18 18:56:11 2011
@@ -32,6 +32,6 @@ public class ReverseComparator<T> implem
     
     public int compare(T o1, T o2)
     {
-        return -comparator.compare(o1, o2) ;
+        return comparator.compare(o2, o1) ;
     }
 }

Modified: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/web/HttpOp.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/web/HttpOp.java?rev=1159357&r1=1159356&r2=1159357&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/web/HttpOp.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/riot/web/HttpOp.java Thu Aug 18 18:56:11
2011
@@ -23,7 +23,6 @@ import static java.lang.String.format ;
 import java.io.IOException ;
 import java.io.InputStream ;
 import java.io.UnsupportedEncodingException ;
-import java.net.URLEncoder ;
 import java.util.Map ;
 import java.util.concurrent.atomic.AtomicLong ;
 



Mime
View raw message