@@ -0,0 +1,1687 @@
+/*******************************************************************************%0A * Copyright (c) 2017 Pivotal, Inc.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A *     Pivotal, Inc. - initial API and implementation%0A *******************************************************************************/%0Apackage org.springsource.ide.eclipse.commons.frameworks.test.util;%0A%0Aimport java.time.Duration;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0Aimport org.eclipse.core.runtime.IProgressMonitor;%0Aimport org.eclipse.core.runtime.IStatus;%0Aimport org.eclipse.core.runtime.Status;%0Aimport org.eclipse.core.runtime.jobs.Job;%0Aimport org.springsource.ide.eclipse.commons.tests.util.StsTestUtil;%0A%0Apublic class Timewatch %7B%0A%0A%09/**%0A%09 * Runs a chunk of code on the current thread, giving a limited amount of time.%0A%09 * After the time limit is exceed a thread-dump is created on sysout.%0A%09 */%0A%09public static void monitor(String taskName, Duration limit, Asserter doit) throws Exception %7B%0A%09%09AtomicBoolean done = new AtomicBoolean(false);%0A%09%09Job threadDumper = new Job(%22ThreadDumper%22) %7B%0A%09%09%09@Override%0A%09%09%09protected IStatus run(IProgressMonitor monitor) %7B%0A%09%09%09%09if (!done.get()) %7B%0A%09%09%09%09%09System.err.println(%22WARNING! %22+taskName+ %22 is longer than %22+limit);%0A%09%09%09%09%09System.err.println(StsTestUtil.getStackDumps());%0A%09%09%09%09%7D%0A%09%09%09%09return Status.OK_STATUS;%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09threadDumper.schedule(limit.toMillis());%0A%09%09try %7B%0A%09%09%09doit.execute();%0A%09%09%7D finally %7B%0A%09%09%09done.set(true);%0A%09%09%09threadDumper.cancel();%0A%09%09%7D%0A%09%7D%0A%09%0A%7D%0A

Add 'Timewatch' test utility