1.1 --- a/samples/aserverinfo/test/org/apidesign/aserverinfo/test/ServerConnectorTest.java Sat Nov 15 06:57:15 2008 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,89 +0,0 @@
1.4 -package org.apidesign.aserverinfo.test;
1.5 -
1.6 -import java.net.MalformedURLException;
1.7 -import java.net.URL;
1.8 -import org.apidesign.aserverinfo.cummulativefactory.ServerConnector;
1.9 -import org.apidesign.aserverinfo.spi.NameProvider;
1.10 -import org.apidesign.aserverinfo.spi.ResetHandler;
1.11 -import org.apidesign.aserverinfo.spi.URLProvider;
1.12 -import org.junit.After;
1.13 -import org.junit.Before;
1.14 -import org.junit.Test;
1.15 -import static org.junit.Assert.*;
1.16 -import org.openide.util.Exceptions;
1.17 -
1.18 -public class ServerConnectorTest {
1.19 -
1.20 - public ServerConnectorTest() {
1.21 - }
1.22 -
1.23 - @Before
1.24 - public void setUp() {
1.25 - }
1.26 -
1.27 - @After
1.28 - public void tearDown() {
1.29 - }
1.30 -
1.31 - @Test
1.32 - public void showUseOfCumulativeFactory() throws Exception {
1.33 - Prov p = new Prov();
1.34 - NameProvider np = p;
1.35 - URLProvider up = p;
1.36 - ResetHandler res = p;
1.37 - ServerConnector inf;
1.38 -
1.39 - // BEGIN: ServerConnector.cumulative.creation
1.40 - inf = ServerConnector.empty().nameProvider(np).urlProvider(up).reset(res);
1.41 - // END: ServerConnector.cumulative.creation
1.42 -
1.43 - assertEquals("API Design Server", inf.getName());
1.44 - assertEquals("http://www.apidesign.org", inf.getURL().toExternalForm());
1.45 - inf.reset();
1.46 - assertEquals("Once reset", 1, p.resets);
1.47 -
1.48 - }
1.49 -
1.50 - @Test
1.51 - public void showVerboseUseOfCumulativeFactory() throws Exception {
1.52 - Prov prov = new Prov();
1.53 - ServerConnector info;
1.54 -
1.55 - // BEGIN: ServerConnector.cumulative.creation.verbose
1.56 - ServerConnector empty = ServerConnector.empty();
1.57 - ServerConnector name = empty.nameProvider(prov);
1.58 - ServerConnector urlAndName = name.urlProvider(prov);
1.59 - info = urlAndName.reset(prov);
1.60 - // END: ServerConnector.cumulative.creation.verbose
1.61 -
1.62 - assertEquals("API Design Server", info.getName());
1.63 - assertEquals("http://www.apidesign.org", info.getURL().toExternalForm());
1.64 - info.reset();
1.65 - assertEquals("Once reset", 1, prov.resets);
1.66 -
1.67 - }
1.68 -
1.69 -
1.70 - private static class Prov implements NameProvider, URLProvider, ResetHandler {
1.71 - int resets;
1.72 -
1.73 - public String getName() {
1.74 - return "API Design Server";
1.75 - }
1.76 -
1.77 - public URL getURL() {
1.78 - try {
1.79 - return new URL("http://www.apidesign.org");
1.80 - } catch (MalformedURLException ex) {
1.81 - Exceptions.printStackTrace(ex);
1.82 - return null;
1.83 - }
1.84 - }
1.85 -
1.86 - public void reset() {
1.87 - resets++;
1.88 - }
1.89 -
1.90 - }
1.91 -
1.92 -}
1.93 \ No newline at end of file