/**
* Copyright © 2015 Instituto Superior Técnico
*
* This file is part of Bennu OAuth Test.
*
* Bennu OAuth Test is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bennu OAuth Test is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Bennu OAuth Test. If not, see <http://www.gnu.org/licenses/>.
*/
package pt.ist.fenixframework.test.core;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import pt.ist.esw.advice.pt.ist.fenixframework.AtomicInstance;
import pt.ist.fenixframework.Atomic.TxMode;
import pt.ist.fenixframework.FenixFramework;
import java.lang.reflect.UndeclaredThrowableException;
public class FenixFrameworkRunner extends BlockJUnit4ClassRunner {
public FenixFrameworkRunner(Class<?> klass) throws InitializationError {
super(klass);
}
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
try {
FenixFramework.getTransactionManager().withTransaction(() -> {
super.runChild(method, notifier);
return null;
}, new AtomicInstance(TxMode.WRITE, true));
} catch (Exception e) {
throw new UndeclaredThrowableException(e);
}
}
}