@@ -153,33 +153,27 @@ private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
153
153
154
154
public static class UnitTest {
155
155
156
- @ After
157
- @ Before
158
- public void reset () {
159
- // use private access to reset so we can test different initializations via the public static flow
160
- RxJavaPlugins .getInstance ().errorHandler .set (null );
161
- RxJavaPlugins .getInstance ().observableExecutionHook .set (null );
162
- }
163
-
164
156
@ Test
165
157
public void testErrorHandlerDefaultImpl () {
166
- RxJavaErrorHandler impl = RxJavaPlugins . getInstance ().getErrorHandler ();
158
+ RxJavaErrorHandler impl = new RxJavaPlugins ().getErrorHandler ();
167
159
assertTrue (impl instanceof RxJavaErrorHandlerDefault );
168
160
}
169
161
170
162
@ Test
171
163
public void testErrorHandlerViaRegisterMethod () {
172
- RxJavaPlugins .getInstance ().registerErrorHandler (new RxJavaErrorHandlerTestImpl ());
173
- RxJavaErrorHandler impl = RxJavaPlugins .getInstance ().getErrorHandler ();
164
+ RxJavaPlugins p = new RxJavaPlugins ();
165
+ p .registerErrorHandler (new RxJavaErrorHandlerTestImpl ());
166
+ RxJavaErrorHandler impl = p .getErrorHandler ();
174
167
assertTrue (impl instanceof RxJavaErrorHandlerTestImpl );
175
168
}
176
169
177
170
@ Test
178
171
public void testErrorHandlerViaProperty () {
179
172
try {
173
+ RxJavaPlugins p = new RxJavaPlugins ();
180
174
String fullClass = getFullClassNameForTestClass (RxJavaErrorHandlerTestImpl .class );
181
175
System .setProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" , fullClass );
182
- RxJavaErrorHandler impl = RxJavaPlugins . getInstance () .getErrorHandler ();
176
+ RxJavaErrorHandler impl = p .getErrorHandler ();
183
177
assertTrue (impl instanceof RxJavaErrorHandlerTestImpl );
184
178
} finally {
185
179
System .clearProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" );
@@ -193,23 +187,26 @@ public static class RxJavaErrorHandlerTestImpl extends RxJavaErrorHandler {
193
187
194
188
@ Test
195
189
public void testObservableExecutionHookDefaultImpl () {
196
- RxJavaObservableExecutionHook impl = RxJavaPlugins .getInstance ().getObservableExecutionHook ();
190
+ RxJavaPlugins p = new RxJavaPlugins ();
191
+ RxJavaObservableExecutionHook impl = p .getObservableExecutionHook ();
197
192
assertTrue (impl instanceof RxJavaObservableExecutionHookDefault );
198
193
}
199
194
200
195
@ Test
201
196
public void testObservableExecutionHookViaRegisterMethod () {
202
- RxJavaPlugins .getInstance ().registerObservableExecutionHook (new RxJavaObservableExecutionHookTestImpl ());
203
- RxJavaObservableExecutionHook impl = RxJavaPlugins .getInstance ().getObservableExecutionHook ();
197
+ RxJavaPlugins p = new RxJavaPlugins ();
198
+ p .registerObservableExecutionHook (new RxJavaObservableExecutionHookTestImpl ());
199
+ RxJavaObservableExecutionHook impl = p .getObservableExecutionHook ();
204
200
assertTrue (impl instanceof RxJavaObservableExecutionHookTestImpl );
205
201
}
206
202
207
203
@ Test
208
204
public void testObservableExecutionHookViaProperty () {
209
205
try {
206
+ RxJavaPlugins p = new RxJavaPlugins ();
210
207
String fullClass = getFullClassNameForTestClass (RxJavaObservableExecutionHookTestImpl .class );
211
208
System .setProperty ("rxjava.plugin.RxJavaObservableExecutionHook.implementation" , fullClass );
212
- RxJavaObservableExecutionHook impl = RxJavaPlugins . getInstance () .getObservableExecutionHook ();
209
+ RxJavaObservableExecutionHook impl = p .getObservableExecutionHook ();
213
210
assertTrue (impl instanceof RxJavaObservableExecutionHookTestImpl );
214
211
} finally {
215
212
System .clearProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" );
0 commit comments