You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/05/11 11:37:44 UTC
[maven-invoker] branch FIXBUILD_ISSUE updated: Improved test to be
sure to get the correct failure for timeout.
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch FIXBUILD_ISSUE
in repository https://gitbox.apache.org/repos/asf/maven-invoker.git
The following commit(s) were added to refs/heads/FIXBUILD_ISSUE by this push:
new 371bdae Improved test to be sure to get the correct failure for timeout.
371bdae is described below
commit 371bdae10e9bb38e3a9443c45d3a31f52282220f
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Fri May 11 13:37:27 2018 +0200
Improved test to be sure to get the correct failure for timeout.
---
.../maven/shared/invoker/DefaultInvokerTest.java | 19 +++++++----
.../resources/test-build-should-timeout/pom.xml | 13 +++++++-
.../org/apache/maven/shared/invoker/AppTest.java | 38 ++++++----------------
3 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
index 7aacf4e..83333bd 100644
--- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
@@ -48,7 +48,7 @@ public class DefaultInvokerTest
request.setBaseDirectory( basedir );
request.setDebug( true );
request.setGoals( Arrays.asList( "clean", "package" ) );
-
+
if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
{
Properties properties = new Properties();
@@ -74,7 +74,7 @@ public class DefaultInvokerTest
request.setBaseDirectory( basedir );
request.setDebug( true );
request.setGoals( Arrays.asList( "clean", "package" ) );
-
+
if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
{
Properties properties = new Properties();
@@ -89,7 +89,7 @@ public class DefaultInvokerTest
@Test
public void testBuildShouldTimeout()
- throws IOException, MavenInvocationException, URISyntaxException
+ throws IOException, MavenInvocationException, URISyntaxException
{
File basedir = getBasedirForBuild();
@@ -102,8 +102,7 @@ public class DefaultInvokerTest
// Using 1 second to make sure we will always get an timeout
// Maybe in the future on a faster system this will not work anymore,
// but for now it works.
- request.setTimeoutInSeconds( 1 );
- request.setOutputHandler( new SystemOutHandler() );
+ request.setTimeoutInSeconds( 4 );
if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
{
@@ -115,7 +114,12 @@ public class DefaultInvokerTest
InvocationResult result = invoker.execute( request );
- assertEquals( 1, result.getExitCode() );
+ // We check the exception to be sure the failure is based on timeout.
+ assertEquals( "Error while executing external command, process killed.",
+ result.getExecutionException().getMessage() );
+ // exitCode can't be used cause in case of an timeout it's not correctly
+ // set in DefaultInvoker. Need to think about this.
+ // assertEquals( 1, result.getExitCode() );
}
@Test
@@ -287,7 +291,8 @@ public class DefaultInvokerTest
if ( dirResource == null )
{
- throw new IllegalStateException( "Project: " + dirName + " for test method: " + methodName + " is missing." );
+ throw new IllegalStateException( "Project: " + dirName + " for test method: " + methodName
+ + " is missing." );
}
return new File( new URI( dirResource.toString() ).getPath() );
diff --git a/src/test/resources/test-build-should-timeout/pom.xml b/src/test/resources/test-build-should-timeout/pom.xml
index d43d9a5..1826d20 100644
--- a/src/test/resources/test-build-should-timeout/pom.xml
+++ b/src/test/resources/test-build-should-timeout/pom.xml
@@ -27,8 +27,19 @@ under the License.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.21.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
diff --git a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
index b1ab6d2..c289090 100644
--- a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
+++ b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
@@ -1,5 +1,7 @@
package org.apache.maven.shared.invoker;
+import org.junit.Test;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,44 +21,24 @@ package org.apache.maven.shared.invoker;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
+public class AppTest
{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
/**
* Not ending test
+ * @throws InterruptedException
*/
- public void testApp()
+ @Test
+ public void testApp() throws InterruptedException
{
- while (true) {
- // Make sure the whole build will take at least 5 seconds.
- Thread.sleep(5000L);
+ while ( true )
+ {
+ Thread.sleep( 1000L );
}
- assertTrue(true);
+// assertTrue( true );
}
}
--
To stop receiving notification emails like this one, please contact
khmarbaise@apache.org.