incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1225740 [1/3] - in /incubator/lcf/trunk: ./ framework/pull-agent/ framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/ tests/cmis/src/test/java/org/apach...
Date Fri, 30 Dec 2011 03:15:14 GMT
Author: kwright
Date: Fri Dec 30 03:15:14 2011
New Revision: 1225740

URL: http://svn.apache.org/viewvc?rev=1225740&view=rev
Log:
Created a ManifoldCFInstance to reduce code duplication in tests.  Part of CONNECTORS-346.

Added:
    incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java   (with props)
    incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java   (with props)
    incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java   (with props)
    incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java   (with props)
    incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java   (with props)
Modified:
    incubator/lcf/trunk/build.xml
    incubator/lcf/trunk/framework/pull-agent/pom.xml
    incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/Base.java
    incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/Base.java
    incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/BaseDerby.java
    incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/BaseHSQLDB.java
    incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/BaseMySQL.java
    incubator/lcf/trunk/tests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_tests/BasePostgresql.java
    incubator/lcf/trunk/tests/rss/src/test/java/org/apache/manifoldcf/rss_tests/BaseDerby.java
    incubator/lcf/trunk/tests/rss/src/test/java/org/apache/manifoldcf/rss_tests/BaseHSQLDB.java
    incubator/lcf/trunk/tests/rss/src/test/java/org/apache/manifoldcf/rss_tests/BaseMySQL.java
    incubator/lcf/trunk/tests/rss/src/test/java/org/apache/manifoldcf/rss_tests/BasePostgresql.java
    incubator/lcf/trunk/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/BaseDerby.java

Modified: incubator/lcf/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/build.xml?rev=1225740&r1=1225739&r2=1225740&view=diff
==============================================================================
--- incubator/lcf/trunk/build.xml (original)
+++ incubator/lcf/trunk/build.xml Fri Dec 30 03:15:14 2011
@@ -2572,7 +2572,7 @@
             </classpath>
             <formatter type="brief" usefile="false"/>
               
-            <test name="org.apache.manifoldcf.alfresco_tests.APISanityIT" todir="test-derby-output/alfresco"/>
+            <test name="org.apache.manifoldcf.alfresco_tests.APISanityIT" todir="test-output/alfresco"/>
         	
         </junit>
     </target>
@@ -2609,8 +2609,8 @@
             </classpath>
             <formatter type="brief" usefile="false"/>
 	    
-            
-            <!-- MHL -->
+            <test name="org.apache.manifoldcf.cmis_tests.APISanityIT" todir="test-output/cmis"/>
+
         </junit>
     </target>
 

