package org.torproject.jtor;

import static org.junit.Assert.*;

import java.io.File;
import java.util.concurrent.TimeUnit;

import org.junit.Test;

public class TorConfigTest {



	@Test
	public void testCircuitBuildTimeout() {
		TorConfig config = Tor.createConfig();
		final long timeout = config.getCircuitBuildTimeout();
		assertEquals(TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS), timeout);
		config.setCircuitBuildTimeout(2, TimeUnit.MINUTES);
		assertTrue(config.getCircuitBuildTimeout() > timeout);
	}
	
	@Test
	public void testDataDirectory() {
		TorConfig config = Tor.createConfig();
		final File dd = config.getDataDirectory();
		assertTrue(dd.getPath().charAt(0) != '~');
		final String testPath = "/foo/dir";
		config.setDataDirectory(new File(testPath));
		assertEquals(new File(testPath), config.getDataDirectory());
	}
	
	@Test
	public void testMaxCircuitsPending() {
		TorConfig config = Tor.createConfig();
		assertEquals(32, config.getMaxClientCircuitsPending());
		config.setMaxClientCircuitsPending(23);
		assertEquals(23, config.getMaxClientCircuitsPending());
	}
	
	@Test
	public void testEnforceDistinctSubnets() {
		final TorConfig config = Tor.createConfig();
		assertEquals(true, config.getEnforceDistinctSubnets());
		config.setEnforceDistinctSubnets(false);
		assertEquals(false, config.getEnforceDistinctSubnets());
	}
	
	
}

@@ -118,16 +118,41 @@
 eUnit;%0A%0A
+import org.junit.Before;%0A
 import o
@@ -197,16 +197,111 @@
 Test %7B%0A%0A
+%09private TorConfig config;%0A%09%0A%09@Before%0A%09public void setup() %7B%0A%09%09config = Tor.createConfig();%0A%09%7D%0A
 %0A%0A%09@Test
@@ -346,49 +346,8 @@
 ) %7B%0A
-%09%09TorConfig config = Tor.createConfig();%0A
 %09%09fi
@@ -638,49 +638,8 @@
 ) %7B%0A
-%09%09TorConfig config = Tor.createConfig();%0A
 %09%09fi
@@ -928,49 +928,8 @@
 ) %7B%0A
-%09%09TorConfig config = Tor.createConfig();%0A
 %09%09as
@@ -1142,55 +1142,8 @@
 ) %7B%0A
-%09%09final TorConfig config = Tor.createConfig();%0A
 %09%09as
@@ -1305,10 +1305,6 @@
 %0A%09%7D%0A
-%09%0A%09%0A
 %7D%0A

Use a @Before to set up TorConfig instance