author | Jaroslav Tulach <jtulach@netbeans.org> |
Wed, 27 Jan 2010 19:04:13 +0100 | |
changeset 344 | 3ba131907351 |
parent 343 | 8e220093e4bf |
child 345 | f497cf8621b3 |
permissions | -rw-r--r-- |
jtulach@343 | 1 |
package org.apidesign.singletons.usage; |
jtulach@343 | 2 |
|
jtulach@343 | 3 |
import org.apidesign.singletons.api.DialogDisplayer; |
jtulach@343 | 4 |
import org.junit.BeforeClass; |
jtulach@343 | 5 |
import org.junit.Test; |
jtulach@343 | 6 |
import org.netbeans.junit.MockServices; |
jtulach@343 | 7 |
import static org.junit.Assert.*; |
jtulach@343 | 8 |
|
jtulach@343 | 9 |
public class MainTest { |
jtulach@343 | 10 |
|
jtulach@343 | 11 |
public MainTest() { |
jtulach@343 | 12 |
} |
jtulach@343 | 13 |
|
jtulach@343 | 14 |
@BeforeClass |
jtulach@343 | 15 |
public static void setUpClass() throws Exception { |
jtulach@343 | 16 |
MockServices.setServices(MockDialogDisplayer.class); |
jtulach@343 | 17 |
} |
jtulach@343 | 18 |
|
jtulach@343 | 19 |
@Test |
jtulach@343 | 20 |
public void testMainAsksAQuestion() { |
jtulach@343 | 21 |
assertNull("No question asked yet", MockDialogDisplayer.askedQuery); |
jtulach@343 | 22 |
Main.main(new String[0]); |
jtulach@343 | 23 |
assertNotNull("main code asked our Mock displayer", MockDialogDisplayer.askedQuery); |
jtulach@343 | 24 |
} |
jtulach@343 | 25 |
|
jtulach@343 | 26 |
public static final class MockDialogDisplayer extends DialogDisplayer { |
jtulach@343 | 27 |
static String askedQuery; |
jtulach@343 | 28 |
|
jtulach@343 | 29 |
@Override |
jtulach@343 | 30 |
public boolean yesOrNo(String query) { |
jtulach@343 | 31 |
askedQuery = query; |
jtulach@343 | 32 |
return false; |
jtulach@343 | 33 |
} |
jtulach@343 | 34 |
|
jtulach@343 | 35 |
} |
jtulach@343 | 36 |
} |