Modified: incubator/lcf/trunk/framework/pull-agent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/pom.xml?rev=1225740&r1=1225739&r2=1225740&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/pom.xml (original)
+++ incubator/lcf/trunk/framework/pull-agent/pom.xml Fri Dec 30 03:15:14 2011
@@ -77,6 +77,50 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>${jetty.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jsp-api-2.1</artifactId>
+      <version>6.1.14</version>
+      <scope>test</scope>
+    </dependency>    
+    <dependency>
+      <groupId>javax.servlet.jsp</groupId>
+      <artifactId>jsp-api</artifactId>
+      <version>2.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jsp-2.1-glassfish</artifactId>
+      <version>2.1.v20091210</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient-mcf</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.5</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>mcf-core</artifactId>
       <version>${project.version}</version>

Added: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java?rev=1225740&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java (added)
+++ incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java Fri Dec 30 03:15:14 2011
@@ -0,0 +1,170 @@
+/* $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.tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseITDerby extends ConnectorBase
+{
+  protected ManifoldCFInstance mcfInstance = new ManifoldCFInstance();
+  
+  // API support
+  
+  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+  
+  /** Construct a command url.
+  */
+  protected String makeAPIURL(String command)
+  {
+    return mcfInstance.makeAPIURL(command);
+  }
+  
+  /** Perform an json API GET operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIGetOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API DELETE operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API PUT operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform an json API POST operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  // Setup/teardown
+  
+  @Before
+  public void setUp()
+    throws Exception
+  {
+    super.setUp();
+    mcfInstance.start();
+  }
+  
+  @After
+  public void cleanUp()
+    throws Exception
+  {
+    initialize();
+    if (isInitialized())
+    {
+      Exception currentException = null;
+      try
+      {
+        mcfInstance.stop();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      // Clean up everything else
+      try
+      {
+        super.cleanUp();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      if (currentException != null)
+        throw currentException;
+    }
+  }
+  
+}

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java?rev=1225740&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java (added)
+++ incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java Fri Dec 30 03:15:14 2011
@@ -0,0 +1,170 @@
+/* $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.tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseITHSQLDB extends ConnectorBaseHSQLDB
+{
+  protected ManifoldCFInstance mcfInstance = new ManifoldCFInstance();
+  
+  // API support
+  
+  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+  
+  /** Construct a command url.
+  */
+  protected String makeAPIURL(String command)
+  {
+    return mcfInstance.makeAPIURL(command);
+  }
+  
+  /** Perform an json API GET operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIGetOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API DELETE operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API PUT operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform an json API POST operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  // Setup/teardown
+  
+  @Before
+  public void setUp()
+    throws Exception
+  {
+    super.setUp();
+    mcfInstance.start();
+  }
+  
+  @After
+  public void cleanUp()
+    throws Exception
+  {
+    initialize();
+    if (isInitialized())
+    {
+      Exception currentException = null;
+      try
+      {
+        mcfInstance.stop();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      // Clean up everything else
+      try
+      {
+        super.cleanUp();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      if (currentException != null)
+        throw currentException;
+    }
+  }
+  
+}

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java?rev=1225740&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java (added)
+++ incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java Fri Dec 30 03:15:14 2011
@@ -0,0 +1,170 @@
+/* $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.tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseITMySQL extends ConnectorBaseMySQL
+{
+  protected ManifoldCFInstance mcfInstance = new ManifoldCFInstance();
+  
+  // API support
+  
+  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+  
+  /** Construct a command url.
+  */
+  protected String makeAPIURL(String command)
+  {
+    return mcfInstance.makeAPIURL(command);
+  }
+  
+  /** Perform an json API GET operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIGetOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API DELETE operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API PUT operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform an json API POST operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  // Setup/teardown
+  
+  @Before
+  public void setUp()
+    throws Exception
+  {
+    super.setUp();
+    mcfInstance.start();
+  }
+  
+  @After
+  public void cleanUp()
+    throws Exception
+  {
+    initialize();
+    if (isInitialized())
+    {
+      Exception currentException = null;
+      try
+      {
+        mcfInstance.stop();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      // Clean up everything else
+      try
+      {
+        super.cleanUp();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      if (currentException != null)
+        throw currentException;
+    }
+  }
+  
+}

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java?rev=1225740&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java (added)
+++ incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java Fri Dec 30 03:15:14 2011
@@ -0,0 +1,170 @@
+/* $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.tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseITPostgresql extends ConnectorBasePostgresql
+{
+  protected ManifoldCFInstance mcfInstance = new ManifoldCFInstance();
+  
+  // API support
+  
+  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+  
+  /** Construct a command url.
+  */
+  protected String makeAPIURL(String command)
+  {
+    return mcfInstance.makeAPIURL(command);
+  }
+  
+  /** Perform an json API GET operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIGetOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API DELETE operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperation(apiURL,expectedResponse);
+  }
+
+  /** Perform an json API PUT operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform an json API POST operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperation(apiURL,expectedResponse,input);
+  }
+
+  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIGetOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    return mcfInstance.performAPIDeleteOperationViaNodes(command,expectedResponse);
+  }
+
+  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPutOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    return mcfInstance.performAPIPostOperationViaNodes(command,expectedResponse,argument);
+  }
+
+  // Setup/teardown
+  
+  @Before
+  public void setUp()
+    throws Exception
+  {
+    super.setUp();
+    mcfInstance.start();
+  }
+  
+  @After
+  public void cleanUp()
+    throws Exception
+  {
+    initialize();
+    if (isInitialized())
+    {
+      Exception currentException = null;
+      try
+      {
+        mcfInstance.stop();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      // Clean up everything else
+      try
+      {
+        super.cleanUp();
+      }
+      catch (Exception e)
+      {
+        if (currentException == null)
+          currentException = e;
+      }
+      if (currentException != null)
+        throw currentException;
+    }
+  }
+  
+}

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1225740&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java (added)
+++ incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java Fri Dec 30 03:15:14 2011
@@ -0,0 +1,434 @@
+/* $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.tests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.log.Logger;
+
+import org.apache.commons.httpclient.*;
+import org.apache.commons.httpclient.methods.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class ManifoldCFInstance
+{
+  public static final String agentShutdownSignal = "agent-process";
+  
+  protected DaemonThread daemonThread = null;
+  protected Server server = null;
+
+  protected int testPort = 8346;
+  
+  public ManifoldCFInstance()
+  {
+  }
+  
+  public ManifoldCFInstance(int testPort)
+  {
+    this.testPort = testPort;
+  }
+
+  // API support
+  
+  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+  
+  /** Construct a command url.
+  */
+  public String makeAPIURL(String command)
+  {
+    return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
+  }
+  
+  /** Perform an json API GET operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  public String performAPIGetOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    HttpClient client = new HttpClient();
+    GetMethod method = new GetMethod(apiURL);
+    int response = client.executeMethod(method);
+    byte[] responseData = method.getResponseBody();
+    String responseString = new String(responseData,"utf-8");
+    if (response != expectedResponse)
+      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+    // We presume that the data is utf-8, since that's what the API uses throughout.
+    return responseString;
+  }
+
+  /** Perform an json API DELETE operation.
+  *@param apiURL is the operation.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  public String performAPIDeleteOperation(String apiURL, int expectedResponse)
+    throws Exception
+  {
+    HttpClient client = new HttpClient();
+    DeleteMethod method = new DeleteMethod(apiURL);
+    int response = client.executeMethod(method);
+    byte[] responseData = method.getResponseBody();
+    String responseString = new String(responseData,"utf-8");
+    if (response != expectedResponse)
+      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+    // We presume that the data is utf-8, since that's what the API uses throughout.
+    return responseString;
+  }
+
+  /** Perform an json API PUT operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  public String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    HttpClient client = new HttpClient();
+    PutMethod method = new PutMethod(apiURL);
+    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
+    method.setRequestBody(input);
+    int response = client.executeMethod(method);
+    byte[] responseData = method.getResponseBody();
+    String responseString = new String(responseData,"utf-8");
+    if (response != expectedResponse)
+      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+    // We presume that the data is utf-8, since that's what the API uses throughout.
+    return responseString;
+  }
+
+  /** Perform an json API POST operation.
+  *@param apiURL is the operation.
+  *@param input is the input JSON.
+  *@param expectedResponse is the expected response code.
+  *@return the json response.
+  */
+  public String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+    throws Exception
+  {
+    HttpClient client = new HttpClient();
+    PostMethod method = new PostMethod(apiURL);
+    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
+    method.setRequestBody(input);
+    int response = client.executeMethod(method);
+    byte[] responseData = method.getResponseBody();
+    String responseString = new String(responseData,"utf-8");
+    if (response != expectedResponse)
+      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+    // We presume that the data is utf-8, since that's what the API uses throughout.
+    return responseString;
+  }
+
+  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  public Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    String result = performAPIGetOperation(makeAPIURL(command),expectedResponse);
+    Configuration cfg = new Configuration();
+    cfg.fromJSON(result);
+    return cfg;
+  }
+
+  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  public Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+    throws Exception
+  {
+    String result = performAPIDeleteOperation(makeAPIURL(command),expectedResponse);
+    Configuration cfg = new Configuration();
+    cfg.fromJSON(result);
+    return cfg;
+  }
+
+  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  public Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    String argumentJson;
+    if (argument != null)
+      argumentJson = argument.toJSON();
+    else
+      argumentJson = null;
+    
+    String result = performAPIPutOperation(makeAPIURL(command),expectedResponse,argumentJson);
+    Configuration cfg = new Configuration();
+    cfg.fromJSON(result);
+    return cfg;
+  }
+
+  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
+  * mostly.
+  */
+  public Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+    throws Exception
+  {
+    String argumentJson;
+    if (argument != null)
+      argumentJson = argument.toJSON();
+    else
+      argumentJson = null;
+    
+    String result = performAPIPostOperation(makeAPIURL(command),expectedResponse,argumentJson);
+    Configuration cfg = new Configuration();
+    cfg.fromJSON(result);
+    return cfg;
+  }
+
+  // Setup/teardown
+  
+  public void start()
+    throws Exception
+  {
+    // Start jetty
+    server = new Server( testPort );    
+    server.setStopAtShutdown( true );
+    
+    String crawlerWarPath = "../../framework/build/war/mcf-crawler-ui.war";
+    String authorityserviceWarPath = "../../framework/build/war/mcf-authority-service.war";
+    String apiWarPath = "../../framework/build/war/mcf-api-service.war";
+
+    if (System.getProperty("crawlerWarPath") != null)
+    	crawlerWarPath = System.getProperty("crawlerWarPath");
+    if (System.getProperty("authorityserviceWarPath") != null)
+    	authorityserviceWarPath = System.getProperty("authorityserviceWarPath");
+    if (System.getProperty("apiWarPath") != null)
+    	apiWarPath = System.getProperty("apiWarPath");
+
+    
+    // Initialize the servlets
+    WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
+    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
+    lcfCrawlerUI.setParentLoaderPriority(true);
+    server.addHandler(lcfCrawlerUI);
+    WebAppContext lcfAuthorityService = new WebAppContext(authorityserviceWarPath,"/mcf-authority-service");
+    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
+    lcfAuthorityService.setParentLoaderPriority(true);
+    server.addHandler(lcfAuthorityService);
+    WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
+    lcfApi.setParentLoaderPriority(true);
+    server.addHandler(lcfApi);
+    server.start();
+
+    // If all worked, then we can start the daemon.
+    // Clear the agents shutdown signal.
+    IThreadContext tc = ThreadContextFactory.make();
+    ILockManager lockManager = LockManagerFactory.make(tc);
+    lockManager.clearGlobalFlag(agentShutdownSignal);
+
+    daemonThread = new DaemonThread();
+    daemonThread.start();
+  }
+  
+  public void stop()
+    throws Exception
+  {
+    Exception currentException = null;
+    IThreadContext tc = ThreadContextFactory.make();
+
+    // Delete all jobs (and wait for them to go away)
+    if (daemonThread != null)
+    {
+      IJobManager jobManager = JobManagerFactory.make(tc);
+        
+      // Get a list of the current active jobs
+      IJobDescription[] jobs = jobManager.getAllJobs();
+      int i = 0;
+      while (i < jobs.length)
+      {
+        IJobDescription desc = jobs[i++];
+        // Abort this job, if it is running
+        try
+        {
+          jobManager.manualAbort(desc.getID());
+        }
+        catch (ManifoldCFException e)
+        {
+          // This generally means that the job was not running
+        }
+      }
+      i = 0;
+      while (i < jobs.length)
+      {
+        IJobDescription desc = jobs[i++];
+        // Wait for this job to stop
+        while (true)
+        {
+          JobStatus status = jobManager.getStatus(desc.getID(),false);
+          if (status != null)
+          {
+            int statusValue = status.getStatus();
+            switch (statusValue)
+            {
+            case JobStatus.JOBSTATUS_NOTYETRUN:
+            case JobStatus.JOBSTATUS_COMPLETED:
+            case JobStatus.JOBSTATUS_ERROR:
+              break;
+            default:
+              ManifoldCF.sleep(10000);
+              continue;
+            }
+          }
+          break;
+        }
+      }
+
+      // Now, delete them all
+      i = 0;
+      while (i < jobs.length)
+      {
+        IJobDescription desc = jobs[i++];
+        try
+        {
+          jobManager.deleteJob(desc.getID());
+        }
+        catch (ManifoldCFException e)
+        {
+          // This usually means that the job is already being deleted
+        }
+      }
+
+      i = 0;
+      while (i < jobs.length)
+      {
+        IJobDescription desc = jobs[i++];
+        // Wait for this job to disappear
+        while (true)
+        {
+          JobStatus status = jobManager.getStatus(desc.getID(),false);
+          if (status != null)
+          {
+            ManifoldCF.sleep(10000);
+            continue;
+          }
+          break;
+        }
+      }
+
+      // Shut down daemon
+      ILockManager lockManager = LockManagerFactory.make(tc);
+      lockManager.setGlobalFlag(agentShutdownSignal);
+      
+      // Wait for daemon thread to exit.
+      while (true)
+      {
+        if (daemonThread.isAlive())
+        {
+          Thread.sleep(1000L);
+          continue;
+        }
+        break;
+      }
+
+      Exception e = daemonThread.getDaemonException();
+      if (e != null)
+        currentException = e;
+    }
+      
+    if (server != null)
+    {
+      server.stop();
+      server.join();
+      server = null;
+    }
+      
+    if (currentException != null)
+      throw currentException;
+  }
+  
+  protected static class DaemonThread extends Thread
+  {
+    protected Exception daemonException = null;
+    
+    public DaemonThread()
+    {
+      setName("Daemon thread");
+    }
+    
+    public void run()
+    {
+      IThreadContext tc = ThreadContextFactory.make();
+      // Now, start the server, and then wait for the shutdown signal.  On shutdown, we have to actually do the cleanup,
+      // because the JVM isn't going away.
+      try
+      {
+        ILockManager lockManager = LockManagerFactory.make(tc);
+        while (true)
+        {
+          // Any shutdown signal yet?
+          if (lockManager.checkGlobalFlag(agentShutdownSignal))
+            break;
+            
+          // Start whatever agents need to be started
+          ManifoldCF.startAgents(tc);
+
+          try
+          {
+            ManifoldCF.sleep(5000);
+          }
+          catch (InterruptedException e)
+          {
+            break;
+          }
+        }
+      }
+      catch (ManifoldCFException e)
+      {
+        daemonException = e;
+      }
+      finally
+      {
+        try
+        {
+          ManifoldCF.stopAgents(tc);
+        }
+        catch (ManifoldCFException e)
+        {
+          daemonException = e;
+        }
+      }
+    }
+    
+    public Exception getDaemonException()
+    {
+      return daemonException;
+    }
+    
+  }
+
+}

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/Base.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/Base.java?rev=1225740&r1=1225739&r2=1225740&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/Base.java (original)
+++ incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/Base.java Fri Dec 30 03:15:14 2011
@@ -18,40 +18,20 @@
 */
 package org.apache.manifoldcf.alfresco_tests;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.manifoldcf.core.interfaces.Configuration;
