Author: sseifert Date: Thu May 4 16:27:29 2017 New Revision: 1793831 URL: http://svn.apache.org/viewvc?rev=1793831&view=rev Log: SLING-6829 make unit tests independent of resource child order
Added: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java (with props) Modified: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java Modified: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java?rev=1793831&r1=1793830&r2=1793831&view=diff ============================================================================== --- sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java (original) +++ sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java Thu May 4 16:27:29 2017 @@ -27,6 +27,7 @@ import static org.junit.Assert.assertNot import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import java.util.Collections; import java.util.List; import javax.jcr.Node; @@ -43,7 +44,7 @@ import org.junit.Before; 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. @@ -152,7 +153,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); Modified: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java?rev=1793831&r1=1793830&r2=1793831&view=diff ============================================================================== --- sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java (original) +++ sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java Thu May 4 16:27:29 2017 @@ -29,6 +29,7 @@ import static org.junit.Assert.assertTha 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; @@ -53,8 +54,8 @@ import org.junit.Before; 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. @@ -247,7 +248,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); Added: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java?rev=1793831&view=auto ============================================================================== --- sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java (added) +++ sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java Thu May 4 16:27:29 2017 @@ -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()); + } + +} Propchange: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Thu May 4 16:27:29 2017 @@ -0,0 +1 @@ +LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author Propchange: sling/trunk/bundles/extensions/fsresource/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java ------------------------------------------------------------------------------ svn:mime-type = text/plain