|
11 | 11 | import java.net.URISyntaxException; |
12 | 12 | import java.net.URL; |
13 | 13 | import java.util.*; |
14 | | - |
| 14 | +import java.util.concurrent.ExecutionException; |
15 | 15 | import com.gargoylesoftware.htmlunit.html.HtmlInput; |
16 | 16 | import org.junit.After; |
17 | 17 | import org.junit.Assert; |
@@ -524,4 +524,135 @@ public void verifySystemTempDirDeleted() throws Exception { |
524 | 524 | FreeStyleBuild build = project.scheduleBuild2(0).get(); |
525 | 525 | jenkins.assertLogContains("rmdir(tmpDir,'s')", build); |
526 | 526 | } |
| 527 | + |
| 528 | + /* |
| 529 | + * Test To verify if Logging level is set correctly |
| 530 | + * |
| 531 | + */ |
| 532 | + |
| 533 | + @Test |
| 534 | + public void verifyLoggingLevelSet() throws Exception { |
| 535 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 536 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 537 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 538 | + Map<String, String> logginggLevel = new HashMap<String, String>(); |
| 539 | + logginggLevel.put("None", "'LoggingLevel', 0"); |
| 540 | + logginggLevel.put("Terse", "'LoggingLevel', 1"); |
| 541 | + logginggLevel.put("Concise", "'LoggingLevel', 2"); |
| 542 | + logginggLevel.put("Detailed", "'LoggingLevel', 3"); |
| 543 | + logginggLevel.put("Verbose", "'LoggingLevel', 4"); |
| 544 | + logginggLevel.forEach((key, val) -> { |
| 545 | + testBuilder.setLoggingLevel(key); |
| 546 | + project.getBuildersList().add(this.testBuilder); |
| 547 | + FreeStyleBuild build; |
| 548 | + try { |
| 549 | + build = project.scheduleBuild2(0).get(); |
| 550 | + jenkins.assertLogContains(val, build); |
| 551 | + } catch (InterruptedException | ExecutionException | IOException e) { |
| 552 | + System.out.println("Build Failed, refer logs for details"); |
| 553 | + e.printStackTrace(); |
| 554 | + } |
| 555 | + }); |
| 556 | + } |
| 557 | + |
| 558 | + /* |
| 559 | + * Test To verify if Output Detail is set correctly |
| 560 | + * |
| 561 | + */ |
| 562 | + |
| 563 | + @Test |
| 564 | + public void verifyOutputDetailSet() throws Exception { |
| 565 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 566 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 567 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 568 | + testBuilder.setLoggingLevel("None"); |
| 569 | + Map<String, String> outputDetail = new HashMap<String, String>(); |
| 570 | + outputDetail.put("none", "'OutputDetail', 0"); |
| 571 | + outputDetail.put("terse", "'OutputDetail', 1"); |
| 572 | + outputDetail.put("concise", "'OutputDetail', 2"); |
| 573 | + outputDetail.put("detailed", "'OutputDetail', 3"); |
| 574 | + outputDetail.put("verbose", "'OutputDetail', 4"); |
| 575 | + outputDetail.forEach((key, val) -> { |
| 576 | + testBuilder.setOutputDetail(key); |
| 577 | + project.getBuildersList().add(this.testBuilder); |
| 578 | + FreeStyleBuild build; |
| 579 | + try { |
| 580 | + build = project.scheduleBuild2(0).get(); |
| 581 | + jenkins.assertLogContains(val, build); |
| 582 | + } catch (InterruptedException | ExecutionException | IOException e) { |
| 583 | + System.out.println("Build Failed, refer logs for details"); |
| 584 | + e.printStackTrace(); |
| 585 | + } |
| 586 | + }); |
| 587 | + } |
| 588 | + |
| 589 | + /* |
| 590 | + * Test To verify when Strict option set |
| 591 | + * |
| 592 | + */ |
| 593 | + |
| 594 | + @Test |
| 595 | + public void verifyStrictSet() throws Exception { |
| 596 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 597 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 598 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 599 | + testBuilder.setLoggingLevel("None"); |
| 600 | + testBuilder.setStrict(true); |
| 601 | + project.getBuildersList().add(this.testBuilder); |
| 602 | + FreeStyleBuild build = project.scheduleBuild2(0).get(); |
| 603 | + jenkins.assertLogContains("FailOnWarningsPlugin", build); |
| 604 | + |
| 605 | + } |
| 606 | + |
| 607 | + /* |
| 608 | + * Test To verify when Strict option not set |
| 609 | + * |
| 610 | + */ |
| 611 | + |
| 612 | + @Test |
| 613 | + public void verifyStrictNotSet() throws Exception { |
| 614 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 615 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 616 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 617 | + testBuilder.setLoggingLevel("None"); |
| 618 | + testBuilder.setStrict(false); |
| 619 | + project.getBuildersList().add(this.testBuilder); |
| 620 | + FreeStyleBuild build = project.scheduleBuild2(0).get(); |
| 621 | + jenkins.assertLogNotContains("FailOnWarningsPlugin", build); |
| 622 | + |
| 623 | + } |
| 624 | + |
| 625 | + /* |
| 626 | + * Test To verify when Run in Parallel option is set |
| 627 | + * |
| 628 | + */ |
| 629 | + |
| 630 | + @Test |
| 631 | + public void verifyRunParallelSet() throws Exception { |
| 632 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 633 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 634 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 635 | + testBuilder.setLoggingLevel("None"); |
| 636 | + testBuilder.setUseParallel(true); |
| 637 | + project.getBuildersList().add(this.testBuilder); |
| 638 | + FreeStyleBuild build = project.scheduleBuild2(0).get(); |
| 639 | + jenkins.assertLogContains("runInParallel", build); |
| 640 | + } |
| 641 | + |
| 642 | + /* |
| 643 | + * Test To verify when Run in Parallel option is set |
| 644 | + * |
| 645 | + */ |
| 646 | + |
| 647 | + @Test |
| 648 | + public void verifyRunParallelNotSet() throws Exception { |
| 649 | + this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent( |
| 650 | + Message.getValue("matlab.custom.location"), getMatlabroot("R2018b"))); |
| 651 | + project.getBuildWrappersList().add(this.buildWrapper); |
| 652 | + testBuilder.setLoggingLevel("None"); |
| 653 | + testBuilder.setUseParallel(false); |
| 654 | + project.getBuildersList().add(this.testBuilder); |
| 655 | + FreeStyleBuild build = project.scheduleBuild2(0).get(); |
| 656 | + jenkins.assertLogNotContains("runInParallel", build); |
| 657 | + } |
527 | 658 | } |
0 commit comments