-import org.apache.manifoldcf.core.interfaces.ILockManager;
-import org.apache.manifoldcf.core.interfaces.IThreadContext;
-import org.apache.manifoldcf.core.interfaces.LockManagerFactory;
-import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
-import org.apache.manifoldcf.core.interfaces.ThreadContextFactory;
-import org.apache.manifoldcf.crawler.interfaces.IJobDescription;
-import org.apache.manifoldcf.crawler.interfaces.IJobManager;
-import org.apache.manifoldcf.crawler.interfaces.JobManagerFactory;
-import org.apache.manifoldcf.crawler.interfaces.JobStatus;
-import org.apache.manifoldcf.crawler.system.ManifoldCF;
-import org.junit.After;
-import org.junit.Before;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.plus.naming.Resource;
 import org.mortbay.jetty.webapp.WebAppContext;
 
+import org.junit.After;
+import org.junit.Before;
+
 /** Tests that run the "agents daemon" should be derived from this 
  * 
  *  @author Piergiorgio Lucidi
  * 
  * */
-public class Base extends org.apache.manifoldcf.crawler.tests.ConnectorBase
+public class Base extends org.apache.manifoldcf.crawler.tests.BaseITDerby
 {
-  public static final String agentShutdownSignal = "agent-process";
-  public static final int testPort = 8346;
-  
-  protected DaemonThread daemonThread = null;
-  protected Server server = null;
   protected Server alfrescoServer = null;
 
   
@@ -75,195 +55,12 @@ public class Base extends org.apache.man
     return new String[]{"org.apache.manifoldcf.agents.output.nullconnector.NullConnector"};
   }
   
