Line 31
Link Here
|
|
|
31 |
import java.util.HashMap; |
Line 34
Link Here
|
|
|
35 |
import java.util.LinkedList; |
Line 35
Link Here
|
|
|
37 |
import java.util.Map; |
Line 192
Link Here
|
|
|
195 |
// test distribution path |
196 |
public static String testDistLocation; |
197 |
|
198 |
public static class TestType { |
199 |
private String name; |
200 |
private String folder; |
201 |
private String runtimeCP; |
202 |
private String compileCP; |
203 |
|
204 |
public TestType() {} |
205 |
public String getName() { |
206 |
return name; |
207 |
} |
208 |
|
209 |
public void setName(String name) { |
210 |
this.name = name; |
211 |
} |
212 |
|
213 |
public String getFolder() { |
214 |
return folder; |
215 |
} |
216 |
|
217 |
public void setFolder(String folder) { |
218 |
this.folder = folder; |
219 |
} |
220 |
|
221 |
public String getRuntimeCP() { |
222 |
return runtimeCP; |
223 |
} |
224 |
|
225 |
public void setRuntimeCP(String runtimeCP) { |
226 |
this.runtimeCP = runtimeCP; |
227 |
} |
228 |
|
229 |
public String getCompileCP() { |
230 |
return compileCP; |
231 |
} |
232 |
|
233 |
public void setCompileCP(String compileCP) { |
234 |
this.compileCP = compileCP; |
235 |
} |
236 |
|
237 |
} |
238 |
List /*<TestType>*/ testTypes = new LinkedList(); |
239 |
|
240 |
public void addTestType(TestType testType) { |
241 |
testTypes.add(testType); |
242 |
} |
243 |
public void add(TestType testType) { |
244 |
testTypes.add(testType); |
245 |
} |
246 |
|
247 |
|
248 |
private TestType getTestType(String name) { |
249 |
for (int i = 0 ; i < testTypes.size() ; i++) { |
250 |
TestType testType = (TestType) testTypes.get(i); |
251 |
if (testType.getName().equals(name)) { |
252 |
return testType; |
253 |
} |
254 |
} |
255 |
return null; |
256 |
} |
257 |
// // unitest properties |
258 |
// // |
259 |
// private String unitTestFolderProperty ; |
260 |
// private String unitTestCompileClassPathProperty; |
261 |
// private String unitTestRuntimeClassPathProperty; |
262 |
// |
263 |
// public void setUnitTestFolderProperty(String unitTestFolder) { |
264 |
// this.unitTestFolderProperty = unitTestFolder; |
265 |
// } |
266 |
// |
267 |
// public void setUnitTestCompileClassPathProperty(String unitTestCompileClassPathProperty) { |
268 |
// this.unitTestCompileClassPathProperty = unitTestCompileClassPathProperty; |
269 |
// } |
270 |
// |
271 |
// public void setUnitTestRuntimeClassPathProperty(String unitTestRuntimeClassPathProperty) { |
272 |
// this.unitTestRuntimeClassPathProperty = unitTestRuntimeClassPathProperty; |
273 |
// } |
274 |
// |
275 |
// |
276 |
// // qa-functional tests properties |
277 |
// // |
278 |
// private String qaFunctionalTestFolderProperty ; |
279 |
// private String qaFunctionalTestCompileClassPathProperty; |
280 |
// private String qaFunctionalTestRuntimeClassPathProperty; |
281 |
// |
282 |
// public void setQaFunctionalTestFolderProperty(String qaFunctionalTestFolder) { |
283 |
// this.qaFunctionalTestFolderProperty = qaFunctionalTestFolder; |
284 |
// } |
285 |
// |
286 |
// public void setQaFunctionalTestCompileClassPathProperty(String qaFunctionalTestCompileClassPathProperty) { |
287 |
// this.qaFunctionalTestCompileClassPathProperty = qaFunctionalTestCompileClassPathProperty; |
288 |
// } |
289 |
// |
290 |
// public void setQaFunctionalTestRuntimeClassPathProperty(String qaFunctionalTestRuntimeClassPathProperty) { |
291 |
// this.qaFunctionalTestRuntimeClassPathProperty = qaFunctionalTestRuntimeClassPathProperty; |
292 |
// } |
293 |
// |
294 |
|
295 |
|
296 |
|
Line 201
Link Here
|
|
|
306 |
|
Line 279
Link Here
|
279 |
if (moduleDependenciesProperty != null || moduleClassPathProperty != null || moduleRunClassPathProperty != null) { |
385 |
if (moduleDependenciesProperty != null || |
280 |
-- |
386 |
moduleClassPathProperty != null || |
|
|
387 |
moduleRunClassPathProperty != null || |
388 |
testTypes.size() > 0) { |
Line 351
Link Here
|
|
|
460 |
|
461 |
// Test dependecies |
462 |
// |
463 |
if (modules != null) { |
464 |
String testDistLocation = getProject().getProperty(TestDeps.TEST_DIST_VAR); |
465 |
if (testDistLocation == null) { |
466 |
testDistLocation = "${" + TestDeps.TEST_DIST_VAR + "}"; |
467 |
} |
468 |
ParseProjectXml.testDistLocation = testDistLocation; |
469 |
|
470 |
TestDeps testDepss[] = getTestDeps(pDoc,modules,getCodeNameBase(pDoc)); |
471 |
for (int tdIt = 0 ; tdIt < testDepss.length ; tdIt++) { |
472 |
TestDeps td = testDepss[tdIt]; |
473 |
// unit tests |
474 |
TestType testType = getTestType(td.testtype); |
475 |
if (testType!= null ) { |
476 |
if (testType.getFolder() != null) { |
477 |
define (testType.getFolder(),td.getTestFolder()); |
478 |
} |
479 |
if (testType.getCompileCP() != null) { |
480 |
|
481 |
define(testType.getCompileCP(),td.getCompileClassPath()); |
482 |
} |
483 |
if (testType.getRuntimeCP() != null) { |
484 |
define(testType.getRuntimeCP(),td.getRuntimeClassPath()); |
485 |
} |
486 |
|
487 |
} |
488 |
} |
489 |
} |
Line 740
Link Here
|
740 |
|
879 |
|
741 |
-- |
880 |
final class TestDeps { |
|
|
881 |
public static final String UNIT = "unit"; |
882 |
public static final String QA_FUNCTIONAL = "qa-functional"; |
883 |
// unit, qa-functional, performance |
884 |
final String testtype; |
885 |
// all dependecies for the testtype |
886 |
final List /*<TestDep>*/ dependencies = new ArrayList(); |
887 |
// code name base of tested module |
888 |
final String cnb; |
889 |
final ModuleListParser modulesParser; |
890 |
|
891 |
public static final String TEST_DIST_VAR = "test.dist.dir"; |
892 |
public TestDeps(String testtype,String cnb,ModuleListParser modulesParser) { |
893 |
assert modulesParser != null; |
894 |
this.testtype = testtype; |
895 |
this.cnb = cnb; |
896 |
this.modulesParser = modulesParser; |
897 |
} |
898 |
|
899 |
public List/*<String>*/ getFiles(boolean compile) { |
900 |
List/*<String>*/ files = new ArrayList(); |
901 |
for (int dIt = 0 ; dIt < dependencies.size() ; dIt++) { |
902 |
files.addAll(((TestDep)dependencies.get(dIt)).getFiles(compile)); |
903 |
} |
904 |
return files; |
905 |
} |
906 |
public void addDepenency(TestDep dep) { |
907 |
dependencies.add(dep); |
908 |
} |
909 |
|
910 |
private String getTestFolder() { |
911 |
ModuleListParser.Entry entry = modulesParser.findByCodeNameBase(cnb); |
912 |
String sep = File.separator; |
913 |
return ParseProjectXml.testDistLocation + sep + testtype + sep + entry.getClusterName() + sep + cnb.replace('.','-'); |
914 |
} |
915 |
|
916 |
String getCompileClassPath() { |
917 |
return getPath(getFiles(true)); |
918 |
} |
919 |
private String getPath(List/*<String>*/ files) { |
920 |
StringBuffer path = new StringBuffer(); |
921 |
Set/*<String>*/ filesSet = new HashSet(); |
922 |
for (int fIt = 0 ; fIt < files.size() ; fIt++) { |
923 |
String filePath = (String)files.get(fIt); |
924 |
if (!filesSet.contains(filePath)) { |
925 |
if (path.length() > 0) { |
926 |
path.append(File.pathSeparatorChar); |
927 |
} |
928 |
filesSet.add(filePath); |
929 |
path.append(filePath); |
930 |
} |
931 |
} |
932 |
return path.toString(); |
933 |
} |
934 |
|
935 |
String getRuntimeClassPath() { |
936 |
return getPath(getFiles(false)); |
937 |
} |
938 |
|
939 |
|
940 |
} |
941 |
/** Test dependency for module and type |
942 |
*/ |
943 |
final class TestDep { |
944 |
final ModuleListParser modulesParser; |
945 |
// code name base |
946 |
final String cnb; |
947 |
// dependencies on tests of modules |
948 |
final boolean recursive; |
949 |
final boolean test; |
950 |
// runtime classpath |
951 |
final boolean compile; |
952 |
TestDeps testDeps; |
953 |
|
954 |
TestDep (String cnb,ModuleListParser modules, boolean recursive,boolean test, boolean compile,TestDeps testDeps) { |
955 |
this.modulesParser = modules; |
956 |
this.cnb = cnb; |
957 |
this.recursive = recursive; |
958 |
this.test = test; |
959 |
this.testDeps = testDeps; |
960 |
this.compile = compile; |
961 |
} |
962 |
/* get modules dependecies |
963 |
*/ |
964 |
List/*<ModuleListParser.Entry>*/ getModules() { |
965 |
List /*<ModuleListParser.Entry>*/ entries = new ArrayList(); |
966 |
if (!test) { |
967 |
if (recursive ) { |
968 |
Map/*<String,ModuleListParser.Entry>*/ entriesMap = new HashMap(); |
969 |
addRecursiveModules(cnb,entriesMap); |
970 |
entries.addAll(entriesMap.values()); |
971 |
} else { |
972 |
entries.add(modulesParser.findByCodeNameBase(cnb)); |
973 |
} |
974 |
} |
975 |
return entries; |
976 |
|
977 |
} |
978 |
|
979 |
private void addRecursiveModules(String cnd, Map entriesMap) { |
980 |
if (!entriesMap.containsKey(cnd)) { |
981 |
ModuleListParser.Entry entry = modulesParser.findByCodeNameBase(cnd); |
982 |
entriesMap.put(cnd,entry); |
983 |
String cnds[] = entry.getBuildPrerequisites(); |
984 |
// cnds can be null |
985 |
if (cnds != null) { |
986 |
for (int i = 0 ; i < cnds.length ; i++) { |
987 |
addRecursiveModules(cnds[i],entriesMap); |
988 |
} |
989 |
} |
990 |
} |
991 |
} |
992 |
List/*<String>*/ getFiles(boolean compile) { |
993 |
List/*<String>*/ files = new ArrayList(); |
994 |
if (!compile || ( compile && this.compile)) { |
995 |
List /*<ModuleListParser.Entry>*/ modules = getModules(); |
996 |
for (int mIt = 0 ; mIt <modules.size() ; mIt++) { |
997 |
ModuleListParser.Entry entry = (ModuleListParser.Entry)modules.get(mIt); |
998 |
if (entry != null) { |
999 |
files.add(entry.getJar().getAbsolutePath()); |
1000 |
} else { |
1001 |
log("Entry doesn't exist."); |
1002 |
} |
1003 |
} |
1004 |
// get tests files |
1005 |
if (test) { |
1006 |
// get test folder |
1007 |
ModuleListParser.Entry entry = (ModuleListParser.Entry) modulesParser.findByCodeNameBase(cnb); |
1008 |
String sep = File.separator; |
1009 |
String jarPath = ParseProjectXml.testDistLocation + sep + testDeps.testtype + sep + entry.getClusterName() + sep + cnb.replace('.','-') + sep + "tests.jar"; |
1010 |
files.add(jarPath); |
1011 |
} |
1012 |
} |
1013 |
return files; |
1014 |
} |
1015 |
} |
Line 850
Link Here
|
|
|
1125 |
private TestDeps[] getTestDeps(Document pDoc,ModuleListParser modules,String testCnb) { |
1126 |
assert modules != null; |
1127 |
Element cfg = getConfig(pDoc); |
1128 |
List testDepsList = new ArrayList(); |
1129 |
Element pp = XMLUtil.findElement(cfg, "test-dependencies", NBM_NS); |
1130 |
if (pp != null) { |
1131 |
for (Iterator depssIt = XMLUtil.findSubElements(pp).iterator(); depssIt.hasNext();) { |
1132 |
Element depssEl = (Element) depssIt.next(); |
1133 |
String testType = findTextOrNull(depssEl,"name"); |
1134 |
if (testType == null) { |
1135 |
testType = TestDeps.UNIT; // default variant |
1136 |
} |
1137 |
TestDeps testDeps = new TestDeps(testType,testCnb,modules); |
1138 |
testDepsList.add(testDeps); |
1139 |
for (Iterator depsIt = XMLUtil.findSubElements(depssEl).iterator() ; depsIt.hasNext();) { |
1140 |
Element el = (Element) depsIt.next(); |
1141 |
if (el.getTagName().equals("test-dependency")) { |
1142 |
// parse test dep |
1143 |
boolean test = (XMLUtil.findElement(el,"test",NBM_NS) != null);; |
1144 |
String cnb = findTextOrNull(el,"code-name-base"); |
1145 |
boolean recursive = (XMLUtil.findElement(el,"recursive",NBM_NS) != null); |
1146 |
boolean compile = (XMLUtil.findElement(el,"compile-dependency",NBM_NS) != null); |
1147 |
testDeps.addDepenency(new TestDep(cnb, |
1148 |
modules, |
1149 |
recursive, |
1150 |
test, |
1151 |
compile, |
1152 |
testDeps)); |
1153 |
} |
1154 |
|
1155 |
} |
1156 |
} |
1157 |
} |
1158 |
TestDeps testDepss[] = new TestDeps[testDepsList.size()]; |
1159 |
testDepsList.toArray(testDepss); |
1160 |
return testDepss; |
1161 |
} |
1162 |
private static String findTextOrNull(Element parentElement,String elementName) { |
1163 |
Element el = XMLUtil.findElement(parentElement,elementName,NBM_NS); |
1164 |
return (el == null) ? null : |
1165 |
XMLUtil.findText(el); |
1166 |
|
1167 |
} |
1168 |
|