You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2015/08/26 16:39:44 UTC
svn commit: r1697947 - in /sling/trunk/launchpad/integration-tests/src/main:
java/org/apache/sling/launchpad/webapp/integrationtest/indexing/
resources/integration-test/indexing/
Author: bdelacretaz
Date: Wed Aug 26 14:39:44 2015
New Revision: 1697947
URL: http://svn.apache.org/r1697947
Log:
Test indexing under several paths
Added:
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/another.pdf (with props)
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/french.pdf (with props)
Modified:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/indexing/FullTextIndexingTest.java
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/indexing/FullTextIndexingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/indexing/FullTextIndexingTest.java?rev=1697947&r1=1697946&r2=1697947&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/indexing/FullTextIndexingTest.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/indexing/FullTextIndexingTest.java Wed Aug 26 14:39:44 2015
@@ -18,12 +18,15 @@
*/
package org.apache.sling.launchpad.webapp.integrationtest.indexing;
-import java.io.IOException;
+import static org.junit.Assert.assertFalse;
+
import java.io.InputStream;
import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.testing.tools.retry.RetryLoop;
@@ -31,36 +34,46 @@ import org.apache.sling.testing.tools.re
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* The <tt>FullTextIndexingTest</tt> verifies that a PDF file which is uploaded will have its contents indexed and
* available for full-text searches, in several different paths.
*
*/
+@RunWith(Parameterized.class)
public class FullTextIndexingTest {
private final HttpTest H = new HttpTest();
- private String folderName;
- private String fileName = "lorem-ipsum.pdf";
+ private final String uploadPath;
+ private final String fileName;
+ private final String expectedText;
+
+ @Parameters(name="{index} - {0}")
+ public static Collection<Object[]> data() {
+ final List<Object []> result = new ArrayList<Object []>();
+ result.add(new Object[] { "lorem-ipsum.pdf", "Excepteur", "/tmp/test-" });
+ result.add(new Object[] { "another.pdf", "some text that we will search for", "/var/test-" });
+ result.add(new Object[] { "french.pdf", "un autre PDF pour le test fulltext", "/libs/test-" });
+ return result;
+ }
+
+ public FullTextIndexingTest(String filename, String expectedText, String uploadPathPrefix) {
+ this.fileName = filename;
+ this.expectedText = expectedText;
+ this.uploadPath = uploadPathPrefix + getClass().getSimpleName();
+ }
@Test
- public void testUploadedPdfIsIndexed() throws IOException, JSONException {
-
- String localPath = "/integration-test/indexing/" + fileName;
- InputStream resourceToUpload = getClass().getResourceAsStream(localPath);
- if (resourceToUpload == null)
- throw new IllegalArgumentException("No resource to upload found at " + localPath);
-
- H.getTestClient().mkdir(HttpTest.WEBDAV_BASE_URL + "/" + folderName);
- H.getTestClient().upload(HttpTest.WEBDAV_BASE_URL + "/" + folderName + "/" + fileName, resourceToUpload);
+ public void testUploadedPdfIsIndexed() throws Exception {
- final String fullTextSearchParameter = "Excepteur";
final String queryUrl = HttpTest.WEBDAV_BASE_URL + "/content.query.json?queryType=xpath&statement="
- + URLEncoder.encode("/jcr:root/" + folderName
- + "//*[jcr:contains(.,'" + fullTextSearchParameter+ "')]", "UTF-8");
+ + URLEncoder.encode("/jcr:root" + uploadPath
+ + "//*[jcr:contains(.,'" + expectedText + "')]", "UTF-8");
- new RetryLoop(new Condition() {
+ final Condition c = new Condition() {
public boolean isTrue() throws Exception {
String result = H.getContent(queryUrl, HttpTest.CONTENT_TYPE_JSON);
@@ -71,7 +84,7 @@ public class FullTextIndexingTest {
return false;
}
- String expectedPath = HttpTest.SERVLET_CONTEXT + "/" + folderName + "/" + fileName + "/jcr:content";
+ String expectedPath = HttpTest.SERVLET_CONTEXT + uploadPath + "/" + fileName + "/jcr:content";
for (int i = 0; i < results.length(); i++) {
JSONObject object = results.getJSONObject(i);
@@ -84,21 +97,32 @@ public class FullTextIndexingTest {
}
public String getDescription() {
- return "A document containing '" + fullTextSearchParameter + "' is found under /" + folderName;
+ return "A document containing '" + expectedText + "' is found under " + uploadPath;
}
- }, 10, 50);
+ };
+
+ assertFalse("Expecting search to return nothing before upload", c.isTrue());
+
+ String localPath = "/integration-test/indexing/" + fileName;
+ InputStream resourceToUpload = getClass().getResourceAsStream(localPath);
+ if (resourceToUpload == null)
+ throw new IllegalArgumentException("No resource to upload found at " + localPath);
+
+ H.getTestClient().mkdirs(HttpTest.WEBDAV_BASE_URL, uploadPath);
+ H.getTestClient().upload(HttpTest.WEBDAV_BASE_URL + uploadPath + "/" + fileName, resourceToUpload);
+
+ new RetryLoop(c, 10, 50);
}
@Before
public void setUp() throws Exception {
H.setUp();
- folderName = getClass().getSimpleName();
- H.getTestClient().delete(HttpTest.WEBDAV_BASE_URL + "/" + folderName);
+ H.getTestClient().delete(HttpTest.WEBDAV_BASE_URL + uploadPath);
}
@After
public void tearDown() throws Exception {
- H.getTestClient().delete(HttpTest.WEBDAV_BASE_URL + "/" + folderName);
+ H.getTestClient().delete(HttpTest.WEBDAV_BASE_URL + uploadPath);
H.tearDown();
}
}
\ No newline at end of file
Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/another.pdf
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/another.pdf?rev=1697947&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/another.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/french.pdf
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/french.pdf?rev=1697947&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/indexing/french.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream