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
;
22 import java
.util
.ArrayList
;
23 import java
.util
.StringTokenizer
;
27 * Base Interface to get a description for a given TestJob
30 public abstract class DescGetter
33 public abstract DescEntry
[] getDescriptionFor(String entry
,
37 protected abstract DescEntry
getDescriptionForSingleJob(String job
,
41 protected abstract String
[] createScenario(String descPath
, String job
,
44 protected DescEntry
[] getScenario(String url
, String descPath
,
47 ArrayList
<DescEntry
> entryList
= new ArrayList
<DescEntry
>();
49 BufferedReader scenario
= null;
50 DescEntry
[] entries
= null;
54 scenario
= new BufferedReader(new FileReader(url
));
56 catch (java
.io
.FileNotFoundException fnfe
)
58 System
.out
.println("Couldn't find file " + url
);
67 if (line
.startsWith("-o"))
69 String job
= line
.substring(3, line
.length()).trim();
71 // special in case several Interfaces are given comma separated
72 if (job
.indexOf(",") < 0)
74 aEntry
= getDescriptionForSingleJob(job
, descPath
,
79 ArrayList
<String
> subs
= getSubInterfaces(job
);
80 String partjob
= job
.substring(0, job
.indexOf(",")).trim();
81 aEntry
= getDescriptionForSingleJob(partjob
, descPath
,
86 for (int i
= 0; i
< aEntry
.SubEntryCount
; i
++)
88 String subEntry
= aEntry
.SubEntries
[i
].longName
;
89 int cpLength
= aEntry
.longName
.length();
90 subEntry
= subEntry
.substring(cpLength
+ 2,
93 if (subs
.contains(subEntry
))
95 aEntry
.SubEntries
[i
].isToTest
= true;
100 // DescEntry aEntry = getDescriptionForSingleJob(
101 // line.substring(3).trim(), descPath,
105 entryList
.add(aEntry
);
108 else if (line
.startsWith("-sce"))
110 DescEntry
[] subs
= getScenario(line
.substring(5,
111 line
.length()).trim(), descPath
,
114 for (int i
= 0; i
< subs
.length
; i
++)
116 entryList
.add(subs
[i
]);
119 else if (line
.startsWith("-p"))
121 String
[] perModule
= createScenario(descPath
,
122 line
.substring(3).trim(), debug
);
124 for (int i
= 0; i
< perModule
.length
; i
++)
126 DescEntry aEntry
= getDescriptionForSingleJob(
127 perModule
[i
].substring(3).trim(),
131 entryList
.add(aEntry
);
136 line
= scenario
.readLine();
138 catch (java
.io
.IOException ioe
)
142 System
.out
.println("Exception while reading scenario");
151 catch (java
.io
.IOException ioe
)
155 System
.out
.println("Exception while closeing scenario");
159 if (entryList
.size() == 0)
163 entries
= new DescEntry
[entryList
.size()];
164 entries
= entryList
.toArray(entries
);
169 protected ArrayList
<String
> getSubInterfaces(String job
)
171 ArrayList
<String
> namesList
= new ArrayList
<String
>();
172 StringTokenizer st
= new StringTokenizer(job
, ",");
174 for (; st
.hasMoreTokens();)
176 String token
= st
.nextToken();
178 if (token
.indexOf(".") < 0)
180 namesList
.add(token
);