@@ -153,33 +153,27 @@ private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
153153
154154 public static class UnitTest {
155155
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-
164156 @ Test
165157 public void testErrorHandlerDefaultImpl () {
166- RxJavaErrorHandler impl = RxJavaPlugins . getInstance ().getErrorHandler ();
158+ RxJavaErrorHandler impl = new RxJavaPlugins ().getErrorHandler ();
167159 assertTrue (impl instanceof RxJavaErrorHandlerDefault );
168160 }
169161
170162 @ Test
171163 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 ();
174167 assertTrue (impl instanceof RxJavaErrorHandlerTestImpl );
175168 }
176169
177170 @ Test
178171 public void testErrorHandlerViaProperty () {
179172 try {
173+ RxJavaPlugins p = new RxJavaPlugins ();
180174 String fullClass = getFullClassNameForTestClass (RxJavaErrorHandlerTestImpl .class );
181175 System .setProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" , fullClass );
182- RxJavaErrorHandler impl = RxJavaPlugins . getInstance () .getErrorHandler ();
176+ RxJavaErrorHandler impl = p .getErrorHandler ();
183177 assertTrue (impl instanceof RxJavaErrorHandlerTestImpl );
184178 } finally {
185179 System .clearProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" );
@@ -193,23 +187,26 @@ public static class RxJavaErrorHandlerTestImpl extends RxJavaErrorHandler {
193187
194188 @ Test
195189 public void testObservableExecutionHookDefaultImpl () {
196- RxJavaObservableExecutionHook impl = RxJavaPlugins .getInstance ().getObservableExecutionHook ();
190+ RxJavaPlugins p = new RxJavaPlugins ();
191+ RxJavaObservableExecutionHook impl = p .getObservableExecutionHook ();
197192 assertTrue (impl instanceof RxJavaObservableExecutionHookDefault );
198193 }
199194
200195 @ Test
201196 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 ();
204200 assertTrue (impl instanceof RxJavaObservableExecutionHookTestImpl );
205201 }
206202
207203 @ Test
208204 public void testObservableExecutionHookViaProperty () {
209205 try {
206+ RxJavaPlugins p = new RxJavaPlugins ();
210207 String fullClass = getFullClassNameForTestClass (RxJavaObservableExecutionHookTestImpl .class );
211208 System .setProperty ("rxjava.plugin.RxJavaObservableExecutionHook.implementation" , fullClass );
212- RxJavaObservableExecutionHook impl = RxJavaPlugins . getInstance () .getObservableExecutionHook ();
209+ RxJavaObservableExecutionHook impl = p .getObservableExecutionHook ();
213210 assertTrue (impl instanceof RxJavaObservableExecutionHookTestImpl );
214211 } finally {
215212 System .clearProperty ("rxjava.plugin.RxJavaErrorHandler.implementation" );
0 commit comments