-  // API support
-  
-  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
-  
-  /** Construct a command url.
-  */
-  protected String makeAPIURL(String command)
-  {
-    return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
-  }
-  
-  /** Perform an json API GET operation.
-  *@param apiURL is the operation.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIGetOperation(String apiURL, int expectedResponse)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    GetMethod method = new GetMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API DELETE operation.
-  *@param apiURL is the operation.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    DeleteMethod method = new DeleteMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API PUT operation.
-  *@param apiURL is the operation.
-  *@param input is the input JSON.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    PutMethod method = new PutMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API POST operation.
-  *@param apiURL is the operation.
-  *@param input is the input JSON.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    PostMethod method = new PostMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
-    throws Exception
-  {
-    String result = performAPIGetOperation(makeAPIURL(command),expectedResponse);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
-    throws Exception
-  {
-    String result = performAPIDeleteOperation(makeAPIURL(command),expectedResponse);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
-    throws Exception
-  {
-    String argumentJson;
-    if (argument != null)
-      argumentJson = argument.toJSON();
-    else
-      argumentJson = null;
-    
-    String result = performAPIPutOperation(makeAPIURL(command),expectedResponse,argumentJson);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
-    throws Exception
-  {
-    String argumentJson;
-    if (argument != null)
-      argumentJson = argument.toJSON();
-    else
-      argumentJson = null;
-    
-    String result = performAPIPostOperation(makeAPIURL(command),expectedResponse,argumentJson);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
   // Setup/teardown
   
   @Before
-  public void setUp()
+  public void setUpAlfresco()
     throws Exception
   {
-    super.setUp();
-    // Start jetty
-    server = new Server( testPort );    
-    server.setStopAtShutdown( true );
-    
-    String crawlerWarPath = "../../framework/build/war/mcf-crawler-ui.war";
-    String authorityserviceWarPath = "../../framework/build/war/mcf-authority-service.war";
-    String apiWarPath = "../../framework/build/war/mcf-api-service.war";
-
-    if (System.getProperty("crawlerWarPath") != null)
-    	crawlerWarPath = System.getProperty("crawlerWarPath");
-    if (System.getProperty("authorityserviceWarPath") != null)
-    	authorityserviceWarPath = System.getProperty("authorityserviceWarPath");
-    if (System.getProperty("apiWarPath") != null)
-    	apiWarPath = System.getProperty("apiWarPath");
-
-    // Initialize the servlets
-    WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
-    lcfCrawlerUI.setParentLoaderPriority(true);
-    server.addHandler(lcfCrawlerUI);
-    WebAppContext lcfAuthorityService = new WebAppContext(authorityserviceWarPath,"/mcf-authority-service");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
-    lcfAuthorityService.setParentLoaderPriority(true);
-    server.addHandler(lcfAuthorityService);
-    WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
-    lcfApi.setParentLoaderPriority(true);
-    server.addHandler(lcfApi);
-    server.start();
-
     alfrescoServer = new Server(9090);
     alfrescoServer.setStopAtShutdown(true);
 
@@ -292,215 +89,18 @@ public class Base extends org.apache.man
     alfrescoServer.start();
     boolean entered = false;
     
-    while(server.isStarted() 
-        && alfrescoServer.isStarted() 
+    while(alfrescoServer.isStarted() 
         && alfrescoServerApi.isStarted()
-        && lcfApi.isStarted()
-        && lcfAuthorityService.isStarted()
-        && lcfCrawlerUI.isStarted()
         && !entered){
       entered = true;
-      ManifoldCF.sleep(5000);
-      // If all worked, then we can start the daemon.
-      // Clear the agents shutdown signal.
-      IThreadContext tc = ThreadContextFactory.make();
-      ILockManager lockManager = LockManagerFactory.make(tc);
-      lockManager.clearGlobalFlag(agentShutdownSignal);
-  
-      daemonThread = new DaemonThread();
-      daemonThread.start();
+      Thread.sleep(5000);
     }
   }
   
   @After
-  public void cleanUp()
+  public void cleanUpAlfresco()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      Exception currentException = null;
-      IThreadContext tc = ThreadContextFactory.make();
-
-      // Delete all jobs (and wait for them to go away)
-      if (daemonThread != null)
-      {
-        IJobManager jobManager = JobManagerFactory.make(tc);
-        
-        // Get a list of the current active jobs
-        IJobDescription[] jobs = jobManager.getAllJobs();
-        int i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Abort this job, if it is running
-          try
-          {
-            jobManager.manualAbort(desc.getID());
-          }
-          catch (ManifoldCFException e)
-          {
-            // This generally means that the job was not running
-          }
-        }
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Wait for this job to stop
-          while (true)
-          {
-            JobStatus status = jobManager.getStatus(desc.getID(),false);
-            if (status != null)
-            {
-              int statusValue = status.getStatus();
-              switch (statusValue)
-              {
-              case JobStatus.JOBSTATUS_NOTYETRUN:
-              case JobStatus.JOBSTATUS_COMPLETED:
-              case JobStatus.JOBSTATUS_ERROR:
-                break;
-              default:
-                ManifoldCF.sleep(10000);
-                continue;
-              }
-            }
-            break;
-          }
-        }
-
-        // Now, delete them all
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          try
-          {
-            jobManager.deleteJob(desc.getID());
-          }
-          catch (ManifoldCFException e)
-          {
-            // This usually means that the job is already being deleted
-          }
-        }
-
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Wait for this job to disappear
-          while (true)
-          {
-            JobStatus status = jobManager.getStatus(desc.getID(),false);
-            if (status != null)
-            {
-              ManifoldCF.sleep(10000);
-              continue;
-            }
-            break;
-          }
-        }
-
-        // Shut down daemon
-        ILockManager lockManager = LockManagerFactory.make(tc);
-        lockManager.setGlobalFlag(agentShutdownSignal);
-      
-        // Wait for daemon thread to exit.
-        while (true)
-        {
-          if (daemonThread.isAlive())
-          {
-            Thread.sleep(1000L);
-            continue;
-          }
-          break;
-        }
-
-        Exception e = daemonThread.getDaemonException();
-        if (e != null)
-          currentException = e;
-      }
-      
-      if (server != null)
-      {
-        server.stop();
-        server.join();
-        server = null;
-      }
-      
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
-    }
   }
   
-  protected static class DaemonThread extends Thread
-  {
-    protected Exception daemonException = null;
-    
-    public DaemonThread()
-    {
-      setName("Daemon thread");
-    }
-    
-    public void run()
-    {
-      IThreadContext tc = ThreadContextFactory.make();
-      // Now, start the server, and then wait for the shutdown signal.  On shutdown, we have to actually do the cleanup,
-      // because the JVM isn't going away.
-      try
-      {
-        ILockManager lockManager = LockManagerFactory.make(tc);
-        while (true)
-        {
-          // Any shutdown signal yet?
-          if (lockManager.checkGlobalFlag(agentShutdownSignal))
-            break;
-            
-          // Start whatever agents need to be started
-          ManifoldCF.startAgents(tc);
-
-          try
-          {
-            ManifoldCF.sleep(5000);
-          }
-          catch (InterruptedException e)
-          {
-            break;
-          }
-        }
-      }
-      catch (ManifoldCFException e)
-      {
-        daemonException = e;
-      }
-      finally
-      {
-        try
-        {
-          ManifoldCF.stopAgents(tc);
-        }
-        catch (ManifoldCFException e)
-        {
-          daemonException = e;
-        }
-      }
-    }
-    
-    public Exception getDaemonException()
-    {
-      return daemonException;
-    }
-    
-  }
-
 }

Modified: incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/Base.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/Base.java?rev=1225740&r1=1225739&r2=1225740&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/Base.java (original)
+++ incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/Base.java Fri Dec 30 03:15:14 2011
@@ -44,13 +44,8 @@ import org.mortbay.jetty.webapp.WebAppCo
  *  @author Piergiorgio Lucidi
  * 
  * */
