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 2020/04/14 18:13:51 UTC
[sling-org-apache-sling-testing-jcr-mock] branch master updated:
SLING-9373 remove compile dependency to guava
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-jcr-mock.git
The following commit(s) were added to refs/heads/master by this push:
new 58022b6 SLING-9373 remove compile dependency to guava
58022b6 is described below
commit 58022b6a4b4b3ff87472639b5f177a2e95ccfa4b
Author: sseifert <ss...@pro-vision.de>
AuthorDate: Tue Apr 14 20:13:35 2020 +0200
SLING-9373 remove compile dependency to guava
---
pom.xml | 15 ++++++++++-----
.../sling/testing/mock/jcr/MockNamespaceRegistry.java | 8 ++++----
.../org/apache/sling/testing/mock/jcr/MockQuery.java | 5 ++---
.../sling/testing/mock/jcr/MockQueryManager.java | 11 ++++++-----
.../apache/sling/testing/mock/jcr/MockQueryResult.java | 18 +++++-------------
.../org/apache/sling/testing/mock/jcr/MockSession.java | 8 +++-----
6 files changed, 30 insertions(+), 35 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1123441..cba0071 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>36</version>
+ <version>38</version>
<relativePath />
</parent>
@@ -69,12 +69,11 @@
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>15.0</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.1</version>
<scope>compile</scope>
</dependency>
-
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -102,6 +101,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>15.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockNamespaceRegistry.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockNamespaceRegistry.java
index 477a2fe..26763b2 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockNamespaceRegistry.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockNamespaceRegistry.java
@@ -23,15 +23,15 @@ import java.util.Set;
import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
+import org.apache.commons.collections4.BidiMap;
+import org.apache.commons.collections4.bidimap.TreeBidiMap;
/**
* Mock {@link NamespaceRegistry} implementation.
*/
class MockNamespaceRegistry implements NamespaceRegistry {
- private final BiMap<String, String> namespacePrefixMapping = HashBiMap.create();
+ private final BidiMap<String, String> namespacePrefixMapping = new TreeBidiMap<>();
public MockNamespaceRegistry() {
this.namespacePrefixMapping.put("jcr", "http://www.jcp.org/jcr/1.0");
@@ -44,7 +44,7 @@ class MockNamespaceRegistry implements NamespaceRegistry {
@Override
public String getPrefix(final String uri) throws RepositoryException {
- return this.namespacePrefixMapping.inverse().get(uri);
+ return this.namespacePrefixMapping.getKey(uri);
}
@Override
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
index 0e56026..cb6b385 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQuery.java
@@ -18,6 +18,7 @@
*/
package org.apache.sling.testing.mock.jcr;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -30,8 +31,6 @@ import javax.jcr.query.QueryResult;
import org.osgi.annotation.versioning.ConsumerType;
-import com.google.common.collect.ImmutableMap;
-
/**
* Mock implementation of {@link Query}.
*/
@@ -97,7 +96,7 @@ public final class MockQuery implements Query {
}
public Map<String, Value> getBindVariables() throws RepositoryException {
- return ImmutableMap.copyOf(variables);
+ return Collections.unmodifiableMap(variables);
}
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
index ddf2c12..6682321 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryManager.java
@@ -19,7 +19,10 @@
package org.apache.sling.testing.mock.jcr;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -31,8 +34,6 @@ import javax.jcr.query.qom.QueryObjectModelFactory;
import org.apache.commons.lang3.StringUtils;
-import com.google.common.collect.ImmutableList;
-
/**
* Mock implementation of {@link QueryManager}.
*/
@@ -41,12 +42,12 @@ class MockQueryManager implements QueryManager {
private List<MockQueryResultHandler> resultHandlers = new ArrayList<MockQueryResultHandler>();
@SuppressWarnings("deprecation")
- private static final List<String> SUPPORTED_QUERY_LANGUAGES = ImmutableList.of(
+ private static final List<String> SUPPORTED_QUERY_LANGUAGES = Stream.of(
Query.JCR_SQL2,
Query.JCR_JQOM,
Query.XPATH,
Query.SQL
- );
+ ).collect(Collectors.toList());
@Override
public Query createQuery(String statement, String language) throws RepositoryException {
@@ -73,7 +74,7 @@ class MockQueryManager implements QueryManager {
}
}
// fallback to empty result
- return new MockQueryResult(ImmutableList.<Node>of());
+ return new MockQueryResult(Collections.emptyList());
}
// --- unsupported operations ---
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
index 3ab0842..84cd1b9 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockQueryResult.java
@@ -18,24 +18,19 @@
*/
package org.apache.sling.testing.mock.jcr;
+import java.util.Collections;
import java.util.List;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
import javax.jcr.query.RowIterator;
import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
-import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
/**
* Mock implementation of {@link QueryResult}.
* Allows to manually set the expected result, optional with column names
@@ -48,7 +43,7 @@ public final class MockQueryResult implements QueryResult {
private final List<String> columnNames;
public MockQueryResult(List<Node> nodes) {
- this(nodes, ImmutableList.<String>of());
+ this(nodes, Collections.emptyList());
}
public MockQueryResult(List<Node> nodes, List<String> columnNames) {
@@ -63,12 +58,9 @@ public final class MockQueryResult implements QueryResult {
@Override
public RowIterator getRows() throws RepositoryException {
- return new RowIteratorAdapter(Lists.transform(nodes, new Function<Node, Row>() {
- @Override
- public Row apply(@Nullable Node node) {
- return new MockRow(columnNames, node);
- }
- }));
+ return new RowIteratorAdapter(nodes.stream()
+ .map(node -> new MockRow(columnNames, node))
+ .iterator());
}
@Override
diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
index f650365..6271c03 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockSession.java
@@ -46,8 +46,6 @@ import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
import org.apache.jackrabbit.value.ValueFactoryImpl;
import org.xml.sax.ContentHandler;
-import com.google.common.collect.ImmutableSet;
-
/**
* Mock {@link Session} implementation. This instance holds the JCR data in a
* simple ordered map.
@@ -228,8 +226,8 @@ class MockSession implements Session {
}
// Find all items matching the source
- List<ItemData> itemsToMove = new LinkedList<>();
- for (String key : ImmutableSet.copyOf(items.keySet())) {
+ List<ItemData> itemsToMove = new LinkedList<>();
+ for (String key : new ArrayList<>(items.keySet())) {
if (key.startsWith(source.getPath())) {
itemsToMove.add(items.remove(key));
}
@@ -244,7 +242,7 @@ class MockSession implements Session {
}
// Cycle items and add them back at the end
- for (String key : ImmutableSet.copyOf(items.keySet())) {
+ for (String key : new ArrayList<>(items.keySet())) {
if (key.equals(destination.getPath())) {
// Move items before destination
for (ItemData item : itemsToMove) {