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 .
20 import java
.io
.BufferedReader
;
21 import java
.io
.FileReader
;
23 import java
.util
.ArrayList
;
24 import java
.util
.Arrays
;
25 import java
.util
.StringTokenizer
;
29 * Base Interface to get a description for a given TestJob
32 public abstract class DescGetter
35 public abstract DescEntry
[] getDescriptionFor(String entry
,
39 protected abstract DescEntry
getDescriptionForSingleJob(String job
,
43 protected abstract String
[] createScenario(String descPath
, String job
,
46 protected DescEntry
[] getScenario(String url
, String descPath
,
49 ArrayList
<DescEntry
> entryList
= new ArrayList
<DescEntry
>();
51 BufferedReader scenario
= null;
52 DescEntry
[] entries
= null;
56 scenario
= new BufferedReader(new FileReader(url
));
58 catch (java
.io
.FileNotFoundException fnfe
)
60 System
.out
.println("Couldn't find file " + url
);
69 if (line
.startsWith("-o"))
71 String job
= line
.substring(3, line
.length()).trim();
73 // special in case several Interfaces are given comma separated
74 if (job
.indexOf(',') < 0)
76 aEntry
= getDescriptionForSingleJob(job
, descPath
,
81 ArrayList
<String
> subs
= getSubInterfaces(job
);
82 String partjob
= job
.substring(0, job
.indexOf(',')).trim();
83 aEntry
= getDescriptionForSingleJob(partjob
, descPath
,
88 for (int i
= 0; i
< aEntry
.SubEntryCount
; i
++)
90 String subEntry
= aEntry
.SubEntries
[i
].longName
;
91 int cpLength
= aEntry
.longName
.length();
92 subEntry
= subEntry
.substring(cpLength
+ 2,
95 if (subs
.contains(subEntry
))
97 aEntry
.SubEntries
[i
].isToTest
= true;
104 entryList
.add(aEntry
);
107 else if (line
.startsWith("-sce"))
109 DescEntry
[] subs
= getScenario(line
.substring(5,
110 line
.length()).trim(), descPath
,
113 entryList
.addAll(Arrays
.asList(subs
));
115 else if (line
.startsWith("-p"))
117 String
[] perModule
= createScenario(descPath
,
118 line
.substring(3).trim(), debug
);
120 for (int i
= 0; i
< perModule
.length
; i
++)
122 DescEntry aEntry
= getDescriptionForSingleJob(
123 perModule
[i
].substring(3).trim(),
127 entryList
.add(aEntry
);
132 line
= scenario
.readLine();
134 catch (java
.io
.IOException ioe
)
138 System
.out
.println("Exception while reading scenario");
147 catch (java
.io
.IOException ioe
)
151 System
.out
.println("Exception while closing scenario");
155 if (entryList
.isEmpty())
159 entries
= new DescEntry
[entryList
.size()];
160 entries
= entryList
.toArray(entries
);
165 protected ArrayList
<String
> getSubInterfaces(String job
)
167 ArrayList
<String
> namesList
= new ArrayList
<String
>();
168 StringTokenizer st
= new StringTokenizer(job
, ",");
170 while (st
.hasMoreTokens())
172 String token
= st
.nextToken();
174 if (token
.indexOf('.') < 0)
176 namesList
.add(token
);