diff options
author | Eike Stepper | 2012-10-07 07:16:20 +0000 |
---|---|---|
committer | Eike Stepper | 2012-10-07 07:16:20 +0000 |
commit | ad9be42fed20da84e2d01965026052f238a6fc41 (patch) | |
tree | 09e4d6e58d9940331ed41ea92652eb06483180a1 /plugins/org.eclipse.net4j.util/src | |
parent | 3d0c7825e4216580e2cff1f857d44bae27acd3e0 (diff) | |
download | cdo-ad9be42fed20da84e2d01965026052f238a6fc41.tar.gz cdo-ad9be42fed20da84e2d01965026052f238a6fc41.tar.xz cdo-ad9be42fed20da84e2d01965026052f238a6fc41.zip |
Make current test instance available globally during tests
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src')
-rw-r--r-- | plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/test/TestExecuter.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/test/TestExecuter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/test/TestExecuter.java new file mode 100644 index 0000000000..055c6cb554 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/test/TestExecuter.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.util.test; + +/** + * @author Eike Stepper + * @since 3.3 + */ +public final class TestExecuter +{ + private static Object currentTest; + + private TestExecuter() + { + } + + public static Object getValue() + { + return currentTest; + } + + public static void execute(Object test, Executable executable) throws Throwable + { + if (currentTest != null) + { + throw new IllegalStateException("Recursive calls are not supported"); + } + + try + { + currentTest = test; + executable.execute(); + } + finally + { + currentTest = null; + } + } + + /** + * @author Eike Stepper + */ + public interface Executable + { + public void execute() throws Throwable; + } +} |