diff options
Diffstat (limited to 'tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java')
-rw-r--r-- | tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java index 695a90ec885..344b19d9810 100644 --- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java +++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode.tests/src/org/eclipse/papyrus/infra/services/controlmode/tests/StrategyChooserFixture.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 CEA and others. + * Copyright (c) 2014, 2016 CEA, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,29 +8,43 @@ * * Contributors: * Christian W. Damus (CEA) - Initial API and implementation + * Christian W. Damus - bug 485220 * */ package org.eclipse.papyrus.infra.services.controlmode.tests; -import org.eclipse.papyrus.infra.services.resourceloading.preferences.StrategyChooser; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.services.resourceloading.IStrategyChooser; /** - * A {@link StrategyChooser} fixture for the control-mode tests that ensures a normal control-mode strategy + * An {@link IStrategyChooser} fixture for the control-mode tests that ensures a normal control-mode strategy * is restored after completion for predictable/correct resource loading behaviour in the execution of * subsequent (and unrelated) tests. */ public class StrategyChooserFixture { private final int strategyToRestore; + private IStrategyChooser chooser; - public StrategyChooserFixture(int choose) { - strategyToRestore = new StrategyChooser().getCurrentStrategy(); - StrategyChooser.setCurrentStrategy(choose); + public StrategyChooserFixture(ServicesRegistry serviceRegistry, int choose) { + super(); + + try { + chooser = serviceRegistry.getService(IStrategyChooser.class); + strategyToRestore = chooser.getCurrentStrategy(); + chooser.setStrategy(choose); + } catch (ServiceException e) { + throw new IllegalStateException("IStrategyChooser service is not available", e); + } } public void dispose() { - StrategyChooser.setCurrentStrategy(strategyToRestore); + if (chooser != null) { + chooser.setStrategy(strategyToRestore); + chooser = null; + } } } |