Hi all,
I did work on this and found that maven's java process is not waiting
until all other processes started during the build is completed /
terminated. Following is what I did:
In one of my test cases, I start a new process using the java Runtime
class. For experimentation I executed the command "notepad" on windows
which would start a separate process for me. The test case is as
follows:
Process p = Runtime.getRuntime().exec("notepad");
When I do a mvn test, the java process started by the maven build does
not exit until the notepad is closed or terminated.
Is there a way or configuration in maven to work around such a setting
or is maven designed like this? I might want to be starting a server
like process in one of my test cases and would want maven to complete
the build which currently is not happening.
Regards,
Ravi
-----Original Message-----
From: Balasubramanian, Ravi Shankar
Sent: Wednesday, April 18, 2007 11:48 AM
To: Maven Users List
Subject: RE: Starting a new java process from within a test case is
hanging the maven JVM
Just in case, if anybody is looking into this, I tried creating a new
java process from a simple Java class in it's main method and verified
if the main class exits. It does exit and only when I run it through a
test case in maven, the maven's java process is not exiting.
Regards,
Ravi
-----Original Message-----
From: Balasubramanian, Ravi Shankar
Sent: Tuesday, April 17, 2007 5:29 PM
To: Maven Users List
Subject: Starting a new java process from within a test case is hanging
the maven JVM
Hi all,
We use maven-surefire-plugin to run our testng test cases. I encountered
a problem where in the maven VM is hanging when one of the test cases
start a separate java process from within it using the java
ProcessBuilder class(which I think is inconsequential here). What I am
doing in the test case is starting a server which I need to be running
throughout my maven builds across different projects. (Some sort of
integration tests.). Following is the structure for my build:
MainTestModule
------setupTests
------functionality1Tests
------functionality2Tests
...............................
My requirement is to have a server started (a separate java process) in
one of the test cases in the setupTests module which needs to be running
for all other tests to run.
One of the test case which starts the server looks something like below:
@Test
public void startUpgradeTestRepository() throws Exception{
ProcessBuilder pb = new
ProcessBuilder("cmd.exe","/c","C:\startrepo.bat");
Map<String, String> env = pb.environment();
pb.directory(new File(infa_home));
Process raprocess = pb.start();
//Process p = Runtime.getRuntime().exec("cmd.exe
/c dir");
}
This calls a batch script which starts a java process from within it:
startrepo.bat:
"@echo off
rem #
------------------------------------------------------------------------
-
rem # Script for starting the Repository
rem #
------------------------------------------------------------------------
-
java
com.informatica.repository.applications.repository.server.RepAgentApp
%REP_AGENT_ARGS%
exit
"
My problem is when I run "mvn test" from the setupTests directory or
from the parent directory, the maven java process that gets started for
the setupTests module does not end until the java process started by the
test case above is ended or is terminated. I am running the tests
through the surefire plugin.
When I run mvn test from the setupTests module, it runs all the test
cases in the module successfully(the java process is also started
successfully) and then it exits from the surefire's java process.
However the build is not ending until the java process is ended or
terminated. The maven java process that gets started for the setupTests
is not ending until the java process started by my test case is
terminated. Hence I am not able to run other tests of other modules
automatically.
Can one of you please let me know if there is any glitch anywhere in the
way I have coded my test case or in my setup?
Regards,
Ravi.
"Tough times never last, but tough men do..."
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]