summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-test-utils
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-07-02 13:44:59 +0000
committerOlivier Lamy <olamy@apache.org>2012-07-02 13:44:59 +0000
commit65795c5962fea897c5ffaaddd35ed7bfd039cc46 (patch)
tree9471e5c8e143190daa9f3f69d0bb61d627ea8fc0 /archiva-modules/archiva-base/archiva-test-utils
parent9062fa612ff29b786e0741e7285d061ac15577be (diff)
downloadarchiva-65795c5962fea897c5ffaaddd35ed7bfd039cc46.tar.gz
archiva-65795c5962fea897c5ffaaddd35ed7bfd039cc46.zip
[MRM-1638] Improve unit test for archiva build
Submitted by Eric Barboni. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1356221 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-test-utils')
-rw-r--r--archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ListGenerator.java41
1 files changed, 24 insertions, 17 deletions
diff --git a/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ListGenerator.java b/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ListGenerator.java
index 4b6916d10..71c9a9efc 100644
--- a/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ListGenerator.java
+++ b/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ListGenerator.java
@@ -20,15 +20,19 @@ import org.junit.runners.model.FrameworkMethod;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
/**
+ * Generator of list of random test method
+ * -Dorg.apache.archiva.test=n
+ * n<=0 default jdk behavior
+ * n>0 number of round of random collection
+ *
* @author Eric
*/
public class ListGenerator
{
- private static int MAXROUND = 1;
+ private static int MAXROUND = 10;
private ListGenerator()
{
@@ -36,9 +40,16 @@ public class ListGenerator
static List<FrameworkMethod> getShuffleList( List<FrameworkMethod> computeTestMethods )
{
- String javaSpecVersion = System.getProperty( "java.specification.version" );
- // 1.6 1.5 version not shuffled to allow build
- if ( javaSpecVersion.equals( "1.6" ) || javaSpecVersion.equals( "1.5" ) )
+ int testRound;
+ try
+ {
+ testRound = Integer.valueOf( System.getProperty( "org.apache.archiva.test", "0" ) );
+ }
+ catch ( NumberFormatException nfe )
+ {
+ testRound = 0;
+ }
+ if ( testRound <= 0 ) // default list usage
{
return computeTestMethods;
}
@@ -46,32 +57,28 @@ public class ListGenerator
{
return null;
}
- List<FrameworkMethod> generated = new ArrayList<FrameworkMethod>( computeTestMethods );
- Collections.sort( generated, new FrameworkMethodComparator() );
+ List<FrameworkMethod> generated = new ArrayList<FrameworkMethod>();
- // 1.7 and more generated shuffled list
- // double test method to have more change of failure
- /*for ( int i = 0; i < MAXROUND; i++ )
+ testRound = Math.min( MAXROUND, testRound );
+
+ for ( int i = 0; i < testRound; i++ )
{
Collections.shuffle( computeTestMethods );
generated.addAll( computeTestMethods );
- }*/
- //generated.add( computeTestMethods.get( 0 ) );
-
- //Collections.shuffle( computeTestMethods );
- //generated.addAll( computeTestMethods );
+ }
+ // Collections.sort( generated, new FrameworkMethodComparator() );
return generated;
}
- private static class FrameworkMethodComparator
+ /*private static class FrameworkMethodComparator
implements Comparator<FrameworkMethod>
{
public int compare( FrameworkMethod frameworkMethod, FrameworkMethod frameworkMethod1 )
{
return frameworkMethod.getName().compareTo( frameworkMethod1.getName() );
}
- }
+ }*/
}