File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -1209,9 +1209,11 @@ public List<ISuite> runSuitesLocally() {
12091209 // Create a map with XmlSuite as key and corresponding SuiteRunner as value
12101210 for (XmlSuite xmlSuite : m_suites ) {
12111211 if (m_configuration .isShareThreadPoolForDataProviders ()) {
1212+ abortIfUsingGraphThreadPoolExecutor ("Shared thread-pool for data providers" );
12121213 xmlSuite .setShareThreadPoolForDataProviders (true );
12131214 }
12141215 if (m_configuration .useGlobalThreadPool ()) {
1216+ abortIfUsingGraphThreadPoolExecutor ("Global thread-pool" );
12151217 xmlSuite .shouldUseGlobalThreadPool (true );
12161218 }
12171219 createSuiteRunners (suiteRunnerMap , xmlSuite );
@@ -1262,6 +1264,13 @@ private static void error(String s) {
12621264 LOGGER .error (s );
12631265 }
12641266
1267+ private static void abortIfUsingGraphThreadPoolExecutor (String prefix ) {
1268+ if (RuntimeBehavior .favourCustomThreadPoolExecutor ()) {
1269+ throw new UnsupportedOperationException (
1270+ prefix + " is NOT COMPATIBLE with TestNG's custom thread pool executor" );
1271+ }
1272+ }
1273+
12651274 /**
12661275 * @return the verbose level, checking in order: the verbose level on the suite, the verbose level
12671276 * on the TestNG object, or 1.
Original file line number Diff line number Diff line change 1818import org .testng .annotations .DataProvider ;
1919import org .testng .annotations .Test ;
2020import org .testng .collections .Lists ;
21+ import org .testng .internal .RuntimeBehavior ;
2122import org .testng .internal .collections .Pair ;
2223import org .testng .internal .reflect .MethodMatcherException ;
2324import org .testng .xml .XmlClass ;
@@ -609,6 +610,20 @@ public void ensureSequentialDataProviderWithRetryAnalyserWorks() {
609610 runTest (false );
610611 }
611612
613+ @ Test (
614+ description = "GITHUB-2980" ,
615+ expectedExceptions = UnsupportedOperationException .class ,
616+ expectedExceptionsMessageRegExp =
617+ "Shared thread-pool for data providers is NOT COMPATIBLE with TestNG's custom thread pool executor" )
618+ public void ensureErrorShownWhenUsedWithGraphThreadPoolExecutor () {
619+ try {
620+ System .setProperty (RuntimeBehavior .FAVOR_CUSTOM_THREAD_POOL_EXECUTOR , "true" );
621+ runDataProviderTest (true );
622+ } finally {
623+ System .setProperty (RuntimeBehavior .FAVOR_CUSTOM_THREAD_POOL_EXECUTOR , "false" );
624+ }
625+ }
626+
612627 @ Test (description = "GITHUB-2980" , dataProvider = "dataProviderForIssue2980" )
613628 public void ensureWeCanShareThreadPoolForDataProviders (
614629 boolean flag , Pair <List <String >, Integer > pair ) {
Original file line number Diff line number Diff line change 99import org .testng .TestNG ;
1010import org .testng .annotations .AfterMethod ;
1111import org .testng .annotations .Test ;
12+ import org .testng .internal .RuntimeBehavior ;
1213import org .testng .xml .XmlSuite ;
1314import test .SimpleBaseTest ;
1415import test .thread .issue2019 .TestClassSample ;
@@ -37,6 +38,20 @@ public void ensureCommonThreadPoolIsNotUsed() {
3738 .hasSizeGreaterThanOrEqualTo (3 );
3839 }
3940
41+ @ Test (
42+ description = "GITHUB-2019" ,
43+ expectedExceptions = UnsupportedOperationException .class ,
44+ expectedExceptionsMessageRegExp =
45+ "Global thread-pool is NOT COMPATIBLE with TestNG's custom thread pool executor" )
46+ public void ensureErrorShownWhenUsedWithGraphThreadPoolExecutor () {
47+ try {
48+ System .setProperty (RuntimeBehavior .FAVOR_CUSTOM_THREAD_POOL_EXECUTOR , "true" );
49+ runSimpleTest (true );
50+ } finally {
51+ System .setProperty (RuntimeBehavior .FAVOR_CUSTOM_THREAD_POOL_EXECUTOR , "false" );
52+ }
53+ }
54+
4055 private static List <Long > runSimpleTest (boolean useSharedGlobalThreadPool ) {
4156 TestNG testng = create (TestClassSample .class );
4257 testng .shouldUseGlobalThreadPool (useSharedGlobalThreadPool );
You can’t perform that action at this time.
0 commit comments