author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 10:08:31 +0200 | |
changeset 250 | c6f1ccdd37f3 |
parent 248 | b3aab65cde53 |
permissions | -rw-r--r-- |
jtulach@248 | 1 |
package org.apidesign.anagram.app.lookup; |
jtulach@248 | 2 |
|
jtulach@250 | 3 |
import org.apidesign.anagram.api.WordLibrary; |
jtulach@248 | 4 |
import org.apidesign.anagram.gui.*; |
jtulach@250 | 5 |
import static org.junit.Assert.*; |
jtulach@250 | 6 |
import org.junit.Test; |
jtulach@250 | 7 |
import org.netbeans.junit.MockServices; |
jtulach@248 | 8 |
|
jtulach@248 | 9 |
public class AnagramsWithLookupTest extends AnagramsTestBase { |
jtulach@248 | 10 |
@Override |
jtulach@248 | 11 |
protected Anagrams create() { |
jtulach@248 | 12 |
return new AnagramsWithLookup(); |
jtulach@248 | 13 |
} |
jtulach@250 | 14 |
|
jtulach@250 | 15 |
@Test public void testChangesInTheRegistrationAreReflected() { |
jtulach@250 | 16 |
Anagrams ui = create(); |
jtulach@250 | 17 |
|
jtulach@250 | 18 |
MockServices.setServices(FirstMockWordLibrary.class); |
jtulach@250 | 19 |
ui.display(); |
jtulach@250 | 20 |
|
jtulach@250 | 21 |
assertEquals( |
jtulach@250 | 22 |
"Original word has to be from FirstMockWordLibrary", |
jtulach@250 | 23 |
"1st", ui.getOriginalWord() |
jtulach@250 | 24 |
); |
jtulach@250 | 25 |
|
jtulach@250 | 26 |
MockServices.setServices(SecondMockWordLibrary.class); |
jtulach@250 | 27 |
|
jtulach@250 | 28 |
assertEquals( |
jtulach@250 | 29 |
"Original word has to be from new library now", |
jtulach@250 | 30 |
"2nd", ui.getOriginalWord() |
jtulach@250 | 31 |
); |
jtulach@250 | 32 |
} |
jtulach@250 | 33 |
|
jtulach@250 | 34 |
public static final class FirstMockWordLibrary implements WordLibrary { |
jtulach@250 | 35 |
public String[] getWords() { |
jtulach@250 | 36 |
return new String[] { "1st" }; |
jtulach@250 | 37 |
} |
jtulach@250 | 38 |
} |
jtulach@250 | 39 |
|
jtulach@250 | 40 |
public static final class SecondMockWordLibrary implements WordLibrary { |
jtulach@250 | 41 |
public String[] getWords() { |
jtulach@250 | 42 |
return new String[] { "2nd" }; |
jtulach@250 | 43 |
} |
jtulach@250 | 44 |
} |
jtulach@250 | 45 |
|
jtulach@250 | 46 |
|
jtulach@248 | 47 |
} |