-public class Base extends org.apache.manifoldcf.crawler.tests.ConnectorBase
+public class Base extends org.apache.manifoldcf.crawler.tests.BaseITDerby
 {
-  public static final String agentShutdownSignal = "agent-process";
-  public static final int testPort = 8346;
-  
-  protected DaemonThread daemonThread = null;
-  protected Server server = null;
   protected Server cmisServer = null;
 
   
@@ -74,195 +69,12 @@ public class Base extends org.apache.man
     return new String[]{"org.apache.manifoldcf.agents.output.nullconnector.NullConnector"};
   }
   
-  // API support
-  
-  // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
-  
-  /** Construct a command url.
-  */
-  protected String makeAPIURL(String command)
-  {
-    return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
-  }
-  
-  /** Perform an json API GET operation.
-  *@param apiURL is the operation.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIGetOperation(String apiURL, int expectedResponse)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    GetMethod method = new GetMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API DELETE operation.
-  *@param apiURL is the operation.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    DeleteMethod method = new DeleteMethod(apiURL);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API PUT operation.
-  *@param apiURL is the operation.
-  *@param input is the input JSON.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    PutMethod method = new PutMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform an json API POST operation.
-  *@param apiURL is the operation.
-  *@param input is the input JSON.
-  *@param expectedResponse is the expected response code.
-  *@return the json response.
-  */
-  protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
-    throws Exception
-  {
-    HttpClient client = new HttpClient();
-    PostMethod method = new PostMethod(apiURL);
-    method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
-    method.setRequestBody(input);
-    int response = client.executeMethod(method);
-    byte[] responseData = method.getResponseBody();
-    String responseString = new String(responseData,"utf-8");
-    if (response != expectedResponse)
-      throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
-    // We presume that the data is utf-8, since that's what the API uses throughout.
-    return responseString;
-  }
-
-  /** Perform a json GET API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
-    throws Exception
-  {
-    String result = performAPIGetOperation(makeAPIURL(command),expectedResponse);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json DELETE API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
-    throws Exception
-  {
-    String result = performAPIDeleteOperation(makeAPIURL(command),expectedResponse);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json PUT API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
-    throws Exception
-  {
-    String argumentJson;
-    if (argument != null)
-      argumentJson = argument.toJSON();
-    else
-      argumentJson = null;
-    
-    String result = performAPIPutOperation(makeAPIURL(command),expectedResponse,argumentJson);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
-  /** Perform a json POST API operation, using Configuration structures to represent the json.  This is for testing convenience,
-  * mostly.
-  */
-  protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
-    throws Exception
-  {
-    String argumentJson;
-    if (argument != null)
-      argumentJson = argument.toJSON();
-    else
-      argumentJson = null;
-    
-    String result = performAPIPostOperation(makeAPIURL(command),expectedResponse,argumentJson);
-    Configuration cfg = new Configuration();
-    cfg.fromJSON(result);
-    return cfg;
-  }
-
   // Setup/teardown
   
   @Before
