/*******************************************************************************
 * Copyright (c) 2012 - 2015 Signal Iduna Corporation 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:
 * Signal Iduna Corporation - initial API and implementation
 * akquinet AG
 *******************************************************************************/
package org.testeditor.fixture.swt;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

/**
 * Module tests for the SWTBotFixture.
 *
 */
public class SWTBotFixtureTest {

	@Test
	public void testMarkForRunningApplication() throws Exception {
		final Set<String> monitor = new HashSet<String>();
		Runnable firstLaunch = new Runnable() {

			@Override
			public void run() {
				try {
					SwtBotFixture swtBotFixture = new SwtBotFixture();
					monitor.add("first launched");
					swtBotFixture.waitUntilPreviousLaunchIsFinished();
					Thread.sleep(30);
					monitor.add("first finished");
					swtBotFixture.markApplicationStopped();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}

			}
		};
		Runnable secondLaunch = new Runnable() {

			@Override
			public void run() {
				try {
					monitor.add("second launched");
					SwtBotFixture swtBotFixture = new SwtBotFixture();
					swtBotFixture.waitUntilPreviousLaunchIsFinished();
					assertTrue(monitor.contains("first finished"));
				} catch (InterruptedException e) {
					e.printStackTrace();
				}

			}
		};
		new Thread(firstLaunch).start();
		new Thread(secondLaunch).start();
		Thread.sleep(10);
		assertEquals(2, monitor.size());
		assertTrue(monitor.contains("first launched"));
		assertTrue(monitor.contains("second launched"));
		Thread.sleep(30);
		assertEquals(3, monitor.size());
		assertTrue(monitor.contains("first finished"));
	}
}

@@ -2103,10 +2103,362 @@
 %22));%0A%09%7D%0A
+%0A%09/**%0A%09 * Tests the tear Down operation.%0A%09 */%0A%09@Test%0A%09public void testTearDown() %7B%0A%09%09final Set%3CString%3E monitor = new HashSet%3CString%3E();%0A%09%09SwtBotFixture swtBotFixture = new SwtBotFixture() %7B%0A%09%09%09@Override%0A%09%09%09public void stopApplication() %7B%0A%09%09%09%09monitor.add(%22stop%22);%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09swtBotFixture.stopApplication();%0A%09%09assertTrue(monitor.contains(%22stop%22));%0A%09%7D%0A%0A
 %7D%0A

Test stop of swtbotfixture