Skip to content

Commit

Permalink
Turn event into an interface, add TestEvent for test
Browse files Browse the repository at this point in the history
  • Loading branch information
grum committed Dec 24, 2011
1 parent 816291b commit c7ab756
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/main/java/nl/grum/microcraft/Event.java
@@ -1,4 +1,5 @@
package nl.grum.microcraft;

public class Event {
public interface Event<L> {
void notify(final L listener);
}
13 changes: 8 additions & 5 deletions src/test/java/nl/grum/microcraft/EventTest.java
@@ -1,22 +1,25 @@
package nl.grum.microcraft;

import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

public class EventTest {

private Event subject;
private static final String STRING = "foo";
private TestEvent subject;

@Before
public void setup() {
subject = new Event();
subject = new TestEvent(STRING);
}

@Test
public void stupidTest() {
assertThat(subject, notNullValue());
public void eventHasStringData() {
assertNotNull(subject.getString());
assertThat(subject.getString(), is(STRING));
}
}
6 changes: 3 additions & 3 deletions src/test/java/nl/grum/microcraft/ServerTest.java
Expand Up @@ -24,18 +24,18 @@ public void queueStartsEmtpy() {

@Test
public void addEventToQueue() {
Event e = new Event();
Event<?> e = new TestEvent("foo");

subject.queueEvent(e);
assertTrue(subject.peekEvent());
}

@Test
public void removeEventFromQueue() {
Event e1 = new Event();
Event<?> e1 = new TestEvent("foo");
subject.queueEvent(e1);

Event e2 = subject.pollEvent();
Event<?> e2 = subject.pollEvent();
assertFalse(subject.peekEvent());
assertEquals(e1, e2);
}
Expand Down

0 comments on commit c7ab756

Please sign in to comment.