16
16
17
17
package org .springframework .security .ldap .server ;
18
18
19
- import javax .annotation .PreDestroy ;
20
-
21
19
import org .junit .After ;
22
20
import org .junit .Test ;
23
21
22
+ import org .springframework .beans .factory .DisposableBean ;
24
23
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
25
24
import org .springframework .context .annotation .Bean ;
26
25
import org .springframework .context .annotation .Configuration ;
@@ -92,7 +91,7 @@ public void unboundIdContainerWhenWildcardLdifNotFoundThenProceeds() {
92
91
}
93
92
94
93
@ Configuration
95
- static class CustomLdifConfig {
94
+ static class CustomLdifConfig implements DisposableBean {
96
95
97
96
private UnboundIdContainer container = new UnboundIdContainer ("dc=springframework,dc=org" ,
98
97
"classpath:test-server.ldif" );
@@ -109,15 +108,15 @@ ContextSource contextSource(UnboundIdContainer container) {
109
108
"ldap://127.0.0.1:" + container .getPort () + "/dc=springframework,dc=org" );
110
109
}
111
110
112
- @ PreDestroy
113
- void shutdown () {
111
+ @ Override
112
+ public void destroy () throws Exception {
114
113
this .container .stop ();
115
114
}
116
115
117
116
}
118
117
119
118
@ Configuration
120
- static class WildcardLdifConfig {
119
+ static class WildcardLdifConfig implements DisposableBean {
121
120
122
121
private UnboundIdContainer container = new UnboundIdContainer ("dc=springframework,dc=org" ,
123
122
"classpath*:test-server.ldif" );
@@ -134,15 +133,15 @@ ContextSource contextSource(UnboundIdContainer container) {
134
133
"ldap://127.0.0.1:" + container .getPort () + "/dc=springframework,dc=org" );
135
134
}
136
135
137
- @ PreDestroy
138
- void shutdown () {
136
+ @ Override
137
+ public void destroy () throws Exception {
139
138
this .container .stop ();
140
139
}
141
140
142
141
}
143
142
144
143
@ Configuration
145
- static class MalformedLdifConfig {
144
+ static class MalformedLdifConfig implements DisposableBean {
146
145
147
146
private UnboundIdContainer container = new UnboundIdContainer ("dc=springframework,dc=org" ,
148
147
"classpath:test-server-malformed.txt" );
@@ -153,15 +152,15 @@ UnboundIdContainer ldapContainer() {
153
152
return this .container ;
154
153
}
155
154
156
- @ PreDestroy
157
- void shutdown () {
155
+ @ Override
156
+ public void destroy () throws Exception {
158
157
this .container .stop ();
159
158
}
160
159
161
160
}
162
161
163
162
@ Configuration
164
- static class MissingLdifConfig {
163
+ static class MissingLdifConfig implements DisposableBean {
165
164
166
165
private UnboundIdContainer container = new UnboundIdContainer ("dc=springframework,dc=org" ,
167
166
"classpath:does-not-exist.ldif" );
@@ -172,15 +171,15 @@ UnboundIdContainer ldapContainer() {
172
171
return this .container ;
173
172
}
174
173
175
- @ PreDestroy
176
- void shutdown () {
174
+ @ Override
175
+ public void destroy () throws Exception {
177
176
this .container .stop ();
178
177
}
179
178
180
179
}
181
180
182
181
@ Configuration
183
- static class WildcardNoLdifConfig {
182
+ static class WildcardNoLdifConfig implements DisposableBean {
184
183
185
184
private UnboundIdContainer container = new UnboundIdContainer ("dc=springframework,dc=org" ,
186
185
"classpath*:*.test.ldif" );
@@ -191,8 +190,8 @@ UnboundIdContainer ldapContainer() {
191
190
return this .container ;
192
191
}
193
192
194
- @ PreDestroy
195
- void shutdown () {
193
+ @ Override
194
+ public void destroy () throws Exception {
196
195
this .container .stop ();
197
196
}
198
197
0 commit comments