You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by ma...@apache.org on 2014/10/19 23:34:03 UTC

svn commit: r1633001 - in /manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript: ./ connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/

Author: maoo
Date: Sun Oct 19 21:34:03 2014
New Revision: 1633001

URL: http://svn.apache.org/r1633001
Log:
added base IT classes and Maven failsafe logic to run tests. Still needs core test logic to be implemented

Added:
    manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/APISanityHSQLDBIT.java
    manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/BaseITHSQLDB.java
Modified:
    manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/pom.xml

Added: manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/APISanityHSQLDBIT.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/APISanityHSQLDBIT.java?rev=1633001&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/APISanityHSQLDBIT.java (added)
+++ manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/APISanityHSQLDBIT.java Sun Oct 19 21:34:03 2014
@@ -0,0 +1,319 @@
+/* $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.crawler.connectors.alfrescowebscript.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.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class APISanityHSQLDBIT extends BaseITHSQLDB
+{
+  
+  private static final String REPLACER = "?";
+  private static final String ALFRESCO_TEST_QUERY = "PATH:\"/app:company_home/cm:testdata\"";
+  
+  private static final String ALFRESCO_USERNAME = "admin"; 
+  private static final String ALFRESCO_PASSWORD = "admin";
+  private static final String ALFRESCO_PROTOCOL = "http";
+  private static final String ALFRESCO_HOST = "localhost";
+  private static final String ALFRESCO_PORT = "9090";
+  private static final String ALFRESCO_CONTEXT = "/alfresco";
+  private static final int SOCKET_TIMEOUT = 120000;
+  private static final String ALFRESCO_ENDPOINT_TEST_SERVER = 
+      ALFRESCO_PROTOCOL+"://"+ALFRESCO_HOST+":"+ALFRESCO_PORT+ALFRESCO_CONTEXT;
+
+  @Before
+  public void createTestArea()
+    throws Exception
+  {
+    removeTestArea();
+    
+    try
+    {
+      //@TODO - Add cmis client logic to push some documents into Alfresco
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+  
+  @After
+  public void removeTestArea()
+    throws Exception
+  {
+  }
+  
+  @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("Alfresco Connector");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+      
+      child = new ConfigurationNode("class_name");
+      child.setValue("org.apache.manifoldcf.crawler.connectors.alfrescowebscript.AlfrescoConnector");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+      
+      child = new ConfigurationNode("description");
+      child.setValue("An Alfresco Repository Connector");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+
+      child = new ConfigurationNode("max_connections");
+      child.setValue("10");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+      
+      child = new ConfigurationNode("configuration");
+      
+      //Alfresco Repository Connector parameters
+      
+      //username
+      ConfigurationNode alfrescoUsernameNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoUsernameNode.setAttribute("name", ALFRESCO_USERNAME);
+      alfrescoUsernameNode.setValue(ALFRESCO_USERNAME);
+      child.addChild(child.getChildCount(), alfrescoUsernameNode);
+      
+      //password
+      ConfigurationNode alfrescoPasswordNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoPasswordNode.setAttribute("name", ALFRESCO_PASSWORD);
+      alfrescoPasswordNode.setValue(ALFRESCO_PASSWORD);
+      child.addChild(child.getChildCount(), alfrescoPasswordNode);
+      
+      //protocol
+      ConfigurationNode alfrescoProtocolNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoProtocolNode.setAttribute("name", ALFRESCO_PROTOCOL);
+      alfrescoProtocolNode.setValue(ALFRESCO_PROTOCOL);
+      child.addChild(child.getChildCount(), alfrescoProtocolNode);
+      
+      //server
+      ConfigurationNode alfrescoServerNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoServerNode.setAttribute("name", ALFRESCO_HOST);
+      alfrescoServerNode.setValue(ALFRESCO_HOST);
+      child.addChild(child.getChildCount(), alfrescoServerNode);
+      
+      //port
+      ConfigurationNode alfrescoPortNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoPortNode.setAttribute("name", ALFRESCO_PORT);
+      alfrescoPortNode.setValue(ALFRESCO_PORT);
+      child.addChild(child.getChildCount(), alfrescoPortNode);
+      
+      //path
+      ConfigurationNode alfrescoPathNode = new ConfigurationNode("_PARAMETER_");
+      alfrescoPathNode.setAttribute("name", ALFRESCO_CONTEXT);
+      alfrescoPathNode.setValue(ALFRESCO_CONTEXT);
+      child.addChild(child.getChildCount(), alfrescoPathNode);
+      
+      //socketTimeout
+      ConfigurationNode socketTimeoutNode = new ConfigurationNode("_PARAMETER_");
+      socketTimeoutNode.setAttribute("name", "60000");
+      socketTimeoutNode.setValue(String.valueOf(SOCKET_TIMEOUT));
+      child.addChild(child.getChildCount(), socketTimeoutNode);
+      
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+
+      requestObject = new Configuration();
+      requestObject.addChild(0,connectionObject);
+      
+      result = performAPIPutOperationViaNodes("repositoryconnections/Alfresco%20Connector",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("Null Connection");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+      
+      child = new ConfigurationNode("class_name");
+      child.setValue("org.apache.manifoldcf.agents.tests.TestingOutputConnector");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+      
+      child = new ConfigurationNode("description");
+      child.setValue("Null Connection");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+
+      child = new ConfigurationNode("max_connections");
+      child.setValue("100");
+      connectionObject.addChild(connectionObject.getChildCount(),child);
+
+      requestObject = new Configuration();
+      requestObject.addChild(0,connectionObject);
+      
+      result = performAPIPutOperationViaNodes("outputconnections/Null%20Connection",201,requestObject);
+      
+      i = 0;
+      while (i < result.getChildCount())
+      {
+        ConfigurationNode resultNode = result.findChild(i++);
+        if (resultNode.getType().equals("error"))
+          throw new Exception(resultNode.getValue());
+      }
+
+      //@TODO - Test Job execution
+    }
+    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");
+  }
+}

Added: manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/BaseITHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/BaseITHSQLDB.java?rev=1633001&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/BaseITHSQLDB.java (added)
+++ manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/tests/BaseITHSQLDB.java Sun Oct 19 21:34:03 2014
@@ -0,0 +1,78 @@
+/* $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.crawler.connectors.alfrescowebscript.tests;
+
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+import org.junit.Before;
+
+public class BaseITHSQLDB extends org.apache.manifoldcf.crawler.tests.BaseITHSQLDB
+{
+  protected Server alfrescoServer = null;
+
+  
+  protected String[] getConnectorNames()
+  {
+    return new String[]{"Alfresco"};
+  }
+  
+  protected String[] getConnectorClasses()
+  {
+    return new String[]{"org.apache.manifoldcf.crawler.connectors.alfrescowebscript.AlfrescoConnector"};
+  }
+  
+  protected String[] getOutputNames()
+  {
+    return new String[]{"Null Output"};
+  }
+  
+  protected String[] getOutputClasses()
+  {
+    return new String[]{"org.apache.manifoldcf.agents.tests.TestingOutputConnector"};
+  }
+
+  @Before
+  public void setUpAlfresco()
+    throws Exception
+  {
+    alfrescoServer = new Server(9090);
+    alfrescoServer.setStopAtShutdown(true);
+
+    String alfrescoServerWarPath = "../../connectors/alfresco-webscript/test-materials-proprietary/alfresco.war";
+
+    if (System.getProperty("alfrescoServerWarPath") != null)
+      alfrescoServerWarPath = System.getProperty("alfrescoServerWarPath");
+    
+    ContextHandlerCollection contexts = new ContextHandlerCollection();
+    alfrescoServer.setHandler(contexts);
+    WebAppContext alfrescoServerApi = new WebAppContext(alfrescoServerWarPath,"/alfresco");
+
+    alfrescoServer.start();
+    boolean entered = false;
+    
+    while(alfrescoServer.isStarted() 
+        && alfrescoServerApi.isStarted()
+        && !entered){
+      entered = true;
+      Thread.sleep(5000);
+    }
+  }
+}

Modified: manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/pom.xml?rev=1633001&r1=1633000&r2=1633001&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-1060/connectors/alfresco-webscript/pom.xml Sun Oct 19 21:34:03 2014
@@ -124,6 +124,91 @@
                     <workingDirectory>target/test-output</workingDirectory>
                 </configuration>
             </plugin>
+
+            <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>${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>
+                                <artifactItem>
+                                    <artifactId>alfresco-indexer-webscripts-war</artifactId>
+                                    <groupId>org.alfresco.consulting.indexer</groupId>
+                                    <version>0.6.4</version>
+                                    <type>war</type>
+                                    <overWrite>false</overWrite>
+                                    <destFileName>alfresco.war</destFileName>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <version>2.12.3</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>
+                        <alfrescoServerWarPath>../dependency/alfresco.war</alfrescoServerWarPath>
+                    </systemPropertyVariables>
+                    <excludes>
+                        <exclude>**/*Postgresql*.java</exclude>
+                        <exclude>**/*MySQL*.java</exclude>
+                    </excludes>
+                    <forkMode>always</forkMode>
+                    <workingDirectory>target/test-output</workingDirectory>
+                    <argLine>-Xms512m -Xmx1024m -Xss1024k -XX:MaxPermSize=256m -XX:NewSize=256m</argLine>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>integration-test</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>