Author: bramk
Date: Fri May 18 15:43:34 2012
New Revision: 1340135
URL: http://svn.apache.org/viewvc?rev=1340135&view=rev
Log:
ACE-275 Fixed itests on windows
Modified:
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/ProcessManagerImplTest.java
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/TestUtil.java
Modified:
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/ProcessManagerImplTest.java
URL:
http://svn.apache.org/viewvc/ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/ProcessManagerImplTest.java?rev=1340135&r1=1340134&r2=1340135&view=diff
==============================================================================
---
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/ProcessManagerImplTest.java
(original)
+++
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/ProcessManagerImplTest.java
Fri May 18 15:43:34 2012
@@ -18,6 +18,7 @@
*/
package org.apache.ace.processlauncher.test.impl;
+import static org.apache.ace.processlauncher.test.impl.TestUtil.createTempDir;
import static org.apache.ace.processlauncher.test.impl.TestUtil.getOSName;
import static org.apache.ace.processlauncher.test.impl.TestUtil.sleep;
@@ -36,7 +37,7 @@ import org.osgi.service.log.LogService;
* Test cases for {@link ProcessManager}.
*/
public class ProcessManagerImplTest extends TestCase {
-
+
private ProcessManagerImpl m_processManager;
/**
@@ -82,7 +83,7 @@ public class ProcessManagerImplTest exte
return;
}
- LaunchConfiguration launchConfig = createLaunchConfiguration("PING",
"-n", "1", "127.0.0.1");
+ LaunchConfiguration launchConfig = createLaunchConfiguration("PING",
"-n", "2", "127.0.0.1");
int processCountBefore = m_processManager.getRunningProcessesCount();
@@ -298,8 +299,8 @@ public class ProcessManagerImplTest exte
* @return a {@link LaunchConfigurationImpl} instance, never
<code>null</code>.
*/
private LaunchConfiguration createLaunchConfiguration(boolean
respawnAutomatically, String execName,
- String... execArgs) {
- return new LaunchConfigurationImpl(1, "/tmp", execName, execArgs, 0,
null /* processStreamListenerFilter */,
+ String... execArgs) throws Exception {
+ return new LaunchConfigurationImpl(1,
createTempDir().getAbsolutePath(), execName, execArgs, 0, null /*
processStreamListenerFilter */,
null /* processLifecycleListenerFilter */, respawnAutomatically);
}
@@ -311,7 +312,7 @@ public class ProcessManagerImplTest exte
*
* @return a {@link LaunchConfigurationImpl} instance, never
<code>null</code>.
*/
- private LaunchConfiguration createLaunchConfiguration(String execName,
String... execArgs) {
+ private LaunchConfiguration createLaunchConfiguration(String execName,
String... execArgs) throws Exception {
return createLaunchConfiguration(false /* respawnAutomatically */,
execName, execArgs);
}
}
Modified:
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/TestUtil.java
URL:
http://svn.apache.org/viewvc/ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/TestUtil.java?rev=1340135&r1=1340134&r2=1340135&view=diff
==============================================================================
---
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/TestUtil.java
(original)
+++
ace/trunk/ace-processlauncher/src/test/java/org/apache/ace/processlauncher/test/impl/TestUtil.java
Fri May 18 15:43:34 2012
@@ -103,4 +103,23 @@ public final class TestUtil {
}
return sb.toString();
}
+
+ /**
+ * Creates a unique temporary directory.
+ *
+ * @return the unique temporary directory
+ */
+ public static File createTempDir() throws IOException {
+
+ File baseDir = new File(System.getProperty("java.io.tmpdir"));
+ String baseName = System.currentTimeMillis() + "-";
+
+ for (int counter = 0; counter < 1000; counter++) {
+ File tempDir = new File(baseDir, baseName + counter);
+ if (tempDir.mkdir()) {
+ return tempDir;
+ }
+ }
+ throw new IOException("Failed to create tmp directory");
+ }
}