2525
2626package integration ;
2727
28- import org .htmlunit .html .HtmlAnchor ;
29- import org .htmlunit .html .HtmlPage ;
3028import edu .umd .cs .findbugs .annotations .NonNull ;
3129import hudson .Extension ;
3230import hudson .model .Action ;
4240import hudson .views .WeatherColumn ;
4341import integration .harness .BasicMultiBranchProject ;
4442import integration .harness .BasicMultiBranchProjectFactory ;
45- import java .io .IOException ;
46- import java .util .ArrayList ;
47- import java .util .Arrays ;
48- import java .util .Collections ;
49- import java .util .List ;
5043import jenkins .branch .Branch ;
5144import jenkins .branch .BranchIndexingCause ;
5245import jenkins .branch .BranchSource ;
6558import jenkins .scm .impl .mock .MockSCMNavigator ;
6659import jenkins .scm .impl .mock .MockSCMSource ;
6760import jenkins .scm .impl .mock .MockSCMSourceEvent ;
68- import org .junit .Before ;
69- import org .junit .ClassRule ;
70- import org .junit .Test ;
61+ import org .htmlunit .html .HtmlAnchor ;
62+ import org .htmlunit .html .HtmlPage ;
63+ import org .junit .jupiter .api .BeforeAll ;
64+ import org .junit .jupiter .api .BeforeEach ;
65+ import org .junit .jupiter .api .Test ;
7166import org .jvnet .hudson .test .Issue ;
7267import org .jvnet .hudson .test .JenkinsRule ;
68+ import org .jvnet .hudson .test .junit .jupiter .WithJenkins ;
69+
70+ import java .io .IOException ;
71+ import java .util .ArrayList ;
72+ import java .util .Arrays ;
73+ import java .util .Collections ;
74+ import java .util .List ;
7375
7476import static org .hamcrest .MatcherAssert .assertThat ;
7577import static org .hamcrest .Matchers .allOf ;
8284import static org .hamcrest .Matchers .notNullValue ;
8385import static org .hamcrest .Matchers .nullValue ;
8486
85- public class BrandingTest {
87+ @ WithJenkins
88+ class BrandingTest {
8689
8790 /**
8891 * All tests in this class only create items and do not affect other global configuration, thus we trade test
8992 * execution time for the restriction on only touching items.
9093 */
91- @ ClassRule
92- public static JenkinsRule r = new JenkinsRule ();
94+ private static JenkinsRule r ;
95+
96+ @ BeforeAll
97+ static void setUp (JenkinsRule rule ) {
98+ r = rule ;
99+ }
93100
94- @ Before
95- public void cleanOutAllItems () throws Exception {
101+ @ BeforeEach
102+ void setUp () throws Exception {
96103 for (TopLevelItem i : r .getInstance ().getItems ()) {
97104 i .delete ();
98105 }
99106 }
100107
101108 @ Test
102- public void given_multibranch_when_noSourcesDefined_then_noSourceBrandingPresent () throws Exception {
109+ void given_multibranch_when_noSourcesDefined_then_noSourceBrandingPresent () throws Exception {
103110 try (MockSCMController c = MockSCMController .create ()) {
104111 BasicMultiBranchProject prj = r .jenkins .createProject (BasicMultiBranchProject .class , "foo" );
105112 prj .setCriteria (null );
@@ -108,7 +115,7 @@ public void given_multibranch_when_noSourcesDefined_then_noSourceBrandingPresent
108115 }
109116
110117 @ Test
111- public void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfterIndexing ()
118+ void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfterIndexing ()
112119 throws Exception {
113120 try (MockSCMController c = MockSCMController .create ()) {
114121 c .createRepository ("foo" );
@@ -123,7 +130,7 @@ public void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfter
123130 }
124131
125132 @ Test
126- public void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfterSourceEvent ()
133+ void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfterSourceEvent ()
127134 throws Exception {
128135 try (MockSCMController c = MockSCMController .create ()) {
129136 c .createRepository ("foo" );
@@ -138,7 +145,7 @@ public void given_multibranch_when_sourceDefined_then_sourceBrandingPresentAfter
138145 }
139146
140147 @ Test
141- public void given_multibranch_when_branches_then_branchBrandingPresent ()
148+ void given_multibranch_when_branches_then_branchBrandingPresent ()
142149 throws Exception {
143150 try (MockSCMController c = MockSCMController .create ()) {
144151 c .createRepository ("foo" );
@@ -152,7 +159,7 @@ public void given_multibranch_when_branches_then_branchBrandingPresent()
152159 }
153160
154161 @ Test
155- public void given_multibranch_when_branches_then_runBrandingPresent ()
162+ void given_multibranch_when_branches_then_runBrandingPresent ()
156163 throws Exception {
157164 try (MockSCMController c = MockSCMController .create ()) {
158165 c .createRepository ("foo" );
@@ -169,7 +176,7 @@ public void given_multibranch_when_branches_then_runBrandingPresent()
169176
170177 @ Test
171178 @ Issue ("JENKINS-48090" )
172- public void given_multibranch_when_runBrandingIncludesAdditionalCauses_then_causesMerged () throws Exception {
179+ void given_multibranch_when_runBrandingIncludesAdditionalCauses_then_causesMerged () throws Exception {
173180 try (MockSCMController c = MockSCMController .create ()) {
174181 c .createRepository ("foo" );
175182 BasicMultiBranchProject prj = r .jenkins .createProject (BasicMultiBranchProject .class , "foo" );
@@ -188,15 +195,15 @@ public void given_multibranch_when_runBrandingIncludesAdditionalCauses_then_caus
188195 }
189196
190197 @ Test
191- public void given_orgFolder_when_noNavigatorsDefined_then_noNavigatorBrandingPresent () throws Exception {
198+ void given_orgFolder_when_noNavigatorsDefined_then_noNavigatorBrandingPresent () throws Exception {
192199 try (MockSCMController c = MockSCMController .create ()) {
193200 OrganizationFolder prj = r .jenkins .createProject (OrganizationFolder .class , "foo" );
194201 assertThat (prj .getAction (MockSCMLink .class ), nullValue ());
195202 }
196203 }
197204
198205 @ Test
199- public void given_multibranch_when_sourceHasNonSafeNames_then_branchDisplayNameNotMangled () throws Exception {
206+ void given_multibranch_when_sourceHasNonSafeNames_then_branchDisplayNameNotMangled () throws Exception {
200207 try (MockSCMController c = MockSCMController .create ()) {
201208 c .createRepository ("foo" );
202209 c .createBranch ("foo" , "." );
@@ -258,7 +265,7 @@ public void given_multibranch_when_sourceHasNonSafeNames_then_branchDisplayNameN
258265 }
259266
260267 @ Test
261- public void given_multibranch_when_sourceHasI18nNames_then_branchDisplayNameNotMangled () throws Exception {
268+ void given_multibranch_when_sourceHasI18nNames_then_branchDisplayNameNotMangled () throws Exception {
262269 try (MockSCMController c = MockSCMController .create ()) {
263270 c .createRepository ("foo" );
264271 c .createBranch ("foo" ,"特征/新" );
@@ -347,7 +354,7 @@ public void given_multibranch_when_sourceHasI18nNames_then_branchDisplayNameNotM
347354 }
348355
349356 @ Test
350- public void given_orgFolder_when_navigatorDefined_then_navigatorBrandingPresentAfterIndexing ()
357+ void given_orgFolder_when_navigatorDefined_then_navigatorBrandingPresentAfterIndexing ()
351358 throws Exception {
352359 try (MockSCMController c = MockSCMController .create ()) {
353360 c .createRepository ("foo" );
@@ -362,7 +369,7 @@ public void given_orgFolder_when_navigatorDefined_then_navigatorBrandingPresentA
362369 }
363370
364371 @ Test
365- public void given_orgFolderWithI18nRepos_when_indexing_then_repoNamesEncoded ()
372+ void given_orgFolderWithI18nRepos_when_indexing_then_repoNamesEncoded ()
366373 throws Exception {
367374 try (MockSCMController c = MockSCMController .create ()) {
368375 c .createRepository ("England" );
@@ -437,7 +444,7 @@ public void given_orgFolderWithI18nRepos_when_indexing_then_repoNamesEncoded()
437444 }
438445
439446 @ Test
440- public void given_orgFolderWithNonSafeRepos_when_indexing_then_repoNamesEncoded ()
447+ void given_orgFolderWithNonSafeRepos_when_indexing_then_repoNamesEncoded ()
441448 throws Exception {
442449 try (MockSCMController c = MockSCMController .create ()) {
443450 c .createRepository ("a?" );
@@ -482,7 +489,7 @@ public void given_orgFolderWithNonSafeRepos_when_indexing_then_repoNamesEncoded(
482489 }
483490
484491 @ Test
485- public void given_orgFolder_when_navigatorDefined_then_sourceBrandingPresentAfterIndexing ()
492+ void given_orgFolder_when_navigatorDefined_then_sourceBrandingPresentAfterIndexing ()
486493 throws Exception {
487494 try (MockSCMController c = MockSCMController .create ()) {
488495 c .createRepository ("foo" );
@@ -497,7 +504,7 @@ public void given_orgFolder_when_navigatorDefined_then_sourceBrandingPresentAfte
497504 }
498505
499506 @ Test
500- public void given_orgFolder_when_navigatorDefined_then_branchBrandingPresentAfterIndexing ()
507+ void given_orgFolder_when_navigatorDefined_then_branchBrandingPresentAfterIndexing ()
501508 throws Exception {
502509 try (MockSCMController c = MockSCMController .create ()) {
503510 c .createRepository ("foo" );
@@ -513,7 +520,7 @@ public void given_orgFolder_when_navigatorDefined_then_branchBrandingPresentAfte
513520 }
514521
515522 @ Test
516- public void given_orgFolder_when_navigatorDefined_then_revisionBrandingPresentAfterIndexing ()
523+ void given_orgFolder_when_navigatorDefined_then_revisionBrandingPresentAfterIndexing ()
517524 throws Exception {
518525 try (MockSCMController c = MockSCMController .create ()) {
519526 c .createRepository ("foo" );
@@ -529,7 +536,7 @@ public void given_orgFolder_when_navigatorDefined_then_revisionBrandingPresentAf
529536 }
530537
531538 @ Test
532- public void given_multibranch_when_decoratedSourceDefined_then_descriptionPresentAfterIndexing ()
539+ void given_multibranch_when_decoratedSourceDefined_then_descriptionPresentAfterIndexing ()
533540 throws Exception {
534541 try (MockSCMController c = MockSCMController .create ()) {
535542 c .createRepository ("foo" );
@@ -545,7 +552,7 @@ public void given_multibranch_when_decoratedSourceDefined_then_descriptionPresen
545552 }
546553
547554 @ Test
548- public void given_multibranch_when_decoratedSourceDefined_then_displayNamePresentAfterIndexing ()
555+ void given_multibranch_when_decoratedSourceDefined_then_displayNamePresentAfterIndexing ()
549556 throws Exception {
550557 try (MockSCMController c = MockSCMController .create ()) {
551558 c .createRepository ("foo" );
@@ -564,7 +571,7 @@ public void given_multibranch_when_decoratedSourceDefined_then_displayNamePresen
564571 }
565572
566573 @ Test
567- public void given_orgFolder_when_decoratedSourceDefined_then_descriptionLinkPresentAfterIndexing ()
574+ void given_orgFolder_when_decoratedSourceDefined_then_descriptionLinkPresentAfterIndexing ()
568575 throws Exception {
569576 try (MockSCMController c = MockSCMController .create ()) {
570577 c .createRepository ("foo" );
@@ -588,7 +595,7 @@ public void given_orgFolder_when_decoratedSourceDefined_then_descriptionLinkPres
588595 }
589596
590597 @ Test
591- public void given_multibranch_when_decoratedSourceDefined_then_folderIconPresentAfterIndexing ()
598+ void given_multibranch_when_decoratedSourceDefined_then_folderIconPresentAfterIndexing ()
592599 throws Exception {
593600 try (MockSCMController c = MockSCMController .create ()) {
594601 c .createRepository ("foo" );
@@ -604,7 +611,7 @@ public void given_multibranch_when_decoratedSourceDefined_then_folderIconPresent
604611 }
605612
606613 @ Test
607- public void given_orgFolder_when_decoratedOrganizationDefined_then_folderIconPresentAfterIndexing ()
614+ void given_orgFolder_when_decoratedOrganizationDefined_then_folderIconPresentAfterIndexing ()
608615 throws Exception {
609616 try (MockSCMController c = MockSCMController .create ()) {
610617 c .createRepository ("foo" );
@@ -620,7 +627,7 @@ public void given_orgFolder_when_decoratedOrganizationDefined_then_folderIconPre
620627 }
621628
622629 @ Test
623- public void given_orgFolder_when_decoratedOrganizationDefined_then_displayNamePresentAfterIndexing ()
630+ void given_orgFolder_when_decoratedOrganizationDefined_then_displayNamePresentAfterIndexing ()
624631 throws Exception {
625632 try (MockSCMController c = MockSCMController .create ()) {
626633 c .createRepository ("foo" );
@@ -636,7 +643,7 @@ public void given_orgFolder_when_decoratedOrganizationDefined_then_displayNamePr
636643 }
637644
638645 @ Test
639- public void given_orgFolder_when_decoratedOrganizationDefined_then_descriptionLinkPresentAfterIndexing ()
646+ void given_orgFolder_when_decoratedOrganizationDefined_then_descriptionLinkPresentAfterIndexing ()
640647 throws Exception {
641648 try (MockSCMController c = MockSCMController .create ()) {
642649 c .createRepository ("foo" );
0 commit comments