import java.awt.Component;
import java.awt.Container;
import java.awt.event.KeyEvent;

import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Before;

public class TestInputResponder implements InputResponder
{
	private InputResponder inputResponder;
	private KeyEvent currentKeyEvent = null;
	private static final char testKey = 'x';

	public void keyDownResponse(KeyEvent e)
	{
		currentKeyEvent = e;
	}

	public void keyUpResponse(KeyEvent e)
	{
		if ((currentKeyEvent == null) || (e.getKeyCode() != currentKeyEvent.getKeyCode()))
			throw new RuntimeException("keyUp is triggered before keyDown!");
		else
			currentKeyEvent = null;
	}

	@Before
	public void instantiate()
	{
		inputResponder = new TestInputResponder();
	}

	@Test
	public void testKeyDownUpResponse()
	{
		Component source = new Container();
		KeyEvent key = new KeyEvent(source, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, (int)testKey, testKey);
		inputResponder.keyDownResponse(key);

		key = new KeyEvent(source, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, (int)testKey, testKey);
		inputResponder.keyUpResponse(key);
	}
}

@@ -223,16 +223,87 @@
 onder%0A%7B%0A
+%09private static final Component testKeyEventSource = new Container();%0A%0A
 %09private
@@ -419,16 +419,407 @@
 = 'x';%0A%0A
+%09private static KeyEvent generateKeyEvent(int id, char key)%0A%09%7B%0A%09%09return new KeyEvent(testKeyEventSource, id, System.currentTimeMillis(), 0, (int)key, key);%0A%09%7D%0A%0A%09public static KeyEvent generateKeyDownEvent(char key)%0A%09%7B%0A%09%09return generateKeyEvent(KeyEvent.KEY_PRESSED, key);%0A%09%7D%0A%0A%09public static KeyEvent generateKeyUpEvent(char key)%0A%09%7B%0A%09%09return generateKeyEvent(KeyEvent.KEY_RELEASED, key);%0A%09%7D%0A%0A
 %09public 
@@ -1256,303 +1256,68 @@
 %7B%0A%09%09
-Component source = new Container();%0A%09%09KeyEvent key = new KeyEvent(source, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, (int)testKey, testKey);%0A%09%09inputResponder.keyDownResponse(key);%0A%0A%09%09key = new KeyEvent(source, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, (int)testKey, testKey
+inputResponder.keyDownResponse(generateKeyDownEvent(testKey)
 );%0A%09
@@ -1346,19 +1346,43 @@
 esponse(
-key
+generateKeyUpEvent(testKey)
 );%0A%09%7D%0A%7D%0A

Refactor KeyEvent generation for unit tests.