You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by je...@apache.org on 2018/06/08 18:50:22 UTC

[sling-whiteboard] branch master updated (e5cc446 -> 057812b)

This is an automated email from the ASF dual-hosted git repository.

jeb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git.


    from e5cc446  updated readme and tests
     new 1afc12f  conforming to formatting standards
     new 057812b  formatting standard and clean up

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sling/resource/filter/ResourceFilter.java      |   2 +-
 .../filter/api/ResourceFilterFunction.java         |   2 +-
 .../filter/api/impl/ComparisonVisitor.java         |   2 +-
 .../filter/api/impl/ResourceFactoryImpl.java       |   4 +-
 .../resource/filter/ResourceFilterArgTest.java     |  12 +-
 .../resource/filter/ResourceFilterDateTest.java    | 140 +++----
 .../resource/filter/ResourceFilterLogicTest.java   |  60 ++-
 .../sling/resource/filter/ResourceFilterTest.java  | 463 +++++++++++----------
 .../resource/predicates/PropertyPredicates.java    |   5 +-
 .../resource/predicates/ResourcePredicates.java    |   3 +-
 .../resource/stream/ResourcePredicateTest.java     |  26 +-
 11 files changed, 360 insertions(+), 359 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
jeb@apache.org.

[sling-whiteboard] 02/02: formatting standard and clean up

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jeb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 057812bf7b16e475b90cc329fdb0717406f13e9e
Author: Jason E Bailey <je...@apache.org>
AuthorDate: Fri Jun 8 14:50:12 2018 -0400

    formatting standard and clean up
---
 .../resource/predicates/PropertyPredicates.java    |  5 ++---
 .../resource/predicates/ResourcePredicates.java    |  3 ++-
 .../resource/stream/ResourcePredicateTest.java     | 26 +++++++++++++---------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
index abfb2ee..c238ab3 100644
--- a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
+++ b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/PropertyPredicates.java
@@ -15,7 +15,6 @@ package org.apache.sling.resource.predicates;
 
 import java.lang.reflect.Array;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.Objects;
 import java.util.function.Predicate;
 
