package com.crawljax.core.largetests;

import static org.junit.Assert.fail;

import java.io.File;

import org.apache.commons.configuration.ConfigurationException;
import org.junit.BeforeClass;

import com.crawljax.browser.EmbeddedBrowser.BrowserType;
import com.crawljax.core.CrawljaxController;
import com.crawljax.core.CrawljaxException;
import com.crawljax.core.configuration.CrawljaxConfiguration;
import com.crawljax.core.configuration.ThreadConfiguration;

public class LargeFirefoxTest extends LargeTestSuper {

	private static final int waitAfterEvent = 200;
	private static final int waitAfterReload = 200;
	private static BrowserType browser = BrowserType.firefox;
	private static final String INDEX = "src/test/site/index.html";

	/**
	 * Runs crawljax.
	 * 
	 * @throws java.lang.Exception
	 *             when error while crawling
	 */
	@BeforeClass
	public static void setUpBeforeClass() {
		CrawljaxConfiguration crawljaxConfiguration = new CrawljaxConfiguration();
		ThreadConfiguration tc = new ThreadConfiguration(2, 2, true);
		crawljaxConfiguration.setThreadConfiguration(tc);
		crawljaxConfiguration.setCrawlSpecification(getCrawlSpecification("file://"
		        + new File(INDEX).getAbsolutePath(), waitAfterEvent, waitAfterReload));
		addPlugins(crawljaxConfiguration);
		crawljaxConfiguration.setBrowser(browser);
		try {
			new CrawljaxController(crawljaxConfiguration).run();
		} catch (ConfigurationException e) {
			e.printStackTrace();
			fail(e.getMessage());
		} catch (CrawljaxException e) {
			e.printStackTrace();
			fail(e.getMessage());
		}
	}
}

@@ -1338,17 +1338,66 @@
 ;%0A%09%09
-try %7B%0A%09%09%09
+CrawljaxController crawljax = null;%0A%09%09try %7B%0A%09%09%09crawljax = 
 new 
@@ -1437,16 +1437,29 @@
 uration)
+;%0A%09%09%09crawljax
 .run();%0A
@@ -1596,32 +1596,32 @@
 ntStackTrace();%0A
-
 %09%09%09fail(e.getMes
@@ -1629,16 +1629,92 @@
 age());%0A
+%09%09%7D finally %7B%0A%09%09%09if (crawljax != null) %7B%0A%09%09%09%09crawljax.terminate(true);%0A%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%7D

terminate all jobs once done.