author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:53:57 +0200 | |
changeset 91 | 3280450405a0 |
child 114 | c479228609ea |
permissions | -rw-r--r-- |
jtulach@91 | 1 |
package org.apidesign.aserverinfo; |
jtulach@91 | 2 |
|
jtulach@91 | 3 |
import java.net.MalformedURLException; |
jtulach@91 | 4 |
import java.net.URL; |
jtulach@91 | 5 |
import org.junit.After; |
jtulach@91 | 6 |
import org.junit.Before; |
jtulach@91 | 7 |
import org.junit.Test; |
jtulach@91 | 8 |
import static org.junit.Assert.*; |
jtulach@91 | 9 |
import org.openide.util.Exceptions; |
jtulach@91 | 10 |
|
jtulach@91 | 11 |
public class AServerInfoTest { |
jtulach@91 | 12 |
|
jtulach@91 | 13 |
public AServerInfoTest() { |
jtulach@91 | 14 |
} |
jtulach@91 | 15 |
|
jtulach@91 | 16 |
@Before |
jtulach@91 | 17 |
public void setUp() { |
jtulach@91 | 18 |
} |
jtulach@91 | 19 |
|
jtulach@91 | 20 |
@After |
jtulach@91 | 21 |
public void tearDown() { |
jtulach@91 | 22 |
} |
jtulach@91 | 23 |
|
jtulach@91 | 24 |
@Test |
jtulach@91 | 25 |
public void showUseOfCumulativeFactory() throws Exception { |
jtulach@91 | 26 |
class Prov implements AServerInfo.NameProvider, AServerInfo.URLProvider, AServerInfo.ResetHandler { |
jtulach@91 | 27 |
int resets; |
jtulach@91 | 28 |
|
jtulach@91 | 29 |
public String getName() { |
jtulach@91 | 30 |
return "API Design Server"; |
jtulach@91 | 31 |
} |
jtulach@91 | 32 |
|
jtulach@91 | 33 |
public URL getURL() { |
jtulach@91 | 34 |
try { |
jtulach@91 | 35 |
return new URL("http://www.apidesign.org"); |
jtulach@91 | 36 |
} catch (MalformedURLException ex) { |
jtulach@91 | 37 |
Exceptions.printStackTrace(ex); |
jtulach@91 | 38 |
return null; |
jtulach@91 | 39 |
} |
jtulach@91 | 40 |
} |
jtulach@91 | 41 |
|
jtulach@91 | 42 |
public void reset() { |
jtulach@91 | 43 |
resets++; |
jtulach@91 | 44 |
} |
jtulach@91 | 45 |
|
jtulach@91 | 46 |
} |
jtulach@91 | 47 |
|
jtulach@91 | 48 |
Prov prov = new Prov(); |
jtulach@91 | 49 |
AServerInfo info; |
jtulach@91 | 50 |
|
jtulach@91 | 51 |
// BEGIN: aserverinfo.cumulative.creation |
jtulach@91 | 52 |
info = AServerInfo.empty().nameProvider(prov).urlProvider(prov).reset(prov); |
jtulach@91 | 53 |
// END: aserverinfo.cumulative.creation |
jtulach@91 | 54 |
|
jtulach@91 | 55 |
assertEquals("API Design Server", info.getName()); |
jtulach@91 | 56 |
assertEquals("http://www.apidesign.org", info.getURL().toExternalForm()); |
jtulach@91 | 57 |
info.reset(); |
jtulach@91 | 58 |
assertEquals("Once reset", 1, prov.resets); |
jtulach@91 | 59 |
|
jtulach@91 | 60 |
} |
jtulach@91 | 61 |
} |