package com.xrtb.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import redis.clients.jedis.Jedis;

import com.xrtb.bidder.DeadmanSwitch;
import com.xrtb.common.Configuration;

public class TestDeadmanSwitch {

	@Test 
	public void testSwitch() throws Exception {
			Jedis redis = new Jedis("localhost");
			redis.connect();
			if (Configuration.getInstance().password != null)
				redis.auth(Configuration.getInstance().password);

			DeadmanSwitch.testmode = true;
			
			if (Configuration.setPassword() != null)
				redis.auth(Configuration.setPassword());
			
			redis.del("deadmanswitch");
			
			DeadmanSwitch d = new DeadmanSwitch("localhost",6379, "deadmanswitch");
			Thread.sleep(1000);
			assertFalse(d.canRun());
			redis.set("deadmanswitch", "ready");
			redis.expire("deadmanswitch", 5);
			
			assertTrue(d.canRun());
			Thread.sleep(10000);
			assertFalse(d.canRun());
		}
}

@@ -53,16 +53,75 @@
 ert.*;%0A%0A
+import org.junit.AfterClass;%0Aimport org.junit.BeforeClass;%0A
 import o
@@ -282,16 +282,420 @@
 itch %7B%0A%0A
+%09/**%0A%09 * Setup the RTB server for the test%0A%09 */%0A%09@BeforeClass%0A%09public static void setup() %7B%0A%09%09try %7B%0A%09%09%09Config.setup();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Shut the RTB server down.%0A%09 */%0A%09@AfterClass%0A%09public static void testCleanup() %7B%0A%09%09Config.teardown();%0A%09%09System.out.println(%22We are done!%22);%0A%09%7D%0A%0A%09/**%0A%09 * %0A%09 * @throws Exception%0A%09 */%0A
 %09@Test %0A

Fix initialization on the test case