+
+#else
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.ServerLocation'))
+ $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.URLColon')) |
+ $Encoder.bodyEscape($SERVERLOCATION) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.SecretApiKey')) |
+ private-***** |
+
+
+
|
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.SSLCertificateListColon')) |
+
+
+ #if($SERVERKEYSTORE_LIST.size() == 0)
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.NoCertificatesPresent')) |
+ #else
+ #foreach($certificate in $SERVERKEYSTORE_LIST)
+
+ |
+ $Encoder.bodyEscape($certificate.get('DESCRIPTION'))
+ |
+
+ #end
+ #end
+
+ |
+
+
+
|
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.EngineNameColon')) |
+ $Encoder.bodyEscape($ENGINENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.ContentAttributeNameColon')) |
+ $Encoder.bodyEscape($CONTENTATTRIBUTENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.CreatedDateAttributeNameColon')) |
+ $Encoder.bodyEscape($CREATEDDATEATTRIBUTENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.ModifiedDateAttributeNameColon')) |
+ $Encoder.bodyEscape($MODIFIEDDATEATTRIBUTENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.IndexingDateAttributeNameColon')) |
+ $Encoder.bodyEscape($INDEXINGDATEATTRIBUTENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.MimeTypeAttributeNameColon')) |
+ $Encoder.bodyEscape($MIMETYPEATTRIBUTENAME) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.ExtractorPatternColon')) |
+ $Encoder.bodyEscape($EXTRACTORPATTERN) |
+
+
+ | $Encoder.bodyEscape($ResourceBundle.getString('AppSearchConnector.ReplacementStringColon')) |
+ $Encoder.bodyEscape($REPLACEMENTSTRING) |
+
+
+
\ No newline at end of file
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/AppSearchIndexTest.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/AppSearchIndexTest.java
new file mode 100644
index 0000000000..8fae2728ab
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/AppSearchIndexTest.java
@@ -0,0 +1,35 @@
+package com.mcplusa.manifoldcf.agents.output.appsearch;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.http.client.HttpClient;
+import org.apache.manifoldcf.core.interfaces.ConfigParams;
+import org.junit.Test;
+
+public class AppSearchIndexTest {
+
+ @Test
+ public void testGetDocumentContent() throws FileNotFoundException {
+ ConfigParams params = new ConfigParams();
+ AppSearchConfig config = new AppSearchConfig(params);
+ HttpClient client = null;
+ AppSearchIndex index = new AppSearchIndex(client, config);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("document-content.txt").getFile());
+ String content = index.getDocumentContent(new FileInputStream(file));
+
+ Pattern pattern = Pattern.compile("\\n\\r\\t\\b\\f");
+ Matcher matcher = pattern.matcher(content);
+
+ if(matcher.find()) {
+ fail("Content should not contains escape sequences");
+ }
+ }
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/APISanityHSQLDBIT.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/APISanityHSQLDBIT.java
new file mode 100644
index 0000000000..0b8067a716
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/APISanityHSQLDBIT.java
@@ -0,0 +1,326 @@
+/* $Id: APISanityHSQLDBIT.java 1627345 2014-09-24 15:18:02Z kwright $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+import org.apache.manifoldcf.core.interfaces.Configuration;
+import org.apache.manifoldcf.core.interfaces.ConfigurationNode;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+import org.junit.Test;
+
+public class APISanityHSQLDBIT extends BaseITHSQLDB {
+
+ @Test
+ public void sanityCheck()
+ throws Exception {
+ try {
+
+ int i;
+
+ // Create a basic file system connection, and save it.
+ ConfigurationNode connectionObject;
+ ConfigurationNode child;
+ Configuration requestObject;
+ Configuration result;
+
+ connectionObject = new ConfigurationNode("repositoryconnection");
+
+ child = new ConfigurationNode("name");
+ child.setValue("Test Connection");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("class_name");
+ child.setValue("org.apache.manifoldcf.crawler.tests.TestingRepositoryConnector");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("description");
+ child.setValue("Test Connection");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("max_connections");
+ child.setValue("10");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("configuration");
+
+ //Testing Repository Connector parameters
+ // MHL
+ /*
+ ConfigurationNode cmisBindingNode = new ConfigurationNode("_PARAMETER_");
+ cmisBindingNode.setAttribute("name", CmisConfig.BINDING_PARAM);
+ cmisBindingNode.setValue(CmisConfig.BINDING_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisBindingNode);
+ */
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ requestObject = new Configuration();
+ requestObject.addChild(0, connectionObject);
+
+ result = performAPIPutOperationViaNodes("repositoryconnections/Test%20Connection", 201, requestObject);
+
+ i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ }
+ }
+
+ // Create a basic null output connection, and save it.
+ connectionObject = new ConfigurationNode("outputconnection");
+
+ child = new ConfigurationNode("name");
+ child.setValue("AppSearch");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("class_name");
+ child.setValue("com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("description");
+ child.setValue("AppSearch Connection");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("max_connections");
+ child.setValue("100");
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ child = new ConfigurationNode("configuration");
+
+ //AppSearch Output Connector parameters
+ //serverlocation
+ ConfigurationNode serverLocation = new ConfigurationNode("_PARAMETER_");
+ serverLocation.setAttribute("name", "serverlocation");
+ serverLocation.setValue("http://localhost:9200");
+ child.addChild(child.getChildCount(), serverLocation);
+
+ //indexname
+ ConfigurationNode engineName = new ConfigurationNode("_PARAMETER_");
+ engineName.setAttribute("name", "enginename");
+ engineName.setValue("index");
+ child.addChild(child.getChildCount(), engineName);
+
+ connectionObject.addChild(connectionObject.getChildCount(), child);
+
+ requestObject = new Configuration();
+ requestObject.addChild(0, connectionObject);
+
+ result = performAPIPutOperationViaNodes("outputconnections/AppSearch", 201, requestObject);
+
+ i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ }
+ }
+
+ // Create a job.
+ ConfigurationNode jobObject = new ConfigurationNode("job");
+
+ child = new ConfigurationNode("description");
+ child.setValue("Test Job");
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ child = new ConfigurationNode("repository_connection");
+ child.setValue("Test Connection");
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ // Revamped way of adding output connection
+ child = new ConfigurationNode("pipelinestage");
+ ConfigurationNode pipelineChild = new ConfigurationNode("stage_id");
+ pipelineChild.setValue("0");
+ child.addChild(child.getChildCount(), pipelineChild);
+ pipelineChild = new ConfigurationNode("stage_isoutput");
+ pipelineChild.setValue("true");
+ child.addChild(child.getChildCount(), pipelineChild);
+ pipelineChild = new ConfigurationNode("stage_connectionname");
+ pipelineChild.setValue("AppSearch");
+ child.addChild(child.getChildCount(), pipelineChild);
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ child = new ConfigurationNode("run_mode");
+ child.setValue("scan once");
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ child = new ConfigurationNode("start_mode");
+ child.setValue("manual");
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ child = new ConfigurationNode("hopcount_mode");
+ child.setValue("accurate");
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ child = new ConfigurationNode("document_specification");
+
+ jobObject.addChild(jobObject.getChildCount(), child);
+
+ requestObject = new Configuration();
+ requestObject.addChild(0, jobObject);
+
+ result = performAPIPostOperationViaNodes("jobs", 201, requestObject);
+
+ String jobIDString = null;
+ i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ } else if (resultNode.getType().equals("job_id")) {
+ jobIDString = resultNode.getValue();
+ }
+ }
+ if (jobIDString == null) {
+ throw new Exception("Missing job_id from return!");
+ }
+
+ // Now, start the job, and wait until it completes.
+ startJob(jobIDString);
+ waitJobInactive(jobIDString, 120000L);
+
+ // Check to be sure we actually processed the right number of documents.
+ // The test data area has 3 documents and one directory, and we have to count the root directory too.
+ long count;
+ count = getJobDocumentsProcessed(jobIDString);
+ if (count != 3) {
+ throw new ManifoldCFException("Wrong number of documents processed - expected 3, saw " + new Long(count).toString());
+ }
+
+ // Now, delete the job.
+ deleteJob(jobIDString);
+
+ waitJobDeleted(jobIDString, 120000L);
+
+ // Cleanup is automatic by the base class, so we can feel free to leave jobs and connections lying around.
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void startJob(String jobIDString)
+ throws Exception {
+ Configuration requestObject = new Configuration();
+
+ Configuration result = performAPIPutOperationViaNodes("start/" + jobIDString, 201, requestObject);
+ int i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ }
+ }
+ }
+
+ protected void deleteJob(String jobIDString)
+ throws Exception {
+ Configuration result = performAPIDeleteOperationViaNodes("jobs/" + jobIDString, 200);
+ int i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ }
+ }
+
+ }
+
+ protected String getJobStatus(String jobIDString)
+ throws Exception {
+ Configuration result = performAPIGetOperationViaNodes("jobstatuses/" + jobIDString, 200);
+ String status = null;
+ int i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ } else if (resultNode.getType().equals("jobstatus")) {
+ int j = 0;
+ while (j < resultNode.getChildCount()) {
+ ConfigurationNode childNode = resultNode.findChild(j++);
+ if (childNode.getType().equals("status")) {
+ status = childNode.getValue();
+ }
+ }
+ }
+ }
+ return status;
+ }
+
+ protected long getJobDocumentsProcessed(String jobIDString)
+ throws Exception {
+ Configuration result = performAPIGetOperationViaNodes("jobstatuses/" + jobIDString, 200);
+ String documentsProcessed = null;
+ int i = 0;
+ while (i < result.getChildCount()) {
+ ConfigurationNode resultNode = result.findChild(i++);
+ if (resultNode.getType().equals("error")) {
+ throw new Exception(resultNode.getValue());
+ } else if (resultNode.getType().equals("jobstatus")) {
+ int j = 0;
+ while (j < resultNode.getChildCount()) {
+ ConfigurationNode childNode = resultNode.findChild(j++);
+ if (childNode.getType().equals("documents_processed")) {
+ documentsProcessed = childNode.getValue();
+ }
+ }
+ }
+ }
+ if (documentsProcessed == null) {
+ throw new Exception("Expected a documents_processed field, didn't find it");
+ }
+ return new Long(documentsProcessed).longValue();
+ }
+
+ protected void waitJobInactive(String jobIDString, long maxTime)
+ throws Exception {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() < startTime + maxTime) {
+ String status = getJobStatus(jobIDString);
+ if (status == null) {
+ throw new Exception("No such job: '" + jobIDString + "'");
+ }
+ if (status.equals("not yet run")) {
+ throw new Exception("Job was never started.");
+ }
+ if (status.equals("done")) {
+ return;
+ }
+ if (status.equals("error")) {
+ throw new Exception("Job reports error.");
+ }
+ ManifoldCF.sleep(1000L);
+ continue;
+ }
+ throw new ManifoldCFException("ManifoldCF did not terminate in the allotted time of " + new Long(maxTime).toString() + " milliseconds");
+ }
+
+ protected void waitJobDeleted(String jobIDString, long maxTime)
+ throws Exception {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() < startTime + maxTime) {
+ String status = getJobStatus(jobIDString);
+ if (status == null) {
+ return;
+ }
+ ManifoldCF.sleep(1000L);
+ }
+ throw new ManifoldCFException("ManifoldCF did not delete in the allotted time of " + new Long(maxTime).toString() + " milliseconds");
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseHSQLDB.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseHSQLDB.java
new file mode 100644
index 0000000000..bcad0529fb
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseHSQLDB.java
@@ -0,0 +1,33 @@
+/* $Id: BaseHSQLDB.java 1302522 2012-03-19 16:06:44Z kwright $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+/**
+ * This is a testing base class that is responsible for setting up/tearing down the agents framework.
+ */
+public class BaseHSQLDB extends org.apache.manifoldcf.crawler.tests.ConnectorBaseHSQLDB {
+
+ protected String[] getOutputNames() {
+ return new String[]{"App Search"};
+ }
+
+ protected String[] getOutputClasses() {
+ return new String[]{"com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector"};
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseITHSQLDB.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseITHSQLDB.java
new file mode 100644
index 0000000000..94605391bd
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseITHSQLDB.java
@@ -0,0 +1,74 @@
+/* $Id: BaseITHSQLDB.java 1627345 2014-09-24 15:18:02Z kwright $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+import org.elasticsearch.node.Node;
+import org.junit.After;
+import org.junit.Before;
+
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+import static org.elasticsearch.node.NodeBuilder.*;
+
+/**
+ * Base integration tests class for Elastic Search tested against a CMIS repository
+ *
+ * @author Piergiorgio Lucidi
+ *
+ *
+ */
+public class BaseITHSQLDB extends org.apache.manifoldcf.crawler.tests.BaseITHSQLDB {
+
+ protected Node node = null;
+
+ protected String[] getConnectorNames() {
+ return new String[]{"CMIS"};
+ }
+
+ protected String[] getConnectorClasses() {
+ return new String[]{"org.apache.manifoldcf.crawler.tests.TestingRepositoryConnector"};
+ }
+
+ protected String[] getOutputNames() {
+ return new String[]{"AppSearch"};
+ }
+
+ protected String[] getOutputClasses() {
+ return new String[]{"com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector"};
+ }
+
+ @Before
+ public void setupElasticSearch()
+ throws Exception {
+ //Initialize ElasticSearch server
+ //the default port is 9200
+ System.out.println("ElasticSearch is starting...");
+ node = nodeBuilder().local(true).node();
+ System.out.println("ElasticSearch is started on port 9200");
+ }
+
+ @After
+ public void cleanUpElasticSearch() {
+ if (node != null) {
+ node.close();
+ }
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BasePostgresql.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BasePostgresql.java
new file mode 100644
index 0000000000..cbf5754a72
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BasePostgresql.java
@@ -0,0 +1,33 @@
+/* $Id: BasePostgresql.java 1302522 2012-03-19 16:06:44Z kwright $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+/**
+ * This is a testing base class that is responsible for setting up/tearing down the agents framework.
+ */
+public class BasePostgresql extends org.apache.manifoldcf.crawler.tests.ConnectorBasePostgresql {
+
+ protected String[] getOutputNames() {
+ return new String[]{"App Search"};
+ }
+
+ protected String[] getOutputClasses() {
+ return new String[]{"com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector"};
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseUIHSQLDB.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseUIHSQLDB.java
new file mode 100644
index 0000000000..88fbf8e499
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/BaseUIHSQLDB.java
@@ -0,0 +1,41 @@
+/* $Id: BaseUIHSQLDB.java 1627345 2014-09-24 15:18:02Z kwright $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+/**
+ * Tests that run the "agents daemon" should be derived from this
+ */
+public class BaseUIHSQLDB extends org.apache.manifoldcf.crawler.tests.ConnectorBaseUIHSQLDB {
+
+ protected String[] getConnectorNames() {
+ return new String[]{"Test Connector"};
+ }
+
+ protected String[] getConnectorClasses() {
+ return new String[]{"org.apache.manifoldcf.crawler.tests.TestingRepositoryConnector"};
+ }
+
+ protected String[] getOutputNames() {
+ return new String[]{"AppSearch"};
+ }
+
+ protected String[] getOutputClasses() {
+ return new String[]{"com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector"};
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/NavigationHSQLDBUI.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/NavigationHSQLDBUI.java
new file mode 100644
index 0000000000..147e3067d8
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/NavigationHSQLDBUI.java
@@ -0,0 +1,157 @@
+/* $Id: NavigationHSQLDBUI.java 1856509 2019-03-28 23:26:45Z kishore $ */
+/**
+ * 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 com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+import java.util.Locale;
+
+import org.apache.manifoldcf.core.tests.SeleniumTester;
+import org.junit.Test;
+
+/**
+ * Basic UI navigation tests
+ */
+public class NavigationHSQLDBUI extends BaseUIHSQLDB {
+
+ @Test
+ public void createConnectionsAndJob()
+ throws Exception {
+ testerInstance.start(SeleniumTester.BrowserType.CHROME, "en-US", "http://localhost:8346/mcf-crawler-ui/index.jsp");
+
+ //Login
+ testerInstance.waitForElementWithName("loginform");
+ testerInstance.setValue("userID", "admin");
+ testerInstance.setValue("password", "admin");
+ testerInstance.clickButton("Login");
+ testerInstance.verifyHeader("Welcome to Apache ManifoldCFâ„¢");
+ testerInstance.navigateTo("List output connections");
+ testerInstance.clickButton("Add a new output connection");
+
+ // Fill in a name
+ testerInstance.waitForElementWithName("connname");
+ testerInstance.setValue("connname", "MyOutputConnection");
+
+ //Goto to Type tab
+ testerInstance.clickTab("Type");
+
+ // Select a type
+ testerInstance.waitForElementWithName("classname");
+ testerInstance.selectValue("classname", "com.mcplusa.manifoldcf.agents.output.appsearch.AppSearchConnector");
+ testerInstance.clickButton("Continue");
+
+ // Visit the Throttling tab
+ testerInstance.clickTab("Throttling");
+
+ // Server tab
+ testerInstance.clickTab("Server");
+ testerInstance.setValue("serverlocation", "http://localhost:9200/");
+
+ // Parameters tab
+ testerInstance.clickTab("Parameters");
+ testerInstance.setValue("enginename", "index");
+
+ // Go back to the Name tab
+ testerInstance.clickTab("Name");
+
+ // Now save the connection.
+ testerInstance.clickButton("Save");
+ testerInstance.verifyThereIsNoError();
+
+ // Define a repository connection via the UI
+ testerInstance.navigateTo("List repository connections");
+ testerInstance.clickButton("Add new connection");
+
+ testerInstance.waitForElementWithName("connname");
+ testerInstance.setValue("connname", "MyRepositoryConnection");
+
+ // Select a type
+ testerInstance.clickTab("Type");
+ testerInstance.selectValue("classname", "org.apache.manifoldcf.crawler.tests.TestingRepositoryConnector");
+ testerInstance.clickButton("Continue");
+
+ // Visit the Throttling tab
+ testerInstance.clickTab("Throttling");
+
+ // Go back to the Name tab
+ testerInstance.clickTab("Name");
+
+ // Save
+ testerInstance.clickButton("Save");
+ testerInstance.verifyThereIsNoError();
+
+ // Create a job
+ testerInstance.navigateTo("List jobs");
+ //Add a job
+ testerInstance.clickButton("Add a new job");
+ testerInstance.waitForElementWithName("description");
+ //Fill in a name
+ testerInstance.setValue("description", "MyJob");
+ testerInstance.clickTab("Connection");
+
+ // Select the connections
+ testerInstance.selectValue("output_connectionname", "MyOutputConnection");
+ testerInstance.selectValue("output_precedent", "-1");
+ testerInstance.clickButton("Add output", true);
+ testerInstance.waitForElementWithName("connectionname");
+ testerInstance.selectValue("connectionname", "MyRepositoryConnection");
+
+ testerInstance.clickButton("Continue");
+
+ // Visit all the tabs. Scheduling tab first
+ testerInstance.clickTab("Scheduling");
+ testerInstance.selectValue("dayofweek", "0");
+ testerInstance.selectValue("hourofday", "1");
+ testerInstance.selectValue("minutesofhour", "30");
+ testerInstance.selectValue("monthofyear", "11");
+ testerInstance.selectValue("dayofmonth", "none");
+ testerInstance.setValue("duration", "120");
+ testerInstance.clickButton("Add Scheduled Time", true);
+ testerInstance.waitForElementWithName("editjob");
+
+ // MHL
+ // Save the job
+ testerInstance.clickButton("Save");
+ testerInstance.verifyThereIsNoError();
+
+ testerInstance.waitForPresenceById("job");
+ String jobID = testerInstance.getAttributeValueById("job", "jobid");
+
+ //Navigate to List Jobs
+ testerInstance.navigateTo("List jobs");
+ testerInstance.waitForElementWithName("listjobs");
+
+ //Delete the job
+ testerInstance.clickButtonByTitle("Delete job " + jobID);
+ testerInstance.acceptAlert();
+ testerInstance.verifyThereIsNoError();
+
+ //Wait for the job to go away
+ testerInstance.waitForJobDeleteEN(jobID, 120);
+
+ // Delete the repository connection
+ testerInstance.navigateTo("List repository connections");
+ testerInstance.clickButtonByTitle("Delete MyRepositoryConnection");
+ testerInstance.acceptAlert();
+
+ // Delete the output connection
+ testerInstance.navigateTo("List output connections");
+ testerInstance.clickButtonByTitle("Delete MyOutputConnection");
+ testerInstance.acceptAlert();
+
+ }
+
+}
diff --git a/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/UtilsTest.java b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/UtilsTest.java
new file mode 100644
index 0000000000..613b2e0ef3
--- /dev/null
+++ b/connectors/appsearch/connector/src/test/java/com/mcplusa/manifoldcf/agents/output/appsearch/tests/UtilsTest.java
@@ -0,0 +1,63 @@
+package com.mcplusa.manifoldcf.agents.output.appsearch.tests;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import com.mcplusa.manifoldcf.agents.output.appsearch.Utils;
+
+public class UtilsTest {
+
+ public UtilsTest() {
+ }
+
+ /**
+ * Test of cleanFieldName method, of class Utils.
+ */
+ @Test
+ public void testCleanFieldName() {
+ assertEquals("twitterog", Utils.cleanFieldName("twitter:og"));
+ assertEquals("twitterimage", Utils.cleanFieldName("Twitter:Image"));
+ assertEquals("twitter_description", Utils.cleanFieldName("twitter description"));
+ assertEquals("fieldwithnum123", Utils.cleanFieldName("field-with-num-123"));
+ assertEquals("fields", Utils.cleanFieldName("