2727import static org .hamcrest .MatcherAssert .assertThat ;
2828import static org .hamcrest .Matchers .containsString ;
2929import static org .hamcrest .Matchers .not ;
30+ import static org .junit .jupiter .api .Assertions .fail ;
3031
3132import edu .umd .cs .findbugs .annotations .NonNull ;
3233import hudson .FilePath ;
6263import org .eclipse .jetty .server .ServerConnector ;
6364import org .eclipse .jetty .util .Callback ;
6465import org .htmlunit .Page ;
66+ import org .junit .jupiter .api .AfterEach ;
6567import org .junit .jupiter .api .BeforeEach ;
6668import org .junit .jupiter .api .Tag ;
6769import org .junit .jupiter .api .Test ;
68- import org .junit .jupiter .api .io .TempDir ;
6970import org .jvnet .hudson .test .Issue ;
7071import org .jvnet .hudson .test .JenkinsRule ;
7172import org .jvnet .hudson .test .junit .jupiter .WithJenkins ;
7879@ WithJenkins
7980class SetupWizardTest {
8081
81- @ TempDir
8282 private File tmpdir ;
8383
8484 private JenkinsRule j ;
8585
8686 @ BeforeEach
87- void setUp (JenkinsRule rule ) {
87+ void setUp (JenkinsRule rule ) throws Exception {
8888 j = rule ;
89- }
9089
91- @ BeforeEach
92- void initSetupWizard () throws IOException , InterruptedException {
90+ tmpdir = Files . createTempDirectory ( "junit-" ). toFile ();
91+
9392 final SetupWizard wizard = j .jenkins .getSetupWizard ();
9493 wizard .init (true );
9594
@@ -100,6 +99,11 @@ void initSetupWizard() throws IOException, InterruptedException {
10099 final String password = ostream .toString (StandardCharsets .UTF_8 );
101100 }
102101
102+ @ AfterEach
103+ void tearDown () {
104+ tmpdir .delete ();
105+ }
106+
103107 @ Test
104108 void shouldReturnPluginListsByDefault () {
105109 JenkinsRule .WebClient wc = j .createWebClient ();
@@ -170,15 +174,13 @@ void shouldProhibitAccessToPluginListWithoutAuth() throws Exception {
170174
171175 private String jsonRequest (JenkinsRule .WebClient wc , String path ) {
172176 // Try to call the actions method to retrieve the data
173- final Page res ;
174177 try {
175- res = wc .goTo (path , null );
178+ final Page res = wc .goTo (path , null );
179+ final String responseJSON = res .getWebResponse ().getContentAsString ();
180+ return responseJSON ;
176181 } catch (Exception ex ) {
177- ex .getMessage ();
178- throw new AssertionError ("Cannot get a response from " + path , ex );
182+ return fail ("Cannot get a response from " + path , ex );
179183 }
180- final String responseJSON = res .getWebResponse ().getContentAsString ();
181- return responseJSON ;
182184 }
183185
184186 private static final class CustomLocalUpdateSite extends UpdateSite {
0 commit comments