You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by du...@apache.org on 2019/09/18 09:56:43 UTC
[sling-org-apache-sling-testing-clients] branch master updated
(4f59360 -> 1c9412e)
This is an automated email from the ASF dual-hosted git repository.
dulvac pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git.
from 4f59360 SLING-8710: IndexingClient should have configurable lanes
new 09b429d SLING-8710 refactor with java 8 streams and other cleanup
new 1c9412e SLING-8710 Added missing package info which resulted in warning
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:
.../testing/clients/indexing/IndexingClient.java | 65 ++++++++++------------
.../clients/query/{ => servlet}/package-info.java | 4 +-
.../clients/indexing/IndexingClientTest.java | 2 +-
3 files changed, 33 insertions(+), 38 deletions(-)
copy src/main/java/org/apache/sling/testing/clients/query/{ => servlet}/package-info.java (92%)
[sling-org-apache-sling-testing-clients] 01/02: SLING-8710 refactor
with java 8 streams and other cleanup
Posted by du...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dulvac pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git
commit 09b429d7e4b1f69cccba9de1e7a1a25d0358a0dd
Author: Andrei Dulvac <ad...@adobe.com>
AuthorDate: Wed Sep 18 11:55:53 2019 +0200
SLING-8710 refactor with java 8 streams and other cleanup
---
.../testing/clients/indexing/IndexingClient.java | 65 ++++++++++------------
.../clients/indexing/IndexingClientTest.java | 2 +-
2 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java b/src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java
index 5368e78..2bbea26 100644
--- a/src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java
+++ b/src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java
@@ -30,14 +30,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static java.util.UUID.randomUUID;
import static org.apache.http.HttpStatus.SC_OK;
@@ -146,6 +146,7 @@ public class IndexingClient extends SlingClient {
/** Global counter for how much time was spent in total waiting for async indexing */
private static final AtomicLong totalWaited = new AtomicLong();
+ public static final String ASYNC_INDEXER_CONFIG = "org.apache.jackrabbit.oak.plugins.index.AsyncIndexerService";
/**
* Constructor used by Builders and adaptTo(). <b>Should never be called directly from the code.</b>
@@ -197,24 +198,11 @@ public class IndexingClient extends SlingClient {
return configuredLanes;
}
- try {
- Object asyncConfigs = adaptTo(OsgiConsoleClient.class)
- .getConfiguration("org.apache.jackrabbit.oak.plugins.index.AsyncIndexerService")
- .get("asyncConfigs");
-
- if (asyncConfigs instanceof String[]) {
- String[] configs = (String[]) asyncConfigs; // ugly, we should refactor OsgiConsoleClient
-
- List<String> lanes = new ArrayList<>(configs.length);
- for (String asyncConfig : configs) {
- lanes.add(asyncConfig.split(":")[0]);
- }
- return lanes;
- } else {
- throw new ClientException("Cannot retrieve config from AsyncIndexerService, asyncConfigs is not a String[]");
- }
- } catch (Exception e) {
- throw new ClientException("Failed to retrieve lanes", e);
+ Object configs = adaptTo(OsgiConsoleClient.class).getConfiguration(ASYNC_INDEXER_CONFIG).get("asyncConfigs");
+ if (configs instanceof String[]) {
+ return Stream.of((String[]) configs).map(e -> e.split(":")[0]).collect(Collectors.toList());
+ } else {
+ throw new ClientException("Cannot retrieve config from AsyncIndexerService, asyncConfigs is not a String[]");
}
}
@@ -223,13 +211,8 @@ public class IndexingClient extends SlingClient {
if (configLanesCsv == null) {
return Collections.emptyList();
}
-
- String[] configLanesArr = configLanesCsv.split(",");
- for (int i = 0; i < configLanesArr.length; i++) {
- configLanesArr[i] = configLanesArr[i].trim();
- }
-
- return Collections.unmodifiableList(Arrays.asList(configLanesArr));
+ return Collections.unmodifiableList(Stream.of(configLanesCsv.split(","))
+ .map(e -> e.trim()).collect(Collectors.toList()));
}
/**
@@ -261,12 +244,7 @@ public class IndexingClient extends SlingClient {
final String uniqueValue = randomUUID().toString(); // to be added in all the content nodes
final List<String> lanes = getLaneNames(); // dynamically detect which lanes to wait for
- Polling p = new Polling(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return searchContent(lanes, uniqueValue);
- }
- });
+ Polling p = new Polling(() -> searchContent(lanes, uniqueValue));
try {
createContent(lanes, uniqueValue);
@@ -319,7 +297,7 @@ public class IndexingClient extends SlingClient {
String indexName = getIndexName(lane);
String indexDefinition = replacePlaceholders(INDEX_DEFINITION, lane, null);
LOG.info("Creating index {} in {}", indexName, INDEX_PATH);
- LOG.debug(indexDefinition);
+ LOG.debug("Index definition: {}", indexDefinition);
importContent(INDEX_PATH, "json", indexDefinition);
// Trigger reindex to make sure the complete index definition is used
setPropertyString(INDEX_PATH + "/" + indexName, "reindex", "true");
@@ -332,10 +310,27 @@ public class IndexingClient extends SlingClient {
* <p>User must manually call this if needed, as opposed to {@link #install()}, which is called
* automatically.</p>
*
+ * @deprecated Use #uninstallWithRetry
* @throws ClientException if the cleanup failed
*/
public void uninstall() throws ClientException {
- deletePath(WAIT_FOR_ASYNC_INDEXING_ROOT, SC_OK);
+ this.deletePath(WAIT_FOR_ASYNC_INDEXING_ROOT, SC_OK);
+ }
+
+ /**
+ * <p>Retries cleaning all the data generated by {@link #install()} and {@link #waitForAsyncIndexing(long, long)}.</p>
+ *
+ * <p>User must manually call this if needed, as opposed to {@link #install()}, which is called
+ * automatically.</p>
+ *
+ * @throws TimeoutException if retry operation times out and the path still exists
+ * @throws InterruptedException if the retry operation was interrupted by the user
+ */
+ public void uninstallWithRetry() throws TimeoutException, InterruptedException {
+ new Polling(() -> {
+ this.deletePath(WAIT_FOR_ASYNC_INDEXING_ROOT, SC_OK);
+ return this.exists(WAIT_FOR_ASYNC_INDEXING_ROOT);
+ }).poll(5000, 500);
}
/**
diff --git a/src/test/java/org/apache/sling/testing/clients/indexing/IndexingClientTest.java b/src/test/java/org/apache/sling/testing/clients/indexing/IndexingClientTest.java
index b97812a..6346afc 100644
--- a/src/test/java/org/apache/sling/testing/clients/indexing/IndexingClientTest.java
+++ b/src/test/java/org/apache/sling/testing/clients/indexing/IndexingClientTest.java
@@ -208,7 +208,7 @@ public class IndexingClientTest {
}
@Test
- public void testWaitForAsyncIndexing_ConfiguredLanes() throws ClientException, TimeoutException, InterruptedException {
+ public void testWaitForAsyncIndexingConfiguredLanes() throws ClientException, TimeoutException, InterruptedException {
client.setLaneNames(PRE_DEFINED_INDEXING_LANES);
client.waitForAsyncIndexing();
[sling-org-apache-sling-testing-clients] 02/02: SLING-8710 Added
missing package info which resulted in warning
Posted by du...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dulvac pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git
commit 1c9412e028203e69bc709a8e6b4f79fc9afc077e
Author: Andrei Dulvac <ad...@adobe.com>
AuthorDate: Wed Sep 18 11:56:25 2019 +0200
SLING-8710 Added missing package info which resulted in warning
---
.../clients/query/servlet/package-info.java | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/main/java/org/apache/sling/testing/clients/query/servlet/package-info.java b/src/main/java/org/apache/sling/testing/clients/query/servlet/package-info.java
new file mode 100644
index 0000000..0263e62
--- /dev/null
+++ b/src/main/java/org/apache/sling/testing/clients/query/servlet/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+/**
+ * Query tools leveraging javax.jcr.query
+ */
+@Version("1.2.2")
+package org.apache.sling.testing.clients.query.servlet;
+
+import org.osgi.annotation.versioning.Version;