206 out = new PrintStream(new BufferedOutputStream(new FileOutputStream(outFile)), true, StandardCharsets.UTF_8.name());
207
208 // read the tests and write them to output
209 list(initialFile);
210 }
211
212 //------------------------------------------------------------------------------------------
213
214 /**
215 * Creates and initializes an instance of a test finder
216 *
217 * @param finder The class name of the required test finder
218 * @param args any args to pass to the TestFinder's init method.
219 * @param ts The testsuite root file
220 * @return The newly created TestFinder.
221 */
222 private TestFinder initializeTestFinder(String finder, String[] args, File ts) throws Fault {
223 TestFinder testFinder;
224
225 try {
226 Class c = Class.forName(finder);
227 testFinder = (TestFinder) (c.newInstance());
228 testFinder.init(args, ts, null);
229 }
230 catch (ClassNotFoundException e) {
231 throw new Fault("Error: Can't find class for TestFinder specified");
232 }
233 catch (InstantiationException e) {
234 throw new Fault("Error: Can't create new instance of TestFinder");
235 }
236 catch (IllegalAccessException e) {
237 throw new Fault("Error: Illegal Access Exception");
238 }
239 catch (TestFinder.Fault e) {
240 throw new Fault("Error: Can't initialize test-finder: " + e.getMessage());
241 }
242
243 return testFinder;
244 }
245
246 //------------------------------------------------------------------------------------------
247
248 private void list(File file) {
249 if (nodes)
250 out.println(file);
251
252 testFinder.read(file);
253 TestDescription[] tests = testFinder.getTests();
254 File[] files = testFinder.getFiles();
255
256 if (tests != null) {
257 for (int i = 0; i < tests.length; i++) {
258 TestDescription td = tests[i];
259 out.println(" " + td.getRootRelativeURL());
260 if (fullTests) {
261 for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) {
262 String key = (String) (iter.next());
263 String value = td.getParameter(key);
264 out.print(" ");
265 out.print(key);
266 pad(key, 15);
267 out.print(value);
268 out.println();
269 }
270 }
271 }
272 }
273
274 if (files != null) {
275 for (int i = 0; i < files.length; i++)
276 list(files[i]);
277 }
278 }
279
280 void pad(String s, int length) {
281 for (int i = s.length(); i < length; i++)
282 out.write(' ');
|
206 out = new PrintStream(new BufferedOutputStream(new FileOutputStream(outFile)), true, StandardCharsets.UTF_8.name());
207
208 // read the tests and write them to output
209 list(initialFile);
210 }
211
212 //------------------------------------------------------------------------------------------
213
214 /**
215 * Creates and initializes an instance of a test finder
216 *
217 * @param finder The class name of the required test finder
218 * @param args any args to pass to the TestFinder's init method.
219 * @param ts The testsuite root file
220 * @return The newly created TestFinder.
221 */
222 private TestFinder initializeTestFinder(String finder, String[] args, File ts) throws Fault {
223 TestFinder testFinder;
224
225 try {
226 Class<?> c = Class.forName(finder);
227 testFinder = (TestFinder) (c.newInstance());
228 testFinder.init(args, ts, null);
229 }
230 catch (ClassNotFoundException e) {
231 throw new Fault("Error: Can't find class for TestFinder specified");
232 }
233 catch (InstantiationException e) {
234 throw new Fault("Error: Can't create new instance of TestFinder");
235 }
236 catch (IllegalAccessException e) {
237 throw new Fault("Error: Illegal Access Exception");
238 }
239 catch (TestFinder.Fault e) {
240 throw new Fault("Error: Can't initialize test-finder: " + e.getMessage());
241 }
242
243 return testFinder;
244 }
245
246 //------------------------------------------------------------------------------------------
247
248 private void list(File file) {
249 if (nodes)
250 out.println(file);
251
252 testFinder.read(file);
253 TestDescription[] tests = testFinder.getTests();
254 File[] files = testFinder.getFiles();
255
256 if (tests != null) {
257 for (int i = 0; i < tests.length; i++) {
258 TestDescription td = tests[i];
259 out.println(" " + td.getRootRelativeURL());
260 if (fullTests) {
261 for (Iterator<String> iter = td.getParameterKeys(); iter.hasNext(); ) {
262 String key = (iter.next());
263 String value = td.getParameter(key);
264 out.print(" ");
265 out.print(key);
266 pad(key, 15);
267 out.print(value);
268 out.println();
269 }
270 }
271 }
272 }
273
274 if (files != null) {
275 for (int i = 0; i < files.length; i++)
276 list(files[i]);
277 }
278 }
279
280 void pad(String s, int length) {
281 for (int i = s.length(); i < length; i++)
282 out.write(' ');
|