bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / runner / complexlib / ShowTargets.java
blob7a8267409af58eb06b57d1a6c8f3540688dfb34f
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package complexlib;
21 import java.util.ArrayList;
23 public class ShowTargets
25 /** Creates a new instance of ShowTargets */
26 public ShowTargets()
30 public static void main( String[] args )
32 ArrayList<String> targets = new ArrayList<String>();
33 ArrayList<String> descs = new ArrayList<String>();
35 targets.add( "run" );
36 descs.add( "runs all complex tests in this module" );
38 int maxTargetLength = 3;
40 for ( int i = 0; i < args.length; ++i )
42 String completePotentialClassName = args[i].replace( '/', '.' );
44 // filter
45 if ( completePotentialClassName.endsWith( ".TestCase" ) )
46 continue;
47 if ( completePotentialClassName.endsWith( ".TestSkeleton" ) )
48 continue;
50 // get the class
51 Class<?> potentialTestClass = null;
52 try { potentialTestClass = Class.forName( completePotentialClassName ); }
53 catch( java.lang.ClassNotFoundException e )
55 continue;
58 // see if it is derived from complexlib.ComplexTestCase
59 Class<?> superClass = potentialTestClass.getSuperclass();
60 while ( superClass != null )
62 if ( superClass.getName().equals( "complexlib.ComplexTestCase" ) )
64 String bareClassName = completePotentialClassName.substring( completePotentialClassName.lastIndexOf( '.' ) + 1 );
65 String target = "run_" + bareClassName;
66 targets.add( target );
67 descs.add( getShortTestDescription( potentialTestClass ) );
69 if ( maxTargetLength < target.length() )
70 maxTargetLength = target.length();
71 break;
73 superClass = superClass.getSuperclass();
77 System.out.println( "possible targets:" );
78 for ( int i=0; i<targets.size(); ++i )
80 // target
81 String target = targets.get(i);
82 // 'tab'
83 System.out.print( " " + target );
84 for ( int s = maxTargetLength - target.length(); s>0; --s )
85 System.out.print( " " );
86 // description
87 System.out.println( " (" + descs.get(i) + ")" );
91 static private String getShortTestDescription( Class<?> _testClass )
93 java.lang.reflect.Method getShortDescriptionMethod = null;
94 try { getShortDescriptionMethod = _testClass.getMethod( "getShortTestDescription", new Class[]{} ); }
95 catch( Exception e ) { }
97 if ( getShortDescriptionMethod != null )
99 try
101 return (String)getShortDescriptionMethod.invoke( null, new Object[]{} );
103 catch( Exception e ) { }
105 return "no description provided by the test";