This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.4.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git
commit 737a614b798c773203b465319c96d911bffde4b8 Author: Stefan Seifert <[email protected]> AuthorDate: Thu May 4 16:28:48 2017 +0000 SLING-6829 make unit tests independent of resource child order git-svn-id: https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1793832 13f79535-47bb-0310-9956-ffa450edef68 --- .../fsprovider/internal/JcrXmlContentTest.java | 6 ++-- .../sling/fsprovider/internal/JsonContentTest.java | 6 ++-- .../internal/ResourcePathComparator.java | 32 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java b/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java index 463963a..7bb6cee 100644 --- a/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java +++ b/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import java.util.Collections; import java.util.List; import javax.jcr.Node; @@ -45,7 +46,7 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; /** * Test access to files and folders from file system. @@ -155,7 +156,8 @@ public class JcrXmlContentTest { @Test public void testFolder3ChildNodes() throws RepositoryException { Resource folder3 = fsroot.getChild("folder3"); - List<Resource> children = ImmutableList.copyOf(folder3.listChildren()); + List<Resource> children = Lists.newArrayList(folder3.listChildren()); + Collections.sort(children, new ResourcePathComparator()); assertEquals(2, children.size()); Resource child1 = children.get(0); diff --git a/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java b/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java index 81a3eb5..7fb7ec8 100644 --- a/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java +++ b/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.math.BigDecimal; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -55,8 +56,8 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; /** * Test access to files and folders and JSON content from file system. @@ -250,7 +251,8 @@ public class JsonContentTest { @Test public void testFolder2ChildNodes() throws RepositoryException { Resource folder2 = fsroot.getChild("folder2"); - List<Resource> children = ImmutableList.copyOf(folder2.listChildren()); + List<Resource> children = Lists.newArrayList(folder2.listChildren()); + Collections.sort(children, new ResourcePathComparator()); assertEquals(2, children.size()); Resource child1 = children.get(0); diff --git a/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java b/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java new file mode 100644 index 0000000..f1c6272 --- /dev/null +++ b/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java @@ -0,0 +1,32 @@ +/* + * 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.apache.sling.fsprovider.internal; + +import java.util.Comparator; + +import org.apache.sling.api.resource.Resource; + +class ResourcePathComparator implements Comparator<Resource> { + + @Override + public int compare(Resource o1, Resource o2) { + return o1.getPath().compareTo(o2.getPath()); + } + +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
