1package org.apache.archiva.test.utils;
23/*4 * Copyright 2012 The Apache Software Foundation.5 *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 at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */1819import org.junit.runners.model.FrameworkMethod;
2021import java.util.ArrayList;
22import java.util.Collections;
23import java.util.List;
2425/**26 * Generator of list of random test method27 * -Dorg.apache.archiva.test=n28 * n<=0 default jdk behavior29 * n>0 number of round of random collection30 *31 * @author Eric32 */33publicclassListGenerator34 {
35privatestaticint MAXROUND = 10;
3637privateListGenerator()
38 {
39 }
4041static List<FrameworkMethod> getShuffleList( List<FrameworkMethod> computeTestMethods )
42 {
43int testRound;
44try45 {
46 testRound = Integer.valueOf( System.getProperty( "org.apache.archiva.test", "0" ) );
47 }
48catch ( NumberFormatException nfe )
49 {
50 testRound = 0;
51 }
52if ( testRound <= 0 ) // default list usage53 {
54return computeTestMethods;
55 }
56if ( computeTestMethods == null )
57 {
58returnnull;
59 }
6061 List<FrameworkMethod> generated = new ArrayList<>();
6263 testRound = Math.min( MAXROUND, testRound );
6465for ( int i = 0; i < testRound; i++ )
66 {
67 Collections.shuffle( computeTestMethods );
68 generated.addAll( computeTestMethods );
69 }
70// Collections.sort( generated, new FrameworkMethodComparator() );7172return generated;
73 }
7475/*private static class FrameworkMethodComparator76 implements Comparator<FrameworkMethod>77 {78 public int compare( FrameworkMethod frameworkMethod, FrameworkMethod frameworkMethod1 )79 {80 return frameworkMethod.getName().compareTo( frameworkMethod1.getName() );81 }82 }*/8384 }