You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by pi...@apache.org on 2012/02/15 20:14:37 UTC
svn commit: r1244653 - in /incubator/lcf/branches/CONNECTORS-288: ./ tests/
tests/elasticsearch/ tests/elasticsearch/src/ tests/elasticsearch/src/test/
tests/elasticsearch/src/test/java/ tests/elasticsearch/src/test/java/org/
tests/elasticsearch/src/te...
Author: piergiorgio
Date: Wed Feb 15 19:14:36 2012
New Revision: 1244653
URL: http://svn.apache.org/viewvc?rev=1244653&view=rev
Log:
added an initial version of integration tests for the ElasticSearch Output Connector (part of CONNECTORS-288)
Added:
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml (with props)
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml (with props)
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java (with props)
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java (with props)
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java (with props)
incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java (with props)
Modified:
incubator/lcf/branches/CONNECTORS-288/build.xml
incubator/lcf/branches/CONNECTORS-288/tests/pom.xml
Modified: incubator/lcf/branches/CONNECTORS-288/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/build.xml?rev=1244653&r1=1244652&r2=1244653&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-288/build.xml Wed Feb 15 19:14:36 2012
@@ -1507,6 +1507,15 @@
<isset property="elasticsearch.exists"/>
</condition>
</target>
+
+ <target name="calculate-elasticsearch-tests-condition" depends="calculate-elasticsearch-condition,calculate-cmis-condition">
+ <condition property="elasticsearch.include">
+ <and>
+ <isset property="elasticsearch.exists"/>
+ <isset property="cmis.include"/>
+ </and>
+ </condition>
+ </target>
<target name="calculate-elasticsearch-doc-condition" depends="doc-elasticsearch-connector">
<available file="connectors/elasticsearch/dist/doc" type="dir" property="elasticsearch-doc.exists"/>
@@ -1901,7 +1910,15 @@
<target name="run-cmis-loadtests-derby" depends="build-tests-framework,build-tests-cmis-connector,build-tests-nulloutput-connector,calculate-cmis-tests-condition" if="cmis-tests.include">
<ant dir="tests/cmis" target="run-load-derby"/>
</target>
-
+
+ <target name="run-elasticsearch-tests-derby" depends="build-tests-framework,build-tests-cmis-connector,build-tests-elasticsearch-connector,calculate-cmis-tests-condition,calculate-elasticsearch-tests-condition" if="elasticsearch-tests.include">
+ <ant dir="tests/elasticsearch" target="run-derby"/>
+ </target>
+
+ <target name="run-elasticsearch-UI-tests-derby" depends="build-tests-framework,build-tests-cmis-connector,build-tests-elasticsearch-connector,calculate-cmis-tests-condition,calculate-elasticsearch-tests-condition" if="elasticsearch-tests.include">
+ <ant dir="tests/elasticsearch" target="run-UI-derby"/>
+ </target>
+
<target name="run-alfresco-loadtests-derby" depends="build-tests-framework,build-tests-alfresco-connector,build-tests-nulloutput-connector,calculate-alfresco-tests-condition" if="alfresco-tests.include">
<ant dir="tests/alfresco" target="run-load-derby"/>
</target>
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml Wed Feb 15 19:14:36 2012
@@ -0,0 +1,58 @@
+<!--
+ 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.
+-->
+
+<project name="elasticsearch" default="all">
+
+ <import file="../ino-test-build.xml"/>
+
+ <target name="run-derby" depends="compile-tests">
+ <mkdir dir="test-derby-output"/>
+ <junit fork="true" maxmemory="128m" dir="test-derby-output" outputtoformatters="true" showoutput="true" haltonfailure="true">
+ <jvmarg value="-DcrawlerWarPath=../../../framework/build/war/mcf-crawler-ui.war"/>
+ <jvmarg value="-DauthorityserviceWarPath=../../../framework/build/war/mcf-authority-service.war"/>
+ <jvmarg value="-DapiWarPath=../../../framework/build/war/mcf-api-service.war"/>
+ <jvmarg value="-DopenCmisServerWarPath=../../../lib/chemistry-opencmis-server-inmemory.war"/>
+ <classpath>
+ <path refid="test-classpath"/>
+ <pathelement location="build/test/classes"/>
+ </classpath>
+ <formatter type="brief" usefile="false"/>
+
+ <test name="org.apache.manifoldcf.elasticsearch_tests.APISanityIT" todir="test-derby-output"/>
+
+ </junit>
+ </target>
+
+ <target name="run-UI-derby" depends="compile-tests">
+ <mkdir dir="test-derby-output"/>
+ <junit fork="true" maxmemory="128m" dir="test-derby-output" outputtoformatters="true" showoutput="true" haltonfailure="true">
+ <jvmarg value="-DcrawlerWarPath=../../../framework/build/war/mcf-crawler-ui.war"/>
+ <jvmarg value="-DauthorityserviceWarPath=../../../framework/build/war/mcf-authority-service.war"/>
+ <jvmarg value="-DapiWarPath=../../../framework/build/war/mcf-api-service.war"/>
+ <jvmarg value="-DopenCmisServerWarPath=../../../lib/chemistry-opencmis-server-inmemory.war"/>
+ <classpath>
+ <path refid="test-classpath"/>
+ <pathelement location="build/test/classes"/>
+ </classpath>
+ <formatter type="brief" usefile="false"/>
+
+ <test name="org.apache.manifoldcf.elasticsearch_tests.NavigationDerbyUI" todir="test-derby-output"/>
+
+ </junit>
+ </target>
+
+</project>
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/build.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml Wed Feb 15 19:14:36 2012
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.manifoldcf</groupId>
+ <artifactId>mcf-tests</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <repositories>
+ <repository>
+ <id>sonatype</id>
+ <url>https://oss.sonatype.org/content/repositories/releases</url>
+ </repository>
+ </repositories>
+
+ <developers>
+ <developer>
+ <name>Piergiorgio Lucidi</name>
+ <organization>Sourcesense</organization>
+ <organizationUrl>http://www.sourcesense.com</organizationUrl>
+ <url>http://www.open4dev.com</url>
+ </developer>
+ </developers>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <artifactId>mcf-elasticsearch-test</artifactId>
+ <name>ManifoldCF - Test - ElasticSearch</name>
+
+
+
+ <build>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-war</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/dependency</outputDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.chemistry.opencmis</groupId>
+ <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+ <version>0.6.0</version>
+ <type>war</type>
+ <overWrite>false</overWrite>
+ <destFileName>chemistry-opencmis-server-inmemory.war</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-api-service</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>false</overWrite>
+ <destFileName>mcf-api-service.war</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-authority-service</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>false</overWrite>
+ <destFileName>mcf-authority-service.war</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-crawler-ui</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>false</overWrite>
+ <destFileName>mcf-crawler-ui.war</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.10</version>
+ <configuration>
+ <skipTests>${skipITs}</skipTests>
+ <systemPropertyVariables>
+ <crawlerWarPath>../dependency/mcf-crawler-ui.war</crawlerWarPath>
+ <authorityserviceWarPath>../dependency/mcf-authority-service.war</authorityserviceWarPath>
+ <apiWarPath>../dependency/mcf-api-service.war</apiWarPath>
+ <openCmisServerWarPath>../dependency/chemistry-opencmis-server-inmemory.war</openCmisServerWarPath>
+ </systemPropertyVariables>
+ <excludes>
+ <exclude>**/*Postgresql*.java</exclude>
+ <exclude>**/*MySQL*.java</exclude>
+ </excludes>
+ <forkMode>always</forkMode>
+ <workingDirectory>target/test-output</workingDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <!-- Internal dependencies -->
+ <dependency>
+ <groupId>org.apache.chemistry.opencmis</groupId>
+ <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+ <version>0.6.0</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-api-service</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-authority-service</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-crawler-ui</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-jettyrunner</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-agents</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-pull-agent</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-cmis-connector</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-elasticsearch-connector</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-nulloutput-connector</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-api-2.1</artifactId>
+ <version>6.1.14</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.1-glassfish</artifactId>
+ <version>2.1.v20091210</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-agents</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mcf-pull-agent</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>${derby.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${mysql.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient-mcf</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.5</version>
+ </dependency>
+
+ <!-- Apache Chemistry dependencies -->
+ <dependency>
+ <groupId>org.apache.chemistry.opencmis</groupId>
+ <artifactId>chemistry-opencmis-client-impl</artifactId>
+ <version>0.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+
+ <!-- Elastic Search dependencies -->
+ <dependency>
+ <groupId>org.elasticsearch</groupId>
+ <artifactId>elasticsearch</artifactId>
+ <version>0.18.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ <version>3.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers</artifactId>
+ <version>3.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-snowball</artifactId>
+ <version>3.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-fast-vector-highlighter</artifactId>
+ <version>3.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-highlighter</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-queries</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java Wed Feb 15 19:14:36 2012
@@ -0,0 +1,594 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.elasticsearch_tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.QueryResult;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.api.SessionFactory;
+import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.commons.spi.ObjectService;
+import org.apache.commons.lang.StringUtils;
+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.connectors.cmis.CmisConfig;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Piergiorgio Lucidi
+ */
+public class APISanityIT extends BaseDerby
+{
+ private static final String REPLACER = "?";
+ private static final String CMIS_TEST_QUERY_CHANGE_DOC = "SELECT * FROM cmis:document WHERE cmis:name='"+REPLACER+"'";
+ private static final String CMIS_TEST_QUERY = "SELECT * FROM cmis:folder WHERE cmis:name='testdata'";
+
+ private Session cmisClientSession = null;
+
+ private Session getCmisClientSession(){
+ // default factory implementation
+ SessionFactory factory = SessionFactoryImpl.newInstance();
+ Map<String, String> parameters = new HashMap<String, String>();
+
+ // user credentials
+ parameters.put(SessionParameter.USER, CmisConfig.USERNAME_DEFAULT_VALUE);
+ parameters.put(SessionParameter.PASSWORD, CmisConfig.PASSWORD_DEFAULT_VALUE);
+
+ // connection settings
+ String endpoint =
+ CmisConfig.PROTOCOL_DEFAULT_VALUE + "://" +
+ CmisConfig.SERVER_DEFAULT_VALUE + ":" +
+ CmisConfig.PORT_DEFAULT_VALUE +
+ CmisConfig.PATH_DEFAULT_VALUE;
+
+ parameters.put(SessionParameter.ATOMPUB_URL, endpoint);
+ parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
+
+ // create session
+ return factory.getRepositories(parameters).get(0).createSession();
+ }
+
+ public Folder getTestFolder(Session session){
+ Folder testFolder = null;
+ ItemIterable<QueryResult> results = session.query(CMIS_TEST_QUERY, false);
+ for (QueryResult result : results) {
+ String folderId = result.getPropertyById("cmis:objectId").getFirstValue().toString();
+ testFolder = (Folder)session.getObject(folderId);
+ }
+ return testFolder;
+ }
+
+ public void createNewDocument(Folder folder, String name) throws IOException{
+ // properties
+ // (minimal set: name and object type id)
+ Map<String, Object> contentProperties = new HashMap<String, Object>();
+ contentProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
+ contentProperties.put(PropertyIds.NAME, name);
+
+ // content
+ String contentString = "CMIS Testdata "+name;
+ byte[] content = contentString.getBytes();
+ InputStream stream = new ByteArrayInputStream(content);
+ ContentStream contentStream = new ContentStreamImpl(name, new BigInteger(content), "text/plain", stream);
+
+ // create a major version
+ folder.createDocument(contentProperties, contentStream, null);
+ stream.close();
+ }
+
+ /**
+ * change the document content with the new one provided as an argument
+ * @param session
+ * @param name
+ * @param newContent
+ */
+ public void changeDocument(Session session, String name, String newContent){
+ String cmisQuery = StringUtils.replace(CMIS_TEST_QUERY_CHANGE_DOC, REPLACER, name);
+ ItemIterable<QueryResult> results = session.query(cmisQuery, false);
+ String objectId = StringUtils.EMPTY;
+ for (QueryResult result : results) {
+ objectId = result.getPropertyById("cmis:objectId").getFirstValue().toString();
+ }
+ String repositoryId = session.getRepositoryInfo().getId();
+ Holder<String> objectIdHolder = new Holder<String>(objectId);
+ Boolean overwriteFlag = true;
+ byte[] newContentByteArray = newContent.getBytes();
+ InputStream stream = new ByteArrayInputStream(newContentByteArray);
+ ContentStream contentStream = new ContentStreamImpl(name, new BigInteger(newContentByteArray), "text/plain", stream);
+ ObjectService objectService = session.getBinding().getObjectService();
+ objectService.setContentStream(repositoryId, objectIdHolder, overwriteFlag, null, contentStream, null);
+ }
+
+ public void removeDocument(Session session, String name){
+ String cmisQuery = StringUtils.replace(CMIS_TEST_QUERY_CHANGE_DOC, REPLACER, name);
+ ItemIterable<QueryResult> results = session.query(cmisQuery, false);
+ String objectId = StringUtils.EMPTY;
+ for (QueryResult result : results) {
+ objectId = result.getPropertyById("cmis:objectId").getFirstValue().toString();
+ }
+ String repositoryId = session.getRepositoryInfo().getId();
+ ObjectService objectService = session.getBinding().getObjectService();
+ objectService.deleteObject(repositoryId, objectId, true, null);
+ }
+
+ @Before
+ public void createTestArea()
+ throws Exception
+ {
+ try
+ {
+ cmisClientSession = getCmisClientSession();
+
+ //creating a new folder
+ Folder root = cmisClientSession.getRootFolder();
+
+ ItemIterable<QueryResult> results = cmisClientSession.query(CMIS_TEST_QUERY, false);
+ for (QueryResult result : results) {
+ String repositoryId = cmisClientSession.getRepositoryInfo().getId();
+ String folderId = result.getPropertyById("cmis:objectId").getFirstValue().toString();
+ cmisClientSession.getBinding().getObjectService().deleteTree(repositoryId, folderId, true, null, false, null);
+ }
+
+ Map<String, Object> folderProperties = new HashMap<String, Object>();
+ folderProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
+ folderProperties.put(PropertyIds.NAME, "testdata");
+
+ Folder newFolder = root.createFolder(folderProperties);
+
+ String name = "testdata1.txt";
+ createNewDocument(newFolder, name);
+
+ name = "testdata2.txt";
+ createNewDocument(newFolder,name);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @After
+ public void removeTestArea()
+ throws Exception
+ {
+ // we don't need to remove anything
+ }
+
+ @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("CMIS Connection");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("class_name");
+ child.setValue("org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("description");
+ child.setValue("CMIS Connection");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("max_connections");
+ child.setValue("10");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("configuration");
+
+ //CMIS Repository Connector parameters
+
+ //binding
+ ConfigurationNode cmisBindingNode = new ConfigurationNode("_PARAMETER_");
+ cmisBindingNode.setAttribute("name", CmisConfig.BINDING_PARAM);
+ cmisBindingNode.setValue(CmisConfig.BINDING_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisBindingNode);
+
+ //username
+ ConfigurationNode cmisUsernameNode = new ConfigurationNode("_PARAMETER_");
+ cmisUsernameNode.setAttribute("name", CmisConfig.USERNAME_PARAM);
+ cmisUsernameNode.setValue(CmisConfig.USERNAME_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisUsernameNode);
+
+ //password
+ ConfigurationNode cmisPasswordNode = new ConfigurationNode("_PARAMETER_");
+ cmisPasswordNode.setAttribute("name", CmisConfig.PASSWORD_PARAM);
+ cmisPasswordNode.setValue(CmisConfig.PASSWORD_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisPasswordNode);
+
+ //protocol
+ ConfigurationNode cmisProtocolNode = new ConfigurationNode("_PARAMETER_");
+ cmisProtocolNode.setAttribute("name", CmisConfig.PROTOCOL_PARAM);
+ cmisProtocolNode.setValue(CmisConfig.PROTOCOL_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisProtocolNode);
+
+ //server
+ ConfigurationNode cmisServerNode = new ConfigurationNode("_PARAMETER_");
+ cmisServerNode.setAttribute("name", CmisConfig.SERVER_PARAM);
+ cmisServerNode.setValue(CmisConfig.SERVER_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisServerNode);
+
+ //port
+ ConfigurationNode cmisPortNode = new ConfigurationNode("_PARAMETER_");
+ cmisPortNode.setAttribute("name", CmisConfig.PORT_PARAM);
+ cmisPortNode.setValue(CmisConfig.PORT_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisPortNode);
+
+ //path
+ ConfigurationNode cmisPathNode = new ConfigurationNode("_PARAMETER_");
+ cmisPathNode.setAttribute("name", CmisConfig.PATH_PARAM);
+ cmisPathNode.setValue(CmisConfig.PATH_DEFAULT_VALUE);
+ child.addChild(child.getChildCount(), cmisPathNode);
+
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ requestObject = new Configuration();
+ requestObject.addChild(0,connectionObject);
+
+ result = performAPIPutOperationViaNodes("repositoryconnections/CMIS%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("ElasticSearch");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("class_name");
+ child.setValue("org.apache.manifoldcf.agents.output.elasticSearch.ElasticSearchConnector");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("description");
+ child.setValue("ElasticSearch Connection");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("max_connections");
+ child.setValue("100");
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ child = new ConfigurationNode("configuration");
+
+ //ElasticSearch 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 indexName = new ConfigurationNode("_PARAMETER_");
+ indexName.setAttribute("name", "indexname");
+ indexName.setValue("index");
+ child.addChild(child.getChildCount(), indexName);
+
+ //indextype
+ ConfigurationNode indexType = new ConfigurationNode("_PARAMETER_");
+ indexType.setAttribute("name", "indextype");
+ indexType.setValue("generictype");
+ child.addChild(child.getChildCount(), indexType);
+
+ //username
+ ConfigurationNode username = new ConfigurationNode("_PARAMETER_");
+ username.setAttribute("name", "username");
+ username.setValue("");
+ child.addChild(child.getChildCount(), username);
+
+ //apikey
+ ConfigurationNode apikey = new ConfigurationNode("_PARAMETER_");
+ apikey.setAttribute("name", "apikey");
+ apikey.setValue("");
+ child.addChild(child.getChildCount(), apikey);
+
+ connectionObject.addChild(connectionObject.getChildCount(),child);
+
+ requestObject = new Configuration();
+ requestObject.addChild(0,connectionObject);
+
+ result = performAPIPutOperationViaNodes("outputconnections/ElasticSearch%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 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("CMIS Connection");
+ jobObject.addChild(jobObject.getChildCount(),child);
+
+ child = new ConfigurationNode("output_connection");
+ child.setValue("ElasticSearch Connection");
+ 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");
+
+
+ //Job configuration
+ ConfigurationNode sn = new ConfigurationNode("startpoint");
+ sn.setAttribute("cmisQuery",CMIS_TEST_QUERY);
+
+ child.addChild(child.getChildCount(),sn);
+ 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());
+
+ // Add a file and recrawl
+ Folder testFolder = getTestFolder(cmisClientSession);
+ createNewDocument(testFolder, "testdata3.txt");
+ createNewDocument(testFolder, "testdata4.txt");
+
+ // Now, start the job, and wait until it completes.
+ startJob(jobIDString);
+ waitJobInactive(jobIDString, 120000L);
+
+ // The test data area has 4 documents and one directory, and we have to count the root directory too.
+ count = getJobDocumentsProcessed(jobIDString);
+ if (count != 5)
+ throw new ManifoldCFException("Wrong number of documents processed after add - expected 5, saw "+new Long(count).toString());
+
+ // Change a document, and recrawl
+ changeDocument(cmisClientSession,"testdata1.txt","MODIFIED - CMIS Testdata - MODIFIED");
+
+ // Now, start the job, and wait until it completes.
+ startJob(jobIDString);
+ waitJobInactive(jobIDString, 120000L);
+
+ // The test data area has 4 documents and one directory, and we have to count the root directory too.
+ count = getJobDocumentsProcessed(jobIDString);
+ if (count != 5)
+ throw new ManifoldCFException("Wrong number of documents processed after change - expected 5, saw "+new Long(count).toString());
+
+ // We also need to make sure the new document was indexed. Have to think about how to do this though.
+ // MHL
+
+ // Delete a file, and recrawl
+ removeDocument(cmisClientSession, "testdata2.txt");
+
+ // 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.
+ count = getJobDocumentsProcessed(jobIDString);
+ if (count != 4)
+ throw new ManifoldCFException("Wrong number of documents processed after delete - expected 5, 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");
+ }
+
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/APISanityIT.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java Wed Feb 15 19:14:36 2012
@@ -0,0 +1,106 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.elasticsearch_tests;
+
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+import org.elasticsearch.node.Node;
+import org.junit.After;
+import org.junit.Before;
+import org.mortbay.jetty.Server;
+import org.mortbay.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 BaseDerby extends org.apache.manifoldcf.crawler.tests.BaseITDerby
+{
+ protected Server cmisServer = null;
+ protected Node node = null;
+
+ protected String[] getConnectorNames()
+ {
+ return new String[]{"CMIS"};
+ }
+
+ protected String[] getConnectorClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector"};
+ }
+
+ protected String[] getOutputNames()
+ {
+ return new String[]{"ElasticSearch"};
+ }
+
+ protected String[] getOutputClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.agents.output.elasticsearch.ElasticSearchConnector"};
+ }
+
+ // Setup/teardown
+
+ @Before
+ public void setUpCMIS()
+ throws Exception
+ {
+ cmisServer = new Server(9090);
+ cmisServer.setStopAtShutdown(true);
+
+ String openCmisServerWarPath = "../../lib/chemistry-opencmis-server-inmemory.war";
+
+ if (System.getProperty("openCmisServerWarPath") != null)
+ openCmisServerWarPath = System.getProperty("openCmisServerWarPath");
+
+ //Initialize OpenCMIS Server bindings
+ WebAppContext openCmisServerApi = new WebAppContext(openCmisServerWarPath,"/chemistry-opencmis-server-inmemory");
+ openCmisServerApi.setParentLoaderPriority(false);
+ cmisServer.addHandler(openCmisServerApi);
+
+ cmisServer.start();
+ boolean entered = false;
+
+ while(cmisServer.isStarted()
+ && openCmisServerApi.isStarted()
+ && !entered){
+ entered = true;
+ ManifoldCF.sleep(5000);
+ }
+ }
+
+ @Before
+ public void setUpElasticSearch(){
+ //port 9200 by default
+ node = nodeBuilder().local(true).node();
+ }
+
+ @After
+ public void cleanUpElasticSearch(){
+ node.close();
+ }
+
+ @After
+ public void cleanUpCMIS()
+ throws Exception
+ {
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseDerby.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java Wed Feb 15 19:14:36 2012
@@ -0,0 +1,54 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.elasticsearch_tests;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseUIDerby extends org.apache.manifoldcf.crawler.tests.ConnectorBaseUIDerby
+{
+ protected String[] getConnectorNames()
+ {
+ return new String[]{"CMIS Connector"};
+ }
+
+ protected String[] getConnectorClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector"};
+ }
+
+ protected String[] getOutputNames()
+ {
+ return new String[]{"ElasticSearch"};
+ }
+
+ protected String[] getOutputClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.agents.output.elasticsearch.ElasticSearchConnector"};
+ }
+
+ protected String[] getAuthorityClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.crawler.connectors.cmis.CmisAuthorityConnector"};
+ }
+
+ protected String[] getAuthorityNames()
+ {
+ return new String[]{"CMIS authority"};
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/BaseUIDerby.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java?rev=1244653&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java (added)
+++ incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java Wed Feb 15 19:14:36 2012
@@ -0,0 +1,273 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.elasticsearch_tests;
+
+import java.util.Locale;
+
+import org.apache.manifoldcf.core.tests.HTMLTester;
+import org.junit.Test;
+
+/** Basic UI navigation tests */
+public class NavigationDerbyUI extends BaseUIDerby
+{
+
+ @Test
+ public void createConnectionsAndJob()
+ throws Exception
+ {
+ testerInstance.newTest(Locale.US);
+
+ HTMLTester.Window window;
+ HTMLTester.Link link;
+ HTMLTester.Form form;
+ HTMLTester.Textarea textarea;
+ HTMLTester.Selectbox selectbox;
+ HTMLTester.Button button;
+ HTMLTester.Radiobutton radiobutton;
+ HTMLTester.Loop loop;
+
+ window = testerInstance.openMainWindow("http://localhost:8346/mcf-crawler-ui/index.jsp");
+
+ // Define an output connection via the UI
+ link = window.findLink(testerInstance.createStringDescription("List output connections"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Add an output connection"));
+ link.click();
+ // Fill in a name
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("connname"));
+ textarea.setValue(testerInstance.createStringDescription("MyOutputConnection"));
+ link = window.findLink(testerInstance.createStringDescription("Type tab"));
+ link.click();
+ // Select a type
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("classname"));
+ selectbox.selectValue(testerInstance.createStringDescription("org.apache.manifoldcf.agents.output.elasticsearch.ElasticSearchConnector"));
+ button = window.findButton(testerInstance.createStringDescription("Continue to next page"));
+ button.click();
+ // Visit the Throttling tab
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Throttling tab"));
+ link.click();
+ // Go back to the Name tab
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Name tab"));
+ link.click();
+ // Parameters tab
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Parameters tab"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("serverlocation"));
+ textarea.setValue(testerInstance.createStringDescription("http://localhost:9200/"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("indexname"));
+ textarea.setValue(testerInstance.createStringDescription("index"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("indextype"));
+ textarea.setValue(testerInstance.createStringDescription("generictype"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("username"));
+ textarea.setValue(testerInstance.createStringDescription("foo"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("apikey"));
+ textarea.setValue(testerInstance.createStringDescription("bar"));
+
+ // Go back to the Name tab
+ link = window.findLink(testerInstance.createStringDescription("Name tab"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ // Now save the connection.
+ button = window.findButton(testerInstance.createStringDescription("Save this connection"));
+ button.click();
+ // Now save the connection.
+ window = testerInstance.findWindow(null);
+ button = window.findButton(testerInstance.createStringDescription("Save this output connection"));
+ button.click();
+
+ // Define a repository connection via the UI
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List repository connections"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Add a connection"));
+ link.click();
+ // Fill in a name
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("connname"));
+ textarea.setValue(testerInstance.createStringDescription("MyRepositoryConnection"));
+ link = window.findLink(testerInstance.createStringDescription("Type tab"));
+ link.click();
+ // Select a type
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("classname"));
+ selectbox.selectValue(testerInstance.createStringDescription("org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector"));
+ button = window.findButton(testerInstance.createStringDescription("Continue to next page"));
+ button.click();
+ // Visit the Throttling tab
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Throttling tab"));
+ link.click();
+ // Server tab
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Server tab"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("username"));
+ textarea.setValue(testerInstance.createStringDescription("foo"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("password"));
+ textarea.setValue(testerInstance.createStringDescription("bar"));
+ // Go back to the Name tab
+ link = window.findLink(testerInstance.createStringDescription("Name tab"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ // Now save the connection.
+ button = window.findButton(testerInstance.createStringDescription("Save this connection"));
+ button.click();
+
+ // Define an authority connection via the UI
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List authorities"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Add a new connection"));
+ link.click();
+ // Fill in a name
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("connname"));
+ textarea.setValue(testerInstance.createStringDescription("MyAuthorityConnection"));
+ link = window.findLink(testerInstance.createStringDescription("Type tab"));
+ link.click();
+ // Select a type
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editconnection"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("classname"));
+ selectbox.selectValue(testerInstance.createStringDescription("org.apache.manifoldcf.crawler.connectors.cmis.CmisAuthorityConnector"));
+ button = window.findButton(testerInstance.createStringDescription("Continue to next page"));
+ button.click();
+ window = testerInstance.findWindow(null);
+ //MHL
+ // Go back to the Name tab
+ link = window.findLink(testerInstance.createStringDescription("Name tab"));
+ link.click();
+ // Now save the connection.
+ window = testerInstance.findWindow(null);
+ button = window.findButton(testerInstance.createStringDescription("Save this authority connection"));
+ button.click();
+
+ // Create a job
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List jobs"));
+ link.click();
+ // Add a job
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Add a job"));
+ link.click();
+ // Fill in a name
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editjob"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("description"));
+ textarea.setValue(testerInstance.createStringDescription("MyJob"));
+ link = window.findLink(testerInstance.createStringDescription("Connection tab"));
+ link.click();
+ // Select the connections
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editjob"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("outputname"));
+ selectbox.selectValue(testerInstance.createStringDescription("MyOutputConnection"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("connectionname"));
+ selectbox.selectValue(testerInstance.createStringDescription("MyRepositoryConnection"));
+ button = window.findButton(testerInstance.createStringDescription("Continue to next screen"));
+ button.click();
+ // Visit all the tabs. Scheduling tab first
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Scheduling tab"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ form = window.findForm(testerInstance.createStringDescription("editjob"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("dayofweek"));
+ selectbox.selectValue(testerInstance.createStringDescription("0"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("hourofday"));
+ selectbox.selectValue(testerInstance.createStringDescription("1"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("minutesofhour"));
+ selectbox.selectValue(testerInstance.createStringDescription("30"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("monthofyear"));
+ selectbox.selectValue(testerInstance.createStringDescription("11"));
+ selectbox = form.findSelectbox(testerInstance.createStringDescription("dayofmonth"));
+ selectbox.selectValue(testerInstance.createStringDescription("none"));
+ textarea = form.findTextarea(testerInstance.createStringDescription("duration"));
+ textarea.setValue(testerInstance.createStringDescription("120"));
+ button = window.findButton(testerInstance.createStringDescription("Add new schedule record"));
+ button.click();
+ window = testerInstance.findWindow(null);
+ // MHL
+ // Save the job
+ button = window.findButton(testerInstance.createStringDescription("Save this job"));
+ button.click();
+
+ // Delete the job
+ window = testerInstance.findWindow(null);
+ HTMLTester.StringDescription jobID = window.findMatch(testerInstance.createStringDescription("<!--jobid=(.*?)-->"),0);
+ testerInstance.printValue(jobID);
+ link = window.findLink(testerInstance.createStringDescription("Delete this job"));
+ link.click();
+
+ // Wait for the job to go away
+ loop = testerInstance.beginLoop(120);
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Manage jobs"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ HTMLTester.StringDescription isJobNotPresent = window.isNotPresent(jobID);
+ testerInstance.printValue(isJobNotPresent);
+ loop.breakWhenTrue(isJobNotPresent);
+ loop.endLoop();
+
+ // Delete the authority connection
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List authorities"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Delete MyAuthorityConnection"));
+ link.click();
+
+ // Delete the repository connection
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List repository connections"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Delete MyRepositoryConnection"));
+ link.click();
+
+ // Delete the output connection
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("List output connections"));
+ link.click();
+ window = testerInstance.findWindow(null);
+ link = window.findLink(testerInstance.createStringDescription("Delete MyOutputConnection"));
+ link.click();
+
+ testerInstance.executeTest();
+ }
+
+}
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/lcf/branches/CONNECTORS-288/tests/elasticsearch/src/test/java/org/apache/manifoldcf/elasticsearch_tests/NavigationDerbyUI.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/lcf/branches/CONNECTORS-288/tests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/tests/pom.xml?rev=1244653&r1=1244652&r2=1244653&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/tests/pom.xml (original)
+++ incubator/lcf/branches/CONNECTORS-288/tests/pom.xml Wed Feb 15 19:14:36 2012
@@ -28,6 +28,7 @@
<name>ManifoldCF - Tests</name>
<packaging>pom</packaging>
<modules>
+ <module>elasticsearch</module>
<module>alfresco</module>
<module>wiki</module>
<module>cmis</module>