-  public void setUp()
+  public void setUpCMIS()
     throws Exception
   {
-    super.setUp();
-    // Start jetty
-    server = new Server( testPort );    
-    server.setStopAtShutdown( true );
-    
-    String crawlerWarPath = "../../framework/build/war/mcf-crawler-ui.war";
-    String authorityserviceWarPath = "../../framework/build/war/mcf-authority-service.war";
-    String apiWarPath = "../../framework/build/war/mcf-api-service.war";
-
-    if (System.getProperty("crawlerWarPath") != null)
-    	crawlerWarPath = System.getProperty("crawlerWarPath");
-    if (System.getProperty("authorityserviceWarPath") != null)
-    	authorityserviceWarPath = System.getProperty("authorityserviceWarPath");
-    if (System.getProperty("apiWarPath") != null)
-    	apiWarPath = System.getProperty("apiWarPath");
-
-    // Initialize the servlets
-    WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
-    lcfCrawlerUI.setParentLoaderPriority(true);
-    server.addHandler(lcfCrawlerUI);
-    WebAppContext lcfAuthorityService = new WebAppContext(authorityserviceWarPath,"/mcf-authority-service");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
-    lcfAuthorityService.setParentLoaderPriority(true);
-    server.addHandler(lcfAuthorityService);
-    WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
-    lcfApi.setParentLoaderPriority(true);
-    server.addHandler(lcfApi);
-    server.start();
-
     cmisServer = new Server(9090);
     cmisServer.setStopAtShutdown(true);
 
@@ -279,215 +91,18 @@ public class Base extends org.apache.man
     cmisServer.start();
     boolean entered = false;
     
-    while(server.isStarted() 
-        && cmisServer.isStarted() 
+    while(cmisServer.isStarted() 
         && openCmisServerApi.isStarted()
-        && lcfApi.isStarted()
-        && lcfAuthorityService.isStarted()
-        && lcfCrawlerUI.isStarted()
         && !entered){
       entered = true;
       ManifoldCF.sleep(5000);
-      // If all worked, then we can start the daemon.
-      // Clear the agents shutdown signal.
-      IThreadContext tc = ThreadContextFactory.make();
-      ILockManager lockManager = LockManagerFactory.make(tc);
-      lockManager.clearGlobalFlag(agentShutdownSignal);
-  
-      daemonThread = new DaemonThread();
-      daemonThread.start();
     }
   }
   
   @After
-  public void cleanUp()
+  public void cleanUpCMIS()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      Exception currentException = null;
-      IThreadContext tc = ThreadContextFactory.make();
-
-      // Delete all jobs (and wait for them to go away)
-      if (daemonThread != null)
-      {
-        IJobManager jobManager = JobManagerFactory.make(tc);
-        
-        // Get a list of the current active jobs
-        IJobDescription[] jobs = jobManager.getAllJobs();
-        int i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Abort this job, if it is running
-          try
-          {
-            jobManager.manualAbort(desc.getID());
-          }
-          catch (ManifoldCFException e)
-          {
-            // This generally means that the job was not running
-          }
-        }
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Wait for this job to stop
-          while (true)
-          {
-            JobStatus status = jobManager.getStatus(desc.getID(),false);
-            if (status != null)
-            {
-              int statusValue = status.getStatus();
-              switch (statusValue)
-              {
-              case JobStatus.JOBSTATUS_NOTYETRUN:
-              case JobStatus.JOBSTATUS_COMPLETED:
-              case JobStatus.JOBSTATUS_ERROR:
-                break;
-              default:
-                ManifoldCF.sleep(10000);
-                continue;
-              }
-            }
-            break;
-          }
-        }
-
-        // Now, delete them all
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          try
-          {
-            jobManager.deleteJob(desc.getID());
-          }
-          catch (ManifoldCFException e)
-          {
-            // This usually means that the job is already being deleted
-          }
-        }
-
-        i = 0;
-        while (i < jobs.length)
-        {
-          IJobDescription desc = jobs[i++];
-          // Wait for this job to disappear
-          while (true)
-          {
-            JobStatus status = jobManager.getStatus(desc.getID(),false);
-            if (status != null)
-            {
-              ManifoldCF.sleep(10000);
-              continue;
-            }
-            break;
-          }
-        }
-
-        // Shut down daemon
-        ILockManager lockManager = LockManagerFactory.make(tc);
-        lockManager.setGlobalFlag(agentShutdownSignal);
-      
-        // Wait for daemon thread to exit.
-        while (true)
-        {
-          if (daemonThread.isAlive())
-          {
-            Thread.sleep(1000L);
-            continue;
-          }
-          break;
-        }
-
-        Exception e = daemonThread.getDaemonException();
-        if (e != null)
-          currentException = e;
-      }
-      
-      if (server != null)
-      {
-        server.stop();
-        server.join();
-        server = null;
-      }
-      
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
-    }
   }
   
-  protected static class DaemonThread extends Thread
-  {
-    protected Exception daemonException = null;
-    
-    public DaemonThread()
-    {
-      setName("Daemon thread");
-    }
-    
-    public void run()
-    {
-      IThreadContext tc = ThreadContextFactory.make();
-      // Now, start the server, and then wait for the shutdown signal.  On shutdown, we have to actually do the cleanup,
-      // because the JVM isn't going away.
-      try
-      {
-        ILockManager lockManager = LockManagerFactory.make(tc);
-        while (true)
-        {
-          // Any shutdown signal yet?
-          if (lockManager.checkGlobalFlag(agentShutdownSignal))
-            break;
-            
-          // Start whatever agents need to be started
-          ManifoldCF.startAgents(tc);
-
-          try
-          {
-            ManifoldCF.sleep(5000);
-          }
-          catch (InterruptedException e)
-          {
-            break;
-          }
-        }
-      }
-      catch (ManifoldCFException e)
-      {
-        daemonException = e;
-      }
-      finally
-      {
-        try
-        {
-          ManifoldCF.stopAgents(tc);
-        }
-        catch (ManifoldCFException e)
-        {
-          daemonException = e;
-        }
-      }
-    }
-    
-    public Exception getDaemonException()
-    {
-      return daemonException;
-    }
-    
-  }
-
 }



Mime
View raw message