1 package org.apache.archiva.test;
4 * Copyright 2012 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.junit.runners.model.FrameworkMethod;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Comparator;
24 import java.util.List;
29 public class ListGenerator
31 private static int MAXROUND = 1;
33 private ListGenerator()
37 static List<FrameworkMethod> getShuffleList( List<FrameworkMethod> computeTestMethods )
39 String javaSpecVersion = System.getProperty( "java.specification.version" );
40 // 1.6 1.5 version not shuffled to allow build
41 if ( javaSpecVersion.equals( "1.6" ) || javaSpecVersion.equals( "1.5" ) )
43 return computeTestMethods;
45 if ( computeTestMethods == null )
49 List<FrameworkMethod> generated = new ArrayList<FrameworkMethod>( computeTestMethods );
51 Collections.sort( generated, new FrameworkMethodComparator() );
53 // 1.7 and more generated shuffled list
54 // double test method to have more change of failure
55 /*for ( int i = 0; i < MAXROUND; i++ )
57 Collections.shuffle( computeTestMethods );
58 generated.addAll( computeTestMethods );
60 //generated.add( computeTestMethods.get( 0 ) );
62 //Collections.shuffle( computeTestMethods );
63 //generated.addAll( computeTestMethods );
68 private static class FrameworkMethodComparator
69 implements Comparator<FrameworkMethod>
71 public int compare( FrameworkMethod frameworkMethod, FrameworkMethod frameworkMethod1 )
73 return frameworkMethod.getName().compareTo( frameworkMethod1.getName() );