27
27
import io .kubernetes .client .openapi .models .*;
28
28
import io .kubernetes .client .util .ClientBuilder ;
29
29
import io .kubernetes .client .util .ModelMapper ;
30
- import java .io .File ;
31
30
import java .io .IOException ;
32
- import java .io .InputStream ;
33
- import java .nio .charset .StandardCharsets ;
34
- import java .nio .file .Files ;
35
- import java .nio .file .Paths ;
36
- import java .util .Properties ;
31
+ import java .util .Objects ;
37
32
33
+ import org .apache .commons .io .IOUtils ;
38
34
import org .junit .Before ;
39
35
import org .junit .Rule ;
40
36
import org .junit .Test ;
@@ -43,88 +39,86 @@ public class KubectlDeleteTest {
43
39
44
40
private ApiClient apiClient ;
45
41
46
- private static final byte [] DISCOVERY_API ;
42
+ private final byte [] DISCOVERY_API ;
47
43
48
- static {
44
+ {
49
45
try {
50
- DISCOVERY_API = KubectlDeleteTest .class
46
+ DISCOVERY_API = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
51
47
.getClassLoader ()
52
- .getResourceAsStream ("discovery-api.json" )
53
- .readAllBytes ();
48
+ .getResourceAsStream ("discovery-api.json" )));
54
49
} catch (IOException e ) {
55
- throw new RuntimeException ("Failed to load resource" , e );
50
+ throw new RuntimeException (e );
56
51
}
57
52
}
58
53
59
- private static final byte [] DISCOVERY_APIV1 ;
54
+ private final byte [] DISCOVERY_APIV1 ;
60
55
61
- static {
56
+ {
62
57
try {
63
- DISCOVERY_APIV1 = KubectlDeleteTest .class
58
+ DISCOVERY_APIV1 = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
64
59
.getClassLoader ()
65
- .getResourceAsStream ("discovery-api-v1.json" )
66
- .readAllBytes ();
60
+ .getResourceAsStream ("discovery-api-v1.json" )));
67
61
} catch (IOException e ) {
68
62
throw new RuntimeException (e );
69
63
}
70
64
}
71
65
72
66
73
- private static final byte [] ADD_JOB ;
67
+ private final byte [] ADD_JOB ;
74
68
75
- static {
69
+ {
76
70
try {
77
- ADD_JOB = KubectlDeleteTest .class
71
+ ADD_JOB = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
78
72
.getClassLoader ()
79
- .getResourceAsStream ("deleted-add-job.json" ). readAllBytes ( );
73
+ .getResourceAsStream ("deleted-add-job.json" )) );
80
74
} catch (IOException e ) {
81
75
throw new RuntimeException (e );
82
76
}
83
77
}
84
78
85
- private static final byte [] GET_BATCH ;
79
+ private final byte [] GET_BATCH ;
86
80
87
- static {
81
+ {
88
82
try {
89
- GET_BATCH = KubectlDeleteTest .class
83
+ GET_BATCH = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
90
84
.getClassLoader ()
91
- .getResourceAsStream ("deleted-get-batch.json" ). readAllBytes ( );
85
+ .getResourceAsStream ("deleted-get-batch.json" )) );
92
86
} catch (IOException e ) {
93
87
throw new RuntimeException (e );
94
88
}
95
89
}
96
90
97
- private static final byte [] DELETED_FIRST ;
91
+ private final byte [] DELETED_FIRST ;
98
92
99
- static {
93
+ {
100
94
try {
101
- DELETED_FIRST = KubectlDeleteTest .class
95
+ DELETED_FIRST = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
102
96
.getClassLoader ()
103
- .getResourceAsStream ("deleted-success.json" ). readAllBytes ( );
97
+ .getResourceAsStream ("deleted-success.json" )) );
104
98
} catch (IOException e ) {
105
99
throw new RuntimeException (e );
106
100
}
107
101
}
108
102
109
- private static final byte [] DELETED_SECOND ;
103
+ private final byte [] DELETED_SECOND ;
110
104
111
- static {
105
+ {
112
106
try {
113
- DELETED_SECOND = KubectlDeleteTest .class
107
+ DELETED_SECOND = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
114
108
.getClassLoader ()
115
- .getResourceAsStream ("deleted-not-found.json" ). readAllBytes ( );
109
+ .getResourceAsStream ("deleted-not-found.json" )) );
116
110
} catch (IOException e ) {
117
111
throw new RuntimeException (e );
118
112
}
119
113
}
120
114
121
- private static final byte [] DISCOVERY_APIS ;
115
+ private final byte [] DISCOVERY_APIS ;
122
116
123
- static {
117
+ {
124
118
try {
125
- DISCOVERY_APIS = KubectlDeleteTest .class
119
+ DISCOVERY_APIS = IOUtils . toByteArray ( Objects . requireNonNull ( KubectlDeleteTest .class
126
120
.getClassLoader ()
127
- .getResourceAsStream ("discovery-apis.json" ). readAllBytes ( );
121
+ .getResourceAsStream ("discovery-apis.json" )) );
128
122
} catch (IOException e ) {
129
123
throw new RuntimeException (e );
130
124
}
0 commit comments