9
9
10
10
import com .cloudbees .jenkins .support .SupportTestUtils ;
11
11
import com .cloudbees .jenkins .support .api .Component ;
12
- import com .cloudbees .jenkins .support .api .Container ;
13
- import edu .umd .cs .findbugs .annotations .NonNull ;
14
12
import hudson .ExtensionList ;
15
13
import hudson .logging .LogRecorder ;
16
- import hudson .security .Permission ;
17
14
import java .io .IOException ;
18
- import java .util .Collections ;
19
15
import java .util .Objects ;
20
- import java .util .Set ;
21
16
import java .util .logging .Level ;
22
17
import java .util .logging .Logger ;
23
- import jenkins .model .Jenkins ;
24
18
import org .hamcrest .Matchers ;
19
+ import org .junit .After ;
25
20
import org .junit .Rule ;
26
21
import org .junit .Test ;
27
22
import org .jvnet .hudson .test .JenkinsRule ;
@@ -31,6 +26,11 @@ public class CustomLogsTest {
31
26
@ Rule
32
27
public JenkinsRule j = new JenkinsRule ();
33
28
29
+ @ After
30
+ public void closeAll () {
31
+ CustomLogs .closeAll ();
32
+ }
33
+
34
34
@ Test
35
35
public void testCustomLogsContentEmpty () {
36
36
String customLogs = SupportTestUtils .invokeComponentToString (
@@ -46,25 +46,7 @@ public void testCustomLogsContent() throws IOException {
46
46
j .getInstance ().getLog ().getRecorders ().add (testLogRecorder );
47
47
testTarget .enable ();
48
48
testLogRecorder .save ();
49
- SupportTestUtils .invokeComponentToString (new Component () {
50
-
51
- @ NonNull
52
- @ Override
53
- public Set <Permission > getRequiredPermissions () {
54
- return Collections .singleton (Jenkins .ADMINISTER );
55
- }
56
-
57
- @ NonNull
58
- @ Override
59
- public String getDisplayName () {
60
- return "" ;
61
- }
62
-
63
- @ Override
64
- public void addContents (@ NonNull Container container ) {
65
- Logger .getLogger (CustomLogsTest .class .getName ()).fine ("Testing custom log recorders" );
66
- }
67
- });
49
+ Logger .getLogger (CustomLogsTest .class .getName ()).fine ("Testing custom log recorders" );
68
50
String customLogs = SupportTestUtils .invokeComponentToString (
69
51
Objects .requireNonNull (ExtensionList .lookup (Component .class ).get (CustomLogs .class )));
70
52
assertFalse ("Should write CustomLogsTest FINE logs" , customLogs .isEmpty ());
0 commit comments