1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import complexlib
.ComplexTestCase
;
30 import util
.DynamicClassLoader
;
31 import share
.DescEntry
;
32 import share
.DescGetter
;
33 import share
.ComplexTest
;
34 import java
.util
.Vector
;
35 import share
.LogWriter
;
40 public class ComplexDescGetter
extends DescGetter
43 ComplexTest testClass
;
45 /** Creates new ComplexDescGetter */
46 public ComplexDescGetter()
51 public DescEntry
[] getDescriptionFor(String entry
, String DescPath
,
55 if (entry
.startsWith("-sce"))
57 DescEntry
[] entries
= getScenario(entry
.substring(5), null, debug
);
61 else if (entry
.startsWith("-o"))
63 DescEntry dEntry
= getDescriptionForSingleJob(entry
.substring(3), null, debug
);
66 return new DescEntry
[]
72 System
.out
.println("Could not get a testjob with parameter '" + entry
+ "'");
77 protected DescEntry
getDescriptionForSingleJob(String className
, String descPath
, boolean debug
)
79 DynamicClassLoader dcl
= new DynamicClassLoader();
80 String methodNames
[] = null;
84 System
.out
.println("Searching Class: " + className
);
87 int index
= className
.indexOf("::");
91 // case2: method(param1,param2)
92 // case3: method1(param1,param2),method2(param1,param2)
93 String method
= className
.substring(index
+ 2);
94 className
= className
.substring(0, index
);
95 Vector methods
= new Vector();
97 String
[] split
= method
.split("(?<=\\)),(?=\\w+)");
99 for (int i
= 0; i
< split
.length
; i
++)
101 String meth
= split
[i
];
103 if (meth
.endsWith("()"))
105 meth
= meth
.substring(0, meth
.length() - 2);
111 methodNames
= new String
[methods
.size()];
112 methodNames
= (String
[]) methods
.toArray(methodNames
);
115 // create an instance
118 testClass
= (ComplexTestCase
) dcl
.getInstance(className
);
120 catch (java
.lang
.IllegalArgumentException e
)
122 System
.out
.println("Error while getting description for test '" + className
+ "' as a Complex test.");
125 catch (java
.lang
.ClassCastException e
)
127 System
.out
.println("The given class '" + className
+ "' is not a Complex test.");
134 System
.out
.println("Got test: " + ((Object
) testClass
).toString());
137 String testObjectName
= className
;
138 String
[] testMethodNames
= null;
140 if (testMethodNames
== null)
142 testMethodNames
= testClass
.getTestMethodNames();
144 if (methodNames
!= null)
146 testMethodNames
= methodNames
;
149 DescEntry dEntry
= createTestDesc(testObjectName
, className
, testMethodNames
, null);
155 * Creates a description exntry for the given parameter
156 * @param testObjectName the name of the object
157 * @param className the class name of the class to load
158 * @param testMethodNames list of all methods to test
160 * @return filled description entry
162 public DescEntry
createTestDesc(String testObjectName
, String className
, String
[] testMethodNames
, LogWriter log
)
165 DescEntry dEntry
= new DescEntry();
167 dEntry
.entryName
= testObjectName
;
168 dEntry
.longName
= className
;
169 dEntry
.isOptional
= false;
170 dEntry
.EntryType
= "unit";
171 dEntry
.isToTest
= true;
173 dEntry
.SubEntryCount
= testMethodNames
.length
;
174 dEntry
.SubEntries
= new DescEntry
[dEntry
.SubEntryCount
];
175 for (int i
= 0; i
< dEntry
.SubEntryCount
; i
++)
177 DescEntry aEntry
= new DescEntry();
178 aEntry
.entryName
= testMethodNames
[i
];
179 aEntry
.longName
= testObjectName
+ "::" + aEntry
.entryName
;
180 aEntry
.isOptional
= false;
181 aEntry
.EntryType
= "method";
182 aEntry
.isToTest
= true;
183 dEntry
.SubEntries
[i
] = aEntry
;
190 protected String
[] createScenario(String descPath
, String job
, boolean debug
)
192 return new String
[] {};