@@ -88,10 +87,10 @@ public class PropertyPredicates {
      *            earliest acceptable value
      * @return predicate
      */
-    public Predicate<Resource> isAfter(Date when) {
+    public Predicate<Resource> isAfter(Calendar when) {
         Objects.requireNonNull(when, "value may not be null");
         return value -> {
-            Date then = value.adaptTo(ValueMap.class).get(key, Date.class);
+            Calendar then = value.adaptTo(ValueMap.class).get(key, Calendar.class);
             if (then != null) {
                 return then.after(when);
             }
diff --git a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ResourcePredicates.java b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ResourcePredicates.java
index c417f3b..ac7e16c 100644
--- a/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ResourcePredicates.java
+++ b/resource-predicates/src/main/java/org/apache/sling/resource/predicates/ResourcePredicates.java
@@ -43,6 +43,7 @@ public class ResourcePredicates {
     public static Predicate<Resource> maxDepth(final int depth) {
         return new Predicate<Resource>() {
             int startingDepth = -1;
+
             @Override
             public boolean test(Resource resource) {
                 int currentDepth = resource.getPath().split("/").length;
@@ -51,7 +52,7 @@ public class ResourcePredicates {
                 }
                 return currentDepth - startingDepth < depth;
             }
-            
+
         };
     }
 
diff --git a/resource-predicates/src/test/java/org/apache/sling/resource/stream/ResourcePredicateTest.java b/resource-predicates/src/test/java/org/apache/sling/resource/stream/ResourcePredicateTest.java
index 67ddec2..a7788ed 100644
--- a/resource-predicates/src/test/java/org/apache/sling/resource/stream/ResourcePredicateTest.java
+++ b/resource-predicates/src/test/java/org/apache/sling/resource/stream/ResourcePredicateTest.java
@@ -21,8 +21,8 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
+import java.util.TimeZone;
 import java.util.stream.Collectors;
 
 import org.apache.sling.api.resource.Resource;
@@ -36,18 +36,21 @@ public class ResourcePredicateTest {
     @Rule
     public final SlingContext context = new SlingContext();
 
-    private Date midPoint;
+    private Calendar midPoint;
 
     private static String DATE_STRING = "Thu Aug 07 2013 16:32:59 GMT+0200";
 
     private static String DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";
 
     private List<Resource> list;
-    
+
     @Before
     public void setUp() throws ParseException {
         context.load().json("/data.json", "/content/sample/en");
-        midPoint = new SimpleDateFormat(DATE_FORMAT).parse(DATE_STRING);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("GMT+0200"));
+        cal.setTime(new SimpleDateFormat(DATE_FORMAT).parse(DATE_STRING));
+        midPoint = cal;
         Resource resource = context.resourceResolver().getResource("/content/sample/en");
         list = new ArrayList<>();
         resource.listChildren().forEachRemaining(list::add);
@@ -70,30 +73,31 @@ public class ResourcePredicateTest {
     @Test
     public void testBeforeThenDate() {
         List<Resource> found = list.stream()
-                .filter(property("jcr:content/created").isBefore(Calendar.getInstance().getTime()))
+                .filter(property("jcr:content/created").isBefore(Calendar.getInstance()))
                 .collect(Collectors.toList());
         assertEquals(7, found.size());
     }
 
     @Test
     public void testAfterThenDate() {
-        List<Resource> found = list.stream()
-                .filter( child("jcr:content").has(property("created").isAfter(new Date(0))))
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(0);
+        List<Resource> found = list.stream().filter(child("jcr:content").has(property("created").isAfter(cal)))
                 .collect(Collectors.toList());
         assertEquals(7, found.size());
     }
 
     @Test
     public void testAfterMidDate() {
-        List<Resource> found = list.stream()
-                .filter(property("jcr:content/created").isAfter(midPoint)).collect(Collectors.toList());
+        List<Resource> found = list.stream().filter(property("jcr:content/created").isAfter(midPoint))
+                .collect(Collectors.toList());
         assertEquals(4, found.size());
     }
 
     @Test
     public void testBeforeMidDate() {
-        List<Resource> found = list.stream()
-                .filter(property("jcr:content/created").isBefore(midPoint)).collect(Collectors.toList());
+        List<Resource> found = list.stream().filter(property("jcr:content/created").isBefore(midPoint))
+                .collect(Collectors.toList());
         assertEquals(1, found.size());
     }
 

-- 
To stop receiving notification emails like this one, please contact
jeb@apache.org.

[sling-whiteboard] 01/02: conforming to formatting standards

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jeb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 1afc12f1e3468a972f8527005b92faaf3c4654f3
Author: Jason E Bailey <je...@apache.org>
AuthorDate: Fri Jun 8 14:31:52 2018 -0400

    conforming to formatting standards
---
 .../sling/resource/filter/ResourceFilter.java      |   2 +-
 .../filter/api/ResourceFilterFunction.java         |   2 +-
 .../filter/api/impl/ComparisonVisitor.java         |   2 +-
 .../filter/api/impl/ResourceFactoryImpl.java       |   4 +-
 .../resource/filter/ResourceFilterArgTest.java     |  12 +-
 .../resource/filter/ResourceFilterDateTest.java    | 140 +++----
 .../resource/filter/ResourceFilterLogicTest.java   |  60 ++-
 .../sling/resource/filter/ResourceFilterTest.java  | 463 +++++++++++----------
 8 files changed, 341 insertions(+), 344 deletions(-)

diff --git a/resource-filter/src/main/java/org/apache/sling/resource/filter/ResourceFilter.java b/resource-filter/src/main/java/org/apache/sling/resource/filter/ResourceFilter.java
index 4dd517e..a752032 100644
--- a/resource-filter/src/main/java/org/apache/sling/resource/filter/ResourceFilter.java
+++ b/resource-filter/src/main/java/org/apache/sling/resource/filter/ResourceFilter.java
@@ -54,7 +54,7 @@ public class ResourceFilter implements Predicate<Resource> {
         this.context = context;
         return this;
     }
-    
+
     public ResourceFilter addArgument(String key, Object value) {
         getContext().addArgument(key, value);
         return this;
diff --git a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/ResourceFilterFunction.java b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/ResourceFilterFunction.java
index c5b2747..1633bc1 100644
--- a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/ResourceFilterFunction.java
+++ b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/ResourceFilterFunction.java
@@ -36,7 +36,7 @@ public interface ResourceFilterFunction extends BiFunction<Object[], Resource, O
      *         used as part of a comparison or Function
      */
     Object apply(Object[] arguments, Resource resource);
-    
+
     /**
      * Allows the name of the function to be defined
      * 
diff --git a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ComparisonVisitor.java b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ComparisonVisitor.java
index 6ac0cf0..de87c16 100644
--- a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ComparisonVisitor.java
+++ b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ComparisonVisitor.java
@@ -48,7 +48,7 @@ public class ComparisonVisitor implements Visitor<Function<Resource, Object>> {
 
     @Override
     public Function<Resource, Object> visit(Node node) {
-       
+
         switch (node.kind) {
         case FilterParserConstants.FUNCTION_NAME:
             // will only get here in the case of the 'FUNCTION' switch case
diff --git a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ResourceFactoryImpl.java b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ResourceFactoryImpl.java
index a206b79..c2ef533 100644
--- a/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ResourceFactoryImpl.java
+++ b/resource-filter/src/main/java/org/apache/sling/resource/filter/api/impl/ResourceFactoryImpl.java
@@ -30,7 +30,7 @@ public class ResourceFactoryImpl implements ResourceFilterFactory {
 
     @Reference
     List<ResourceFilterFunction> functions;
-    
+
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
     @Override
@@ -38,7 +38,7 @@ public class ResourceFactoryImpl implements ResourceFilterFactory {
         try {
             ResourceFilter filter = new ResourceFilter(script);
             Context context = filter.getContext();
-            for (ResourceFilterFunction func: functions) {
+            for (ResourceFilterFunction func : functions) {
                 context.addArgument(func.getName(), func);
             }
         } catch (ParseException e) {
diff --git a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterArgTest.java b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterArgTest.java
index 585a37a..cfb0017 100644
--- a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterArgTest.java
+++ b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterArgTest.java
@@ -41,20 +41,19 @@ public class ResourceFilterArgTest {
     @Test
     public void testMatchingNameInArg() throws Exception {
         ResourceFilter filter = new ResourceFilter("[jcr:content/jcr:title] == $lang")
-                        .addArgument("date", "2013-08-08T16:32:59").addArgument("lang", "Mongolian");
+                .addArgument("date", "2013-08-08T16:32:59").addArgument("lang", "Mongolian");
         List<Resource> found = handle(START_PATH, filter);
         assertEquals(1, found.size());
     }
-    
+
     @Test
     public void testMatchingNameAndMultipleArgs() throws Exception {
-        ResourceFilter filter = new ResourceFilter(
-                "[jcr:content/created] > $date and [jcr:content/jcr:title] == $lang")
-                        .addArgument("date", "2013-08-08T16:32:59").addArgument("lang", "Mongolian");
+        ResourceFilter filter = new ResourceFilter("[jcr:content/created] > $date and [jcr:content/jcr:title] == $lang")
+                .addArgument("date", "2013-08-08T16:32:59").addArgument("lang", "Mongolian");
         List<Resource> found = handle(START_PATH, filter);
         assertEquals(1, found.size());
     }
-    
+
     @Test
     public void testNameFunctionAgainstRegex() throws ParseException, Exception {
         ResourceFilter query = new ResourceFilter("name() like $regex").addArgument("regex", "testpage[1-2]");
@@ -67,5 +66,4 @@ public class ResourceFilterArgTest {
         return new ResourceStream(resource).stream(r -> true).filter(filter).collect(Collectors.toList());
     }
 
-
 }
diff --git a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterDateTest.java b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterDateTest.java
index 7937fba..69eb00c 100644
--- a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterDateTest.java
+++ b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterDateTest.java
@@ -28,74 +28,74 @@ import org.junit.Test;
 
 public class ResourceFilterDateTest {
 
-	@Rule
-	public final SlingContext context = new SlingContext();
-	
-	private static String START_PATH = "/content/sample/en";
-
-	@Before
-	public void setUp() throws ParseException, java.text.ParseException {
-		context.load().json("/data.json", "/content/sample/en");
-	}
-
-	@Test
-	public void testPropLessThanDateFunction() throws ParseException {
-		String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00')";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] < 2013-08-08T16:32:59.000";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] < 2013-08-08T16:32";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] < date('2013-08-08','yyyy-MM-dd')";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] less than 2013-08-07T14:32:59";
-		found = handle(START_PATH, query);
-		assertEquals(2, found.size());
-
-		query = "[jcr:content/created] <= 2013-08-07T14:32:59";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] <= 2013-08-07T14:32";
-		found = handle(START_PATH, query);
-		assertEquals(2, found.size());
-
-		query = "[jcr:content/created] < 2013-08-07T14:32:59.010";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] > 2013-08-07T14:32";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] greater than 2013-08-07T14:32:59";
-		found = handle(START_PATH, query);
-		assertEquals(2, found.size());
-
-		query = "[jcr:content/created] >= 2013-08-07T14:32:59";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-
-		query = "[jcr:content/created] like '2013-08-07.*'";
-		found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-		
-		query = "[jcr:content/created] like '201[2-5].*'";
-		found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-	
-	
-	private List<Resource> handle(String path, String filter) throws ParseException {
-		Resource resource = context.resourceResolver().getResource(path);
-		return new ResourceFilterStream(resource).stream(r -> true).filter(new ResourceFilter(filter)).collect(Collectors.toList());
-	}
+    @Rule
+    public final SlingContext context = new SlingContext();
+
+    private static String START_PATH = "/content/sample/en";
+
+    @Before
+    public void setUp() throws ParseException, java.text.ParseException {
+        context.load().json("/data.json", "/content/sample/en");
+    }
+
+    @Test
+    public void testPropLessThanDateFunction() throws ParseException {
+        String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00')";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] < 2013-08-08T16:32:59.000";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] < 2013-08-08T16:32";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] < date('2013-08-08','yyyy-MM-dd')";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] less than 2013-08-07T14:32:59";
+        found = handle(START_PATH, query);
+        assertEquals(2, found.size());
+
+        query = "[jcr:content/created] <= 2013-08-07T14:32:59";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] <= 2013-08-07T14:32";
+        found = handle(START_PATH, query);
+        assertEquals(2, found.size());
+
+        query = "[jcr:content/created] < 2013-08-07T14:32:59.010";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] > 2013-08-07T14:32";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] greater than 2013-08-07T14:32:59";
+        found = handle(START_PATH, query);
+        assertEquals(2, found.size());
+
+        query = "[jcr:content/created] >= 2013-08-07T14:32:59";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] like '2013-08-07.*'";
+        found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+
+        query = "[jcr:content/created] like '201[2-5].*'";
+        found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    private List<Resource> handle(String path, String filter) throws ParseException {
+        Resource resource = context.resourceResolver().getResource(path);
+        return new ResourceFilterStream(resource).stream(r -> true).filter(new ResourceFilter(filter))
+                .collect(Collectors.toList());
+    }
 }
diff --git a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterLogicTest.java b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterLogicTest.java
index 470c15a..99f6591 100644
--- a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterLogicTest.java
+++ b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterLogicTest.java
@@ -28,40 +28,38 @@ import org.junit.Test;
 
 public class ResourceFilterLogicTest {
 
-	@Rule
-	public final SlingContext context = new SlingContext();
-	
-	private static String START_PATH = "/content/sample/en";
-	
+    @Rule
+    public final SlingContext context = new SlingContext();
 
-	@Before
-	public void setUp() throws ParseException, java.text.ParseException {
-		context.load().json("/data.json", START_PATH);
-	}
+    private static String START_PATH = "/content/sample/en";
 
-	
-	@Test
-	public void testDateAndProperty() throws ParseException {
-		String query = "[jcr:content/created] > '2013-08-08T16:32:59' and [jcr:content/jcr:title] == 'Mongolian'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
+    @Before
+    public void setUp() throws ParseException, java.text.ParseException {
+        context.load().json("/data.json", START_PATH);
+    }
 
-		query = "([jcr:content/created] < '2013-08-08T16:32' and [jcr:content/jcr:title] == 'English') or [jcr:content/jcr:title] == 'Mongolian'";
-		found = handle(START_PATH, query);
-		assertEquals(4, found.size());
+    @Test
+    public void testDateAndProperty() throws ParseException {
+        String query = "[jcr:content/created] > '2013-08-08T16:32:59' and [jcr:content/jcr:title] == 'Mongolian'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
 
-		query = "[jcr:content/created] < '2013-08-08T16:32' and ([jcr:content/jcr:title] == 'English' or [jcr:content/jcr:title] == 'Mongolian')";
-		found = handle(START_PATH, query);
-		assertEquals(3, found.size());
+        query = "([jcr:content/created] < '2013-08-08T16:32' and [jcr:content/jcr:title] == 'English') or [jcr:content/jcr:title] == 'Mongolian'";
+        found = handle(START_PATH, query);
+        assertEquals(4, found.size());
 
-		query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') or [jcr:content/jcr:title] == 'Mongolian'";
-		found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-	
-	
-	private List<Resource> handle(String path, String filter) throws ParseException {
-		Resource resource = context.resourceResolver().getResource(path);
-		return new ResourceFilterStream(resource).stream(r -> true).filter(new ResourceFilter(filter)).collect(Collectors.toList());
-	}
+        query = "[jcr:content/created] < '2013-08-08T16:32' and ([jcr:content/jcr:title] == 'English' or [jcr:content/jcr:title] == 'Mongolian')";
+        found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+
+        query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') or [jcr:content/jcr:title] == 'Mongolian'";
+        found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    private List<Resource> handle(String path, String filter) throws ParseException {
+        Resource resource = context.resourceResolver().getResource(path);
+        return new ResourceFilterStream(resource).stream(r -> true).filter(new ResourceFilter(filter))
+                .collect(Collectors.toList());
+    }
 }
diff --git a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterTest.java b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterTest.java
index f57f7a2..1fc6cc8 100644
--- a/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterTest.java
+++ b/resource-filter/src/test/java/org/apache/sling/resource/filter/ResourceFilterTest.java
@@ -32,235 +32,236 @@ import org.junit.Test;
 
 public class ResourceFilterTest {
 
-	@Rule
-	public final SlingContext context = new SlingContext();
-
-	private static String START_PATH = "/content/sample/en";
-	private Date midPoint;
-
-	private static String DATE_STRING = "Thu Aug 07 2013 16:32:59 GMT+0200";
-	private static String NEW_DATE = "2013-08-08T16:32:59.000+02:00";
-	private static String DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";
-
-	@Before
-	public void setUp() throws ParseException, java.text.ParseException {
-		context.load().json("/data.json", "/content/sample/en");
-		midPoint = new SimpleDateFormat(DATE_FORMAT).parse(DATE_STRING);
-	}
-
-	@Test
-	public void testPropertyEquals() throws ParseException {
-		String query = "[jcr:content/jcr:title] == 'English'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testPropertyIs() throws ParseException {
-		String query = "[jcr:content/jcr:title] is 'English'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testDateBeforeValue() throws ParseException {
-		String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00')";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testDateBeforeValue2() throws ParseException {
-		String query = "[jcr:content/created] less than date('2013-08-08T16:32:59.000+02:00')";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testDateBeforeValue3() throws ParseException {
-		String query = "[jcr:content/created] < date('2013-08-08','yyyy-MM-dd')";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testDateAndProperty() throws ParseException {
-		String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') and [jcr:content/jcr:title] == 'English'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testDateAndPropertyTwice() throws ParseException {
-		String query = "([jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') and [jcr:content/jcr:title] == 'English') or [jcr:content/jcr:title] == 'Mongolian'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testDateOrProperty() throws ParseException {
-		String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') or [jcr:content/jcr:title] == 'Mongolian'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testDateAsString() throws ParseException {
-		String query = "[jcr:content/created] < '2013-08-08T16:32'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testNullPropertyAndLimit() throws ParseException {
-		String query = "[jcr:content/foo] == null ";
-		Resource resource = context.resourceResolver().getResource(START_PATH);
-		List<Resource> found = new ResourceStream(resource).stream(r -> true).filter(new ResourceFilter(query)).limit(3).collect(Collectors.toList());
-		assertEquals(3, found.size());
-	}
-
-	@Test
-	public void testNullProperty() throws ParseException {
-		String query = "[jcr:content/foo] == null ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(20, found.size());
-	}
-
-	@Test
-	public void testNumberLiteral() throws ParseException {
-		String query = "[count] < 2 ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testNumberLiteral2() throws ParseException {
-		String query = "[count] < 2 or [count] > 1";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testNumberLiteral3() throws ParseException {
-		String query = "[views] < 7 ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testNotNullProperty() throws ParseException {
-		String query = "[layout] != null ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(5, found.size());
-	}
-
-	@Test
-	public void testNotProperty() throws ParseException {
-		String query = "[layout] != 'foo' ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testNameFunctionIs() throws ParseException {
-		String query = "name() == 'testpage1'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testNameFunctionAgainstRegex() throws ParseException {
-		String query = "name() like 'testpage.*'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testNameFunctionAgainstRegex2() throws ParseException {
-		String query = "name() like 'testpage[1-2]'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(2, found.size());
-	}
-
-	@Test
-	public void testChildExistence() throws ParseException {
-		String query = "name() == 'testpage3' ";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testBoolean() throws ParseException {
-		String query = "[published] == true";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testContains() throws ParseException {
-		String query = "[jcr:content/monkey] contains 'fish'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testContainsNot() throws ParseException {
-		String query = "[jcr:content/monkey] contains not 'fish'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(19, found.size());
-	}
-
-	@Test
-	public void testIn() throws ParseException {
-		String query = "'fish' in [jcr:content/monkey]";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testPathLike() throws ParseException {
-		String query = "path() like '/content/sample/en/testpage1.*'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(4, found.size());
-	}
-
-	@Test
-	public void testPathLike2() throws ParseException {
-		String query = "path() like '/content/sample/en/testpage1'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testPathLike3() throws ParseException {
-		String query = "path() is '/content/sample/en/testpage1'";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(1, found.size());
-	}
-
-	@Test
-	public void testNotIn() throws ParseException {
-		String query = "'fish' not in [jcr:content/monkey]";
-		List<Resource> found = handle(START_PATH, query);
-		assertEquals(19, found.size());
-	}
-
-	@Test
-	public void testInNotException() throws ParseException {
-		ParseException error = null;
-		try {
-			String query = "'fish' in not [jcr:content/monkey]";
-			handle(START_PATH, query);
-		} catch (ParseException e) {
-			error = e;
-		}
-		assert (error.getMessage()
-				.startsWith("Encountered \" <PROPERTY> \"jcr:content/monkey \"\" at line 1, column 15."));
-	}
-
-	private List<Resource> handle(String path, String filter) throws ParseException {
-		Resource resource = context.resourceResolver().getResource(path);
-		Predicate<Resource> f = new ResourceFilter(filter);
-		return new ResourceStream(resource).stream(r -> true).filter(f).collect(Collectors.toList());
-	}
+    @Rule
+    public final SlingContext context = new SlingContext();
+
+    private static String START_PATH = "/content/sample/en";
+    private Date midPoint;
+
+    private static String DATE_STRING = "Thu Aug 07 2013 16:32:59 GMT+0200";
+    private static String NEW_DATE = "2013-08-08T16:32:59.000+02:00";
+    private static String DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";
+
+    @Before
+    public void setUp() throws ParseException, java.text.ParseException {
+        context.load().json("/data.json", "/content/sample/en");
+        midPoint = new SimpleDateFormat(DATE_FORMAT).parse(DATE_STRING);
+    }
+
+    @Test
+    public void testPropertyEquals() throws ParseException {
+        String query = "[jcr:content/jcr:title] == 'English'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testPropertyIs() throws ParseException {
+        String query = "[jcr:content/jcr:title] is 'English'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testDateBeforeValue() throws ParseException {
+        String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00')";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testDateBeforeValue2() throws ParseException {
+        String query = "[jcr:content/created] less than date('2013-08-08T16:32:59.000+02:00')";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testDateBeforeValue3() throws ParseException {
+        String query = "[jcr:content/created] < date('2013-08-08','yyyy-MM-dd')";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testDateAndProperty() throws ParseException {
+        String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') and [jcr:content/jcr:title] == 'English'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testDateAndPropertyTwice() throws ParseException {
+        String query = "([jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') and [jcr:content/jcr:title] == 'English') or [jcr:content/jcr:title] == 'Mongolian'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testDateOrProperty() throws ParseException {
+        String query = "[jcr:content/created] < date('2013-08-08T16:32:59.000+02:00') or [jcr:content/jcr:title] == 'Mongolian'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testDateAsString() throws ParseException {
+        String query = "[jcr:content/created] < '2013-08-08T16:32'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testNullPropertyAndLimit() throws ParseException {
+        String query = "[jcr:content/foo] == null ";
+        Resource resource = context.resourceResolver().getResource(START_PATH);
+        List<Resource> found = new ResourceStream(resource).stream(r -> true).filter(new ResourceFilter(query)).limit(3)
+                .collect(Collectors.toList());
+        assertEquals(3, found.size());
+    }
+
+    @Test
+    public void testNullProperty() throws ParseException {
+        String query = "[jcr:content/foo] == null ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(20, found.size());
+    }
+
+    @Test
+    public void testNumberLiteral() throws ParseException {
+        String query = "[count] < 2 ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testNumberLiteral2() throws ParseException {
+        String query = "[count] < 2 or [count] > 1";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testNumberLiteral3() throws ParseException {
+        String query = "[views] < 7 ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testNotNullProperty() throws ParseException {
+        String query = "[layout] != null ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(5, found.size());
+    }
+
+    @Test
+    public void testNotProperty() throws ParseException {
+        String query = "[layout] != 'foo' ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testNameFunctionIs() throws ParseException {
+        String query = "name() == 'testpage1'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testNameFunctionAgainstRegex() throws ParseException {
+        String query = "name() like 'testpage.*'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testNameFunctionAgainstRegex2() throws ParseException {
+        String query = "name() like 'testpage[1-2]'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(2, found.size());
+    }
+
+    @Test
+    public void testChildExistence() throws ParseException {
+        String query = "name() == 'testpage3' ";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testBoolean() throws ParseException {
+        String query = "[published] == true";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testContains() throws ParseException {
+        String query = "[jcr:content/monkey] contains 'fish'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testContainsNot() throws ParseException {
+        String query = "[jcr:content/monkey] contains not 'fish'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(19, found.size());
+    }
+
+    @Test
+    public void testIn() throws ParseException {
+        String query = "'fish' in [jcr:content/monkey]";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testPathLike() throws ParseException {
+        String query = "path() like '/content/sample/en/testpage1.*'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(4, found.size());
+    }
+
+    @Test
+    public void testPathLike2() throws ParseException {
+        String query = "path() like '/content/sample/en/testpage1'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testPathLike3() throws ParseException {
+        String query = "path() is '/content/sample/en/testpage1'";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(1, found.size());
+    }
+
+    @Test
+    public void testNotIn() throws ParseException {
+        String query = "'fish' not in [jcr:content/monkey]";
+        List<Resource> found = handle(START_PATH, query);
+        assertEquals(19, found.size());
+    }
+
+    @Test
+    public void testInNotException() throws ParseException {
+        ParseException error = null;
+        try {
+            String query = "'fish' in not [jcr:content/monkey]";
+            handle(START_PATH, query);
+        } catch (ParseException e) {
+            error = e;
+        }
+        assert (error.getMessage()
+                .startsWith("Encountered \" <PROPERTY> \"jcr:content/monkey \"\" at line 1, column 15."));
+    }
+
+    private List<Resource> handle(String path, String filter) throws ParseException {
+        Resource resource = context.resourceResolver().getResource(path);
+        Predicate<Resource> f = new ResourceFilter(filter);
+        return new ResourceStream(resource).stream(r -> true).filter(f).collect(Collectors.toList());
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
jeb@apache.org.