chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1619913 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/query/ test/java/org/apache/chemistry/opencmis/inmemory/query/
Date Fri, 22 Aug 2014 19:23:28 GMT
Author: jens
Date: Fri Aug 22 19:23:27 2014
New Revision: 1619913

URL: http://svn.apache.org/r1619913
Log:
InMemory: fix a bug in query processor, unescaping of string literals in properties

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=1619913&r1=1619912&r2=1619913&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
Fri Aug 22 19:23:27 2014
@@ -752,7 +752,6 @@ public class InMemoryQueryProcessor {
             }
             break;
         case HTML:
-        case STRING:
         case URI:
         case ID:
             if (rVal instanceof String) {
@@ -762,6 +761,15 @@ public class InMemoryQueryProcessor {
                 throwIncompatibleTypesException(lValue, rVal);
             }
             break;
+        case STRING:
+            if (rVal instanceof String) {
+            	String unesc = StringUtil.unescape((String) rVal, null);
+                LOG.debug("compare strings: " + lValue + " with " + unesc);
+                return ((String) lValue).compareTo(unesc);
+            } else {
+                throwIncompatibleTypesException(lValue, rVal);
+            }
+            break;
         }
         return 0;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1619913&r1=1619912&r2=1619913&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
Fri Aug 22 19:23:27 2014
@@ -38,6 +38,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.inmemory.AbstractServiceTest;
@@ -78,7 +79,7 @@ public class EvalQueryTest extends Abstr
         log.debug("Start testAll...");
         String statement = "SELECT * FROM cmis:document";
         ObjectList res = doQuery(statement);
-        assertEquals(5, res.getObjects().size());
+        assertEquals(6, res.getObjects().size());
         assertTrue(resultContains("alpha", res));
         assertFalse(resultContains("jens", res));
         log.debug("...Stop testAll.");
@@ -410,6 +411,16 @@ public class EvalQueryTest extends Abstr
         log.debug("...Stop testStringGreaterOrEquals.");
     }
 
+    @Test
+    public void testStringEscape() {
+        log.debug("Start testStringEscape...");
+        String statement = "SELECT * FROM " + BaseTypeId.CMIS_DOCUMENT.value() + " WHERE
" + PropertyIds.NAME
+                + "='John\\'s Document'";
+        ObjectList res = doQuery(statement);
+        assertEquals(1, res.getObjects().size());
+        assertTrue(resultContains( "John's Document", res));
+        log.debug("...Stop testStringEscape.");
+    }
     // //////////////////////////////////////////////////////////////////
     // Boolean condition tests
 
@@ -581,11 +592,11 @@ public class EvalQueryTest extends Abstr
         log.debug("Start testOrderBySystemProperties...");
         String statement = "SELECT * from cmis:document ORDER BY " + PropertyIds.NAME;
         ObjectList res = doQuery(statement);
-        assertEquals(5, res.getObjects().size());
+        assertEquals(6, res.getObjects().size());
         statement = "SELECT * from cmis:document ORDER BY " + PropertyIds.CREATION_DATE +
" ASC";
-        assertEquals(5, res.getObjects().size());
+        assertEquals(6, res.getObjects().size());
         statement = "SELECT * from cmis:document ORDER BY " + PropertyIds.LAST_MODIFICATION_DATE
+ " DESC";
-        assertEquals(5, res.getObjects().size());
+        assertEquals(6, res.getObjects().size());
         log.debug("...Stop testOrderBySystemProperties.");
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java?rev=1619913&r1=1619912&r2=1619913&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTestDataCreator.java
Fri Aug 22 19:23:27 2014
@@ -51,6 +51,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
@@ -201,6 +202,10 @@ public class QueryTestDataCreator {
         ContentStream content5 = createContent("I hate having pets.");
         doc5 = createDocument("epsilon", rootFolderId, COMPLEX_TYPE, propertyMap5, content5);
         assertNotNull(doc5);
+        
+        final Map<String, Object> propertyMap6 = new HashMap<String, Object>();
+        doc4 = createDocument("John's Document", rootFolderId, BaseTypeId.CMIS_DOCUMENT.value(),
propertyMap6, null);
+        assertNotNull(doc4);
 
     }
 



Mime
View raw message