incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1374918 - in /incubator/ooo/trunk/main/test: testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java testuno/source/org/openoffice/test/uno/UnoApp.java
Date Mon, 20 Aug 2012 06:00:58 GMT
Author: liuzhe
Date: Mon Aug 20 06:00:58 2012
New Revision: 1374918

URL: http://svn.apache.org/viewvc?rev=1374918&view=rev
Log:
Set connection retry count to 5, sleep interval to 2 seconds.

Modified:
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
    incubator/ooo/trunk/main/test/testuno/source/org/openoffice/test/uno/UnoApp.java

Modified: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java?rev=1374918&r1=1374917&r2=1374918&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
(original)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
Mon Aug 20 06:00:58 2012
@@ -33,6 +33,8 @@ import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.openoffice.test.common.SystemUtil;
+
 /**
  * Manage the communication with the automation server.
  * It's used to establish the connection, send and receive data package.
@@ -56,9 +58,9 @@ public class CommunicationManager implem
 
 	private Socket socket = null;
 	
-	private int reconnectInterval = 4000;
+	private double reconnectInterval = 2;
 	
-	private int reconnectCount = 3;
+	private int reconnectCount = 5;
 	
 	private List<CommunicationListener> listeners = new Vector<CommunicationListener>();
 	
@@ -87,39 +89,6 @@ public class CommunicationManager implem
 		this.port = port;
 	}
 	
-	
-	/**
-	 * Get the max count retrying to connect the server  
-	 * @return
-	 */
-	public int getReconnectCount() {
-		return reconnectCount;
-	}
-
-	/**
-	 * Set the max count retrying to connect the server  
-	 * @param reconnectCount
-	 */
-	public void setReconnectCount(int reconnectCount) {
-		this.reconnectCount = reconnectCount;
-	}
-
-	/**
-	 * Get the interval between retrying to connect the server
-	 * @return
-	 */
-	public int getReconnectInterval() {
-		return reconnectInterval;
-	}
-
-	/**
-	 * Set the interval between retrying to connect the server
-	 * @param reconnectInterval
-	 */
-	public void setReconnectInterval(int reconnectInterval) {
-		this.reconnectInterval = reconnectInterval;
-	}
-	
 	/**
 	 * Send a data package to server
 	 * @param headerType the package header type
@@ -255,14 +224,10 @@ public class CommunicationManager implem
 				logger.log(Level.FINEST, "Failed to connect! Tried " + i, e);
 			}
 			
-			try {
-				Thread.sleep(2000);
-			} catch (InterruptedException e) {
-				//ignore
-			}
+			SystemUtil.sleep(reconnectInterval);
 		}
 		
-		throw new CommunicationException("Failed to connect automation server!");
+		throw new CommunicationException("Failed to connect to automation server on: " + host +
":" + port);
 	}
 	
 	

Modified: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java?rev=1374918&r1=1374917&r2=1374918&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
(original)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
Mon Aug 20 06:00:58 2012
@@ -84,10 +84,13 @@ public class VclApp {
 	public void start(boolean isCleanUserInstallation) {	// Default to clean user installation
 		if (openOffice != null) {
 			if (isCleanUserInstallation) {
+				openOffice.kill();
 				openOffice.cleanUserInstallation();
+				openOffice.start();
+				SystemUtil.sleep(5);
+			} else {
+				openOffice.start();
 			}
-			
-			openOffice.start();
 		}
 		
 		communicationManager.start();

Modified: incubator/ooo/trunk/main/test/testuno/source/org/openoffice/test/uno/UnoApp.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testuno/source/org/openoffice/test/uno/UnoApp.java?rev=1374918&r1=1374917&r2=1374918&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testuno/source/org/openoffice/test/uno/UnoApp.java (original)
+++ incubator/ooo/trunk/main/test/testuno/source/org/openoffice/test/uno/UnoApp.java Mon Aug
20 06:00:58 2012
@@ -58,10 +58,22 @@ public class UnoApp {
 
 	private XDesktop desktop = null;
 
+	private double reconnectInterval = 2;
+	
+	private int reconnectCount = 5;
+	
 	public UnoApp() {
 		this.openOffice = OpenOffice.getDefault();
 	}
-
+	
+	public UnoApp(OpenOffice openOffice) {
+		this.openOffice = openOffice;
+	}
+	
+	public UnoApp(String unoUrl) {
+		this.unoUrl = unoUrl;
+	}
+	
 	/**
 	 * Start OpenOffice and connect to it
 	 */
@@ -71,7 +83,7 @@ public class UnoApp {
 			unoUrl = openOffice.getUnoUrl();
 		}
 
-		for (int i = 0; i < 3; i++) {
+		for (int i = 0; i < reconnectCount; i++) {
 			try {
 				XUnoUrlResolver resolver = UnoUrlResolver.create(Bootstrap.createInitialComponentContext(null));
 				componentContext = UnoRuntime.queryInterface(XComponentContext.class, resolver.resolve("uno:"
+ unoUrl + ";StarOffice.ComponentContext"));
@@ -83,10 +95,10 @@ public class UnoApp {
 				// e.printStackTrace(); // for debugging
 			}
 
-			SystemUtil.sleep(2);
+			SystemUtil.sleep(reconnectInterval);
 		}
 
-		throw new RuntimeException("OpenOffice can't be connected!");
+		throw new RuntimeException("Failed to connect to uno url: " + unoUrl);
 	}
 
 	private Timer timer = new Timer(true);



Mime
View raw message