You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2017/05/04 16:28:49 UTC
svn commit: r1793832 - in
/sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal:
JcrXmlContentTest.java JsonContentTest.java ResourcePathComparator.java
Author: sseifert
Date: Thu May 4 16:28:48 2017
New Revision: 1793832
URL: http://svn.apache.org/viewvc?rev=1793832&view=rev
Log:
SLING-6829 make unit tests independent of resource child order
Added:
sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java (with props)
Modified:
sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
Modified: sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java?rev=1793832&r1=1793831&r2=1793832&view=diff
==============================================================================
--- sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java (original)
+++ sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JcrXmlContentTest.java Thu May 4 16:28:48 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;
@@ -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);
Modified: sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java?rev=1793832&r1=1793831&r2=1793832&view=diff
==============================================================================
--- sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java (original)
+++ sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/JsonContentTest.java Thu May 4 16:28:48 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;
@@ -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);
Added: sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java
URL: http://svn.apache.org/viewvc/sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java?rev=1793832&view=auto
==============================================================================
--- sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java (added)
+++ sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java Thu May 4 16:28:48 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/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu May 4 16:28:48 2017
@@ -0,0 +1 @@
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
Propchange: sling/branches/fsresource-1.x/src/test/java/org/apache/sling/fsprovider/internal/ResourcePathComparator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain