-
Notifications
You must be signed in to change notification settings - Fork 1k
/
XmlSuite.java
executable file
·1149 lines (990 loc) · 31.4 KB
/
XmlSuite.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package org.testng.xml;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.testng.ITestObjectFactory;
import org.testng.TestNG;
import org.testng.collections.Lists;
import org.testng.collections.Maps;
import org.testng.internal.Utils;
import org.testng.reporters.XMLStringBuffer;
import org.testng.xml.dom.OnElement;
import org.testng.xml.dom.OnElementList;
import org.testng.xml.dom.Tag;
import static org.testng.collections.CollectionUtils.hasElements;
import static org.testng.internal.Utils.isStringNotEmpty;
import static org.testng.xml.XmlSuite.ParallelMode.skipDeprecatedValues;
/**
* This class describes the tag <suite> in testng.xml.
*
* @author <a href = "mailto:cedric@beust.com">Cedric Beust</a>
* @author <a href = 'mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
*/
public class XmlSuite implements Serializable, Cloneable {
/** Parallel modes */
public enum ParallelMode {
TESTS("tests", false), METHODS("methods"), CLASSES("classes"), INSTANCES("instances"), NONE("none", false),
@Deprecated TRUE("true"), @Deprecated FALSE("false", false);
private final String name;
private final boolean isParallel;
ParallelMode(String name) {
this(name, true);
}
ParallelMode(String name, boolean isParallel) {
this.name = name;
this.isParallel = isParallel;
}
public static XmlSuite.ParallelMode getValidParallel(String parallel) {
if (parallel == null) {
return null;
}
try {
return XmlSuite.ParallelMode.valueOf(parallel.toUpperCase());
} catch (IllegalArgumentException e) {
return null;
}
}
public static ParallelMode skipDeprecatedValues(ParallelMode parallel) {
if (parallel == ParallelMode.TRUE) {
Utils.log("XmlSuite", 1, "[WARN] 'parallel' value 'true' is deprecated, default value will be used instead: '" + ParallelMode.METHODS + "'.");
return ParallelMode.METHODS;
}
if (parallel == ParallelMode.FALSE) {
Utils.log("XmlSuite", 1, "[WARN] 'parallel' value 'false' is deprecated, default value will be used instead: '" + ParallelMode.NONE + "'.");
return ParallelMode.NONE;
}
return parallel;
}
public boolean isParallel() {
return isParallel;
}
@Override
public String toString() {
return name;
}
}
/** Configuration failure policy options */
public enum FailurePolicy {
SKIP("skip"), CONTINUE("continue");
private final String name;
FailurePolicy(String name) {
this.name = name;
}
public static FailurePolicy getValidPolicy(String policy) {
if (policy == null) {
return null;
}
try {
return XmlSuite.FailurePolicy.valueOf(policy.toUpperCase());
} catch (IllegalArgumentException e) {
return null;
}
}
@Override
public String toString() {
return name;
}
}
private String m_test;
/** The default suite name TODO CQ is this OK as a default name. */
private static final String DEFAULT_SUITE_NAME = "Default Suite";
/** The suite name (defaults to DEFAULT_SUITE_NAME) */
private String m_name = DEFAULT_SUITE_NAME;
/** The suite verbose flag. (0 to 10)*/
public static final Integer DEFAULT_VERBOSE = 1;
private Integer m_verbose = null;
public static final ParallelMode DEFAULT_PARALLEL = ParallelMode.NONE;
private ParallelMode m_parallel = DEFAULT_PARALLEL;
private String m_parentModule = "";
private String m_guiceStage = "";
/** Whether to SKIP or CONTINUE to re-attempt failed configuration methods. */
public static final FailurePolicy DEFAULT_CONFIG_FAILURE_POLICY = FailurePolicy.SKIP;
private FailurePolicy m_configFailurePolicy = DEFAULT_CONFIG_FAILURE_POLICY;
/** JUnit compatibility flag. */
public static final Boolean DEFAULT_JUNIT = Boolean.FALSE;
private Boolean m_isJUnit = DEFAULT_JUNIT;
/** mixed mode flag. */
public static final Boolean DEFAULT_MIXED = Boolean.FALSE;
private Boolean m_isMixed = DEFAULT_MIXED;
public static final Boolean DEFAULT_SKIP_FAILED_INVOCATION_COUNTS = Boolean.FALSE;
private Boolean m_skipFailedInvocationCounts = DEFAULT_SKIP_FAILED_INVOCATION_COUNTS;
/** The thread count. */
public static final Integer DEFAULT_THREAD_COUNT = 5;
private int m_threadCount = DEFAULT_THREAD_COUNT;
/** Thread count for the data provider pool */
public static final Integer DEFAULT_DATA_PROVIDER_THREAD_COUNT = 10;
private int m_dataProviderThreadCount = DEFAULT_DATA_PROVIDER_THREAD_COUNT;
/** By default, a method failing will cause all instances of that class to skip */
public static final Boolean DEFAULT_GROUP_BY_INSTANCES = false;
private Boolean m_groupByInstances = DEFAULT_GROUP_BY_INSTANCES;
public static final Boolean DEFAULT_ALLOW_RETURN_VALUES = Boolean.FALSE;
private Boolean m_allowReturnValues = DEFAULT_ALLOW_RETURN_VALUES;
/** The packages containing test classes. */
private List<XmlPackage> m_xmlPackages = Lists.newArrayList();
/** BeanShell expression. */
private String m_expression = null;
/** Suite level method selectors. */
private List<XmlMethodSelector> m_methodSelectors = Lists.newArrayList();
/** Tests in suite. */
private List<XmlTest> m_tests = Lists.newArrayList();
/** Suite level parameters. */
private Map<String, String> m_parameters = Maps.newHashMap();
/** Name of the XML file */
private String m_fileName;
/** Time out for methods/tests */
private String m_timeOut;
/** List of child XML suite specified using <suite-file> tags */
private List<XmlSuite> m_childSuites = Lists.newArrayList();
/** Parent XML Suite if this suite was specified in another suite using <suite-file> tag */
private XmlSuite m_parentSuite;
private List<String> m_suiteFiles = Lists.newArrayList();
private ITestObjectFactory m_objectFactory;
private List<String> m_listeners = Lists.newArrayList();
private static final long serialVersionUID = 4999962288272750226L;
public static final Boolean DEFAULT_PRESERVE_ORDER = Boolean.TRUE;
private Boolean m_preserveOrder = DEFAULT_PRESERVE_ORDER;
private List<String> m_includedGroups = Lists.newArrayList();
private List<String> m_excludedGroups = Lists.newArrayList();
private XmlMethodSelectors m_xmlMethodSelectors;
/**
* @return the fileName
*/
public String getFileName() {
return m_fileName;
}
/**
* @param fileName the fileName to set
*/
public void setFileName(String fileName) {
m_fileName = fileName;
}
/**
* Returns the parallel mode.
* @return the parallel mode.
*/
public ParallelMode getParallel() {
return m_parallel;
}
public String getParentModule() {
return m_parentModule;
}
public String getGuiceStage() {
return m_guiceStage;
}
public ITestObjectFactory getObjectFactory() {
return m_objectFactory;
}
public void setObjectFactory(ITestObjectFactory objectFactory) {
m_objectFactory = objectFactory;
}
/**
* @deprecated Use #setParallel(XmlSuite.ParallelMode) instead
*/
@Deprecated
public void setParallel(String parallel) {
if (parallel == null) {
setParallel((ParallelMode)null);
} else {
setParallel(XmlSuite.ParallelMode.getValidParallel(parallel));
}
}
/**
* Sets the parallel mode
* @param parallel the parallel mode
*/
public void setParallel(ParallelMode parallel) {
if (parallel == null) {
m_parallel = DEFAULT_PARALLEL;
} else {
m_parallel = skipDeprecatedValues(parallel);
}
}
public void setParentModule(String parentModule) {
m_parentModule = parentModule;
}
public void setGuiceStage(String guiceStage) {
m_guiceStage = guiceStage;
}
/**
* Sets the configuration failure policy.
* @param configFailurePolicy the config failure policy
*/
public void setConfigFailurePolicy(FailurePolicy configFailurePolicy) {
m_configFailurePolicy = configFailurePolicy;
}
/**
* Returns the configuration failure policy.
* @return the configuration failure policy
*/
public FailurePolicy getConfigFailurePolicy() {
return m_configFailurePolicy;
}
/**
* Returns the verbose.
* @return the verbose.
*/
public Integer getVerbose() {
return m_verbose != null ? m_verbose : TestNG.DEFAULT_VERBOSE;
}
/**
* Set the verbose.
* @param verbose The verbose to set.
*/
public void setVerbose(Integer verbose) {
m_verbose = verbose;
}
/**
* Returns the name.
* @return the name.
*/
public String getName() {
return m_name;
}
/**
* Sets the name.
* @param name The name to set.
*/
public void setName(String name) {
m_name = name;
}
/**
* Returns the test.
* @return the test.
*/
public String getTest() {
return m_test;
}
/**
* Returns the tests.
* @return the tests.
*/
public List<XmlTest> getTests() {
return m_tests;
}
// For YAML
public void setTests(List<XmlTest> tests) {
m_tests = tests;
}
/**
* Returns the method selectors.
*
* @return the method selectors.
*/
public List<XmlMethodSelector> getMethodSelectors() {
if (m_xmlMethodSelectors != null) {
return m_xmlMethodSelectors.getMethodSelectors();
} else {
// deprecated
return m_methodSelectors;
}
}
/**
* Sets the method selectors.
*
* @param methodSelectors the method selectors.
*/
public void setMethodSelectors(List<XmlMethodSelector> methodSelectors) {
m_methodSelectors = Lists.newArrayList(methodSelectors);
}
/**
* Updates the list of parameters that apply to this XML suite. This method
* should be invoked any time there is a change in the state of this suite that
* would affect the parameter list.<br>
* NOTE: Currently being invoked after a parent suite is added or if parameters
* for this suite are updated.
*/
private void updateParameters() {
/*
* Whatever parameters are set by user or via XML, should be updated
* using parameters from parent suite, if it exists. Parameters from this
* suite override the same named parameters from parent suite.
*/
if (m_parentSuite != null) {
Set<String> keySet = m_parentSuite.getParameters().keySet();
for (String name : keySet) {
if (!m_parameters.containsKey(name)) {
m_parameters.put(name, m_parentSuite.getParameter(name));
}
}
}
}
/**
* Sets parameters.
* @param parameters the parameters.
*/
public void setParameters(Map<String, String> parameters) {
m_parameters = parameters;
updateParameters();
}
/**
* Gets the parameters that apply to tests in this suite.<br>
* Set of parameters for a suite is appended with parameters from parent suite.
* Also, parameters from this suite override the same named parameters from
* parent suite.
*/
public Map<String, String> getParameters() {
return m_parameters;
}
/**
* @return The parameters defined in this suite and all its XmlTests.
*/
public Map<String, String> getAllParameters() {
Map<String, String> result = Maps.newHashMap();
for (Map.Entry<String, String> entry : m_parameters.entrySet()) {
result.put(entry.getKey(), entry.getValue());
}
for (XmlTest test : getTests()) {
Map<String, String> tp = test.getLocalParameters();
for (Map.Entry<String, String> entry : tp.entrySet()) {
result.put(entry.getKey(), entry.getValue());
}
}
return result;
}
/**
* Returns the parameter defined in this suite only.
* @param name the parameter name.
* @return The parameter defined in this suite only.
*/
public String getParameter(String name) {
return m_parameters.get(name);
}
/**
* @return The threadCount.
*/
public int getThreadCount() {
return m_threadCount;
}
/**
* Set the thread count.
* @param threadCount The thread count to set.
*/
public void setThreadCount(int threadCount) {
m_threadCount = threadCount;
}
/**
* @return The JUnit compatibility flag.
*/
public Boolean isJUnit() {
return m_isJUnit;
}
/**
* Sets the JUnit compatibility flag.
*
* @param isJUnit the JUnit compatibility flag.
*/
public void setJUnit(Boolean isJUnit) {
m_isJUnit = isJUnit;
}
// For YAML
public void setJunit(Boolean j) {
setJUnit(j);
}
public Boolean skipFailedInvocationCounts() {
return m_skipFailedInvocationCounts;
}
public void setSkipFailedInvocationCounts(boolean skip) {
m_skipFailedInvocationCounts = skip;
}
/**
* Sets the XML packages.
*
* @param packages the XML packages.
*/
public void setXmlPackages(List<XmlPackage> packages) {
m_xmlPackages = Lists.newArrayList(packages);
}
/**
* Returns the XML packages.
*
* @return the XML packages.
*/
public List<XmlPackage> getXmlPackages() {
return m_xmlPackages;
}
// For YAML
public List<XmlPackage> getPackages() {
return getXmlPackages();
}
@Tag(name = "method-selectors")
public void setMethodSelectors(XmlMethodSelectors xms) {
m_xmlMethodSelectors = xms;
}
// For YAML
public void setPackages(List<XmlPackage> packages) {
setXmlPackages(packages);
}
/**
* @return A String representation of this XML suite.
*/
public String toXml() {
XMLStringBuffer xsb = new XMLStringBuffer();
xsb.setDocType("suite SYSTEM \"" + Parser.TESTNG_DTD_URL + '\"');
Properties p = new Properties();
p.setProperty("name", getName());
if (getVerbose() != null) {
XmlUtils.setProperty(p, "verbose", getVerbose().toString(), DEFAULT_VERBOSE.toString());
}
final ParallelMode parallel= getParallel();
if(parallel != null && !DEFAULT_PARALLEL.equals(parallel)) {
p.setProperty("parallel", parallel.toString());
}
XmlUtils.setProperty(p, "group-by-instances", String.valueOf(getGroupByInstances()),
DEFAULT_GROUP_BY_INSTANCES.toString());
XmlUtils.setProperty(p, "configfailurepolicy", getConfigFailurePolicy().toString(),
DEFAULT_CONFIG_FAILURE_POLICY.toString());
XmlUtils.setProperty(p, "thread-count", String.valueOf(getThreadCount()),
DEFAULT_THREAD_COUNT.toString());
XmlUtils.setProperty(p, "data-provider-thread-count", String.valueOf(getDataProviderThreadCount()),
DEFAULT_DATA_PROVIDER_THREAD_COUNT.toString());
if (! DEFAULT_JUNIT.equals(m_isJUnit)) {
p.setProperty("junit", m_isJUnit != null ? m_isJUnit.toString() : "false"); // TESTNG-141
}
XmlUtils.setProperty(p, "skipfailedinvocationcounts", m_skipFailedInvocationCounts.toString(),
DEFAULT_SKIP_FAILED_INVOCATION_COUNTS.toString());
if(null != m_objectFactory) {
p.setProperty("object-factory", m_objectFactory.getClass().getName());
}
if (isStringNotEmpty(m_parentModule)) {
p.setProperty("parent-module", getParentModule());
}
if (isStringNotEmpty(m_guiceStage)) {
p.setProperty("guice-stage", getGuiceStage());
}
XmlUtils.setProperty(p, "allow-return-values", String.valueOf(getAllowReturnValues()),
DEFAULT_ALLOW_RETURN_VALUES.toString());
xsb.push("suite", p);
XmlUtils.dumpParameters(xsb, m_parameters);
if (hasElements(m_listeners)) {
xsb.push("listeners");
for (String listenerName: m_listeners) {
Properties listenerProps = new Properties();
listenerProps.setProperty("class-name", listenerName);
xsb.addEmptyElement("listener", listenerProps);
}
xsb.pop("listeners");
}
if (hasElements(getXmlPackages())) {
xsb.push("packages");
for (XmlPackage pack : getXmlPackages()) {
xsb.getStringBuffer().append(pack.toXml(" "));
}
xsb.pop("packages");
}
if (getXmlMethodSelectors() != null) {
xsb.getStringBuffer().append(getXmlMethodSelectors().toXml(" "));
} else {
// deprecated
if (hasElements(getMethodSelectors())) {
xsb.push("method-selectors");
for (XmlMethodSelector selector : getMethodSelectors()) {
xsb.getStringBuffer().append(selector.toXml(" "));
}
xsb.pop("method-selectors");
}
}
List<String> suiteFiles = getSuiteFiles();
if (suiteFiles.size() > 0) {
xsb.push("suite-files");
for (String sf : suiteFiles) {
Properties prop = new Properties();
prop.setProperty("path", sf);
xsb.addEmptyElement("suite-file", prop);
}
xsb.pop("suite-files");
}
List<String> included = getIncludedGroups();
List<String> excluded = getExcludedGroups();
if (hasElements(included) || hasElements(excluded)) {
xsb.push("groups");
xsb.push("run");
for (String g : included) {
xsb.addEmptyElement("include", "name", g);
}
for (String g : excluded) {
xsb.addEmptyElement("exclude", "name", g);
}
xsb.pop("run");
xsb.pop("groups");
}
if (m_xmlGroups != null) {
xsb.getStringBuffer().append(m_xmlGroups.toXml(" "));
}
for (XmlTest test : getTests()) {
xsb.getStringBuffer().append(test.toXml(" "));
}
xsb.pop("suite");
return xsb.toXML();
}
@Tag(name = "method-selectors")
public void setXmlMethodSelectors(XmlMethodSelectors xms) {
m_xmlMethodSelectors = xms;
}
private XmlMethodSelectors getXmlMethodSelectors() {
return m_xmlMethodSelectors;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuffer result = new StringBuffer("[Suite: \"").append( m_name).append( "\" ");
for (XmlTest t : m_tests) {
result.append(" ").append( t.toString()).append(' ');
}
for (XmlMethodSelector ms : m_methodSelectors) {
result.append(" methodSelector:" + ms);
}
result.append(']');
return result.toString();
}
/**
* Logs to System.out.
* @param s the message to log.
*/
private static void ppp(String s) {
System.out.println("[XmlSuite] " + s);
}
/**
* {@inheritDoc}
* Note that this is not a full clone: XmlTest children are not cloned by this
* method.
*/
@Override
public Object clone() {
XmlSuite result = shallowCopy();
result.setExcludedGroups(getExcludedGroups());
result.setIncludedGroups(getIncludedGroups());
result.setGroupByInstances(getGroupByInstances());
result.setGroups(getGroups());
result.setMethodSelectors(getXmlMethodSelectors());
result.setPackages(getPackages());
result.setParentSuite(getParentSuite());
result.setPreserveOrder(getPreserveOrder());
result.setSuiteFiles(getSuiteFiles());
result.setTests(getTests());
result.setXmlMethodSelectors(getXmlMethodSelectors());
return result;
}
/**
* This method returns a shallow cloned version. {@link XmlTest} are not copied by this method.
* @return - A Shallow copied version of {@link XmlSuite}.
*/
public XmlSuite shallowCopy() {
XmlSuite result = new XmlSuite();
result.setName(getName());
result.setFileName(getFileName());
result.setListeners(getListeners());
result.setParallel(getParallel());
result.setParentModule(getParentModule());
result.setGuiceStage(getGuiceStage());
result.setConfigFailurePolicy(getConfigFailurePolicy());
result.setThreadCount(getThreadCount());
result.setDataProviderThreadCount(getDataProviderThreadCount());
result.setParameters(getParameters());
result.setVerbose(getVerbose());
result.setXmlPackages(getXmlPackages());
// result.setBeanShellExpression(getExpression());
result.setMethodSelectors(getMethodSelectors());
result.setJUnit(isJUnit()); // TESTNG-141
result.setSkipFailedInvocationCounts(skipFailedInvocationCounts());
result.setObjectFactory(getObjectFactory());
result.setAllowReturnValues(getAllowReturnValues());
result.setTimeOut(getTimeOut());
return result;
}
/**
* Sets the timeout.
*
* @param timeOut the timeout.
*/
public void setTimeOut(String timeOut) {
m_timeOut = timeOut;
}
/**
* Returns the timeout.
* @return the timeout.
*/
public String getTimeOut() {
return m_timeOut;
}
/**
* Returns the timeout as a long value specifying the default value to be used if
* no timeout was specified.
*
* @param def the the default value to be used if no timeout was specified.
* @return the timeout as a long value specifying the default value to be used if
* no timeout was specified.
*/
public long getTimeOut(long def) {
long result = def;
if (m_timeOut != null) {
result = Long.parseLong(m_timeOut);
}
return result;
}
/**
* Sets the suite files.
*
* @param files the suite files.
*/
public void setSuiteFiles(List<String> files) {
m_suiteFiles = files;
}
/**
* Returns the suite files.
* @return the suite files.
*/
public List<String> getSuiteFiles() {
return m_suiteFiles;
}
public void setListeners(List<String> listeners) {
m_listeners = listeners;
}
public List<String> getListeners() {
if (m_parentSuite != null) {
List<String> listeners = m_parentSuite.getListeners();
for (String listener : listeners) {
if (!m_listeners.contains(listener)) {
m_listeners.add(listener);
}
}
}
return m_listeners;
}
public void setDataProviderThreadCount(int count) {
m_dataProviderThreadCount = count;
}
public int getDataProviderThreadCount() {
// org.testng.CommandLineArgs.DATA_PROVIDER_THREAD_COUNT
String s = System.getProperty("dataproviderthreadcount");
if (s != null) {
try {
int nthreads = Integer.parseInt(s);
return nthreads;
} catch(NumberFormatException nfe) {
System.err.println("Parsing System property 'dataproviderthreadcount': " + nfe);
}
}
return m_dataProviderThreadCount;
}
public void setParentSuite(XmlSuite parentSuite) {
m_parentSuite = parentSuite;
updateParameters();
}
public XmlSuite getParentSuite() {
return m_parentSuite;
}
public List<XmlSuite> getChildSuites() {
return m_childSuites;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
// result = prime * result
// + ((m_childSuites == null) ? 0 : m_childSuites.hashCode());
result = prime
* result
+ ((m_configFailurePolicy == null) ? 0 : m_configFailurePolicy
.hashCode());
result = prime * result + m_dataProviderThreadCount;
result = prime * result
+ ((m_expression == null) ? 0 : m_expression.hashCode());
result = prime * result
+ ((m_fileName == null) ? 0 : m_fileName.hashCode());
result = prime * result
+ ((m_isJUnit == null) ? 0 : m_isJUnit.hashCode());
result = prime * result
+ ((m_listeners == null) ? 0 : m_listeners.hashCode());
result = prime * result
+ ((m_methodSelectors == null) ? 0 : m_methodSelectors.hashCode());
result = prime * result + ((m_name == null) ? 0 : m_name.hashCode());
result = prime * result
+ ((m_objectFactory == null) ? 0 : m_objectFactory.hashCode());
result = prime * result
+ ((m_parallel == null) ? 0 : m_parallel.hashCode());
// result = prime * result
// + ((m_parameters == null) ? 0 : m_parameters.hashCode());
// result = prime * result
// + ((m_parentSuite == null) ? 0 : m_parentSuite.hashCode());
result = prime
* result
+ ((m_skipFailedInvocationCounts == null) ? 0
: m_skipFailedInvocationCounts.hashCode());
result = prime * result
+ ((m_suiteFiles == null) ? 0 : m_suiteFiles.hashCode());
result = prime * result + ((m_test == null) ? 0 : m_test.hashCode());
result = prime * result + ((m_tests == null) ? 0 : m_tests.hashCode());
result = prime * result + m_threadCount;
result = prime * result
+ ((m_timeOut == null) ? 0 : m_timeOut.hashCode());
result = prime * result
+ ((m_verbose == null) ? 0 : m_verbose.hashCode());
result = prime * result
+ ((m_xmlPackages == null) ? 0 : m_xmlPackages.hashCode());
return result;
}
/**
* Used to debug equals() bugs.
*/
static boolean f() {
return false;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return f();
}
if (getClass() != obj.getClass()) {
return f();
}
XmlSuite other = (XmlSuite) obj;
// if (m_childSuites == null) {
// if (other.m_childSuites != null)
// return f();
// } else if (!m_childSuites.equals(other.m_childSuites))
// return f();
if (m_configFailurePolicy == null) {
if (other.m_configFailurePolicy != null) {
return f();
}
} else if (!m_configFailurePolicy.equals(other.m_configFailurePolicy)) {
return f();
}
if (m_dataProviderThreadCount != other.m_dataProviderThreadCount) {
return f();
}
if (m_expression == null) {
if (other.m_expression != null) {
return f();
}
} else if (!m_expression.equals(other.m_expression)) {
return f();
}
if (m_isJUnit == null) {
if (other.m_isJUnit != null) {
return f();
}
} else if (!m_isJUnit.equals(other.m_isJUnit)) {
return f();
}
if (m_listeners == null) {
if (other.m_listeners != null) {
return f();
}
} else if (!m_listeners.equals(other.m_listeners)) {
return f();
}
if (m_methodSelectors == null) {
if (other.m_methodSelectors != null) {
return f();
}
} else if (!m_methodSelectors.equals(other.m_methodSelectors)) {
return f();
}
if (m_name == null) {
if (other.m_name != null) {
return f();
}
} else if (!m_name.equals(other.m_name)) {
return f();
}
if (m_objectFactory == null) {
if (other.m_objectFactory != null) {
return f();
}
} else if (!m_objectFactory.equals(other.m_objectFactory)) {
return f();
}
if (m_parallel == null) {
if (other.m_parallel != null) {
return f();
}
} else if (!m_parallel.equals(other.m_parallel)) {
return f();
}
// if (m_parameters == null) {
// if (other.m_parameters != null) {
// return f();
// }
// } else if (!m_parameters.equals(other.m_parameters)) {
// return f();
// }
// if (m_parentSuite == null) {
// if (other.m_parentSuite != null)
// return f();
// } else if (!m_parentSuite.equals(other.m_parentSuite))
// return f();
if (m_skipFailedInvocationCounts == null) {
if (other.m_skipFailedInvocationCounts != null)
return f();
} else if (!m_skipFailedInvocationCounts
.equals(other.m_skipFailedInvocationCounts))
return f();
if (m_suiteFiles == null) {
if (other.m_suiteFiles != null)
return f();
} else if (!m_suiteFiles.equals(other.m_suiteFiles))
return f();
if (m_test == null) {
if (other.m_test != null)
return f();
} else if (!m_test.equals(other.m_test))
return f();
if (m_tests == null) {
if (other.m_tests != null)
return f();
} else if (!m_tests.equals(other.m_tests))
return f();
if (m_threadCount != other.m_threadCount)
return f();
if (m_timeOut == null) {
if (other.m_timeOut != null)
return f();
} else if (!m_timeOut.equals(other.m_timeOut))
return f();
if (m_verbose == null) {
if (other.m_verbose != null)
return f();
} else if (!m_verbose.equals(other.m_verbose))
return f();
if (m_xmlPackages == null) {
if (other.m_xmlPackages != null)
return f();
} else if (!m_xmlPackages.equals(other.m_xmlPackages))
return f();
return true;
}
/**
* The DTD sometimes forces certain attributes to receive a default value. Such