Links { public static Link getLink(String uri) { return getLink(URIs.newURI(uri)); } private  Links(); static Link getDefault(); static Configurer getDefaultConfigurer(); static Link getLink(String uri); static Link getLink(URI uri); static Link getLink(Configurer configurer); @LapsedWith(module = JDK8, value = "Stream") static Configurer setChoiceValues(Configurer configurer); static boolean isConfigured(ConfigAttribute attribute);  }
@Test public void serialDashDoesHandleSerial() throws Exception { final LinkFactory<LinkConfig> serialDashAnything = spy(factoryNamed(serialDash("appendix-does-not-matter"))); withRegistered(serialDashAnything).execute(new Statement() { @Override public void execute() throws Exception { assertLinkWasCreatedBy(Links.getLink("ardulink: } }); }
@Test public void doesCacheLinks() throws IOException { String uri = "ardulink: Link link1 = Links.getLink(uri); Link link2 = Links.getLink(uri); assertThat(link1, notNullValue()); assertThat(link2, notNullValue()); assertAllSameInstances(link1, link2); close(link1, link2); }
@Test public void doesCacheLinksWhenUsingDefaultValues() throws IOException { Link link1 = Links.getLink("ardulink: Link link2 = Links.getLink("ardulink: assertThat(link1, notNullValue()); assertThat(link2, notNullValue()); assertAllSameInstances(link1, link2); close(link1, link2); }
@Test public void twoDifferentURIsWithSameParamsMustNotBeenMixed() throws Exception { final String name1 = new DummyLinkFactory().getName(); final String name2 = "DummyLINK"; assert name1.equalsIgnoreCase(name2) && !name1.equals(name2); class DummyLinkFactoryExtension extends DummyLinkFactory { @Override public String getName() { return name2; } } withRegistered(new DummyLinkFactoryExtension()).execute(new Statement() { @Override public void execute() throws IOException { Link link1 = Links.getLink(makeUri(name1)); Link link2 = Links.getLink(makeUri(name2)); assertThat(link1, not(sameInstance(link2))); close(link1, link2); } private String makeUri(String name) { return String.format("ardulink: } }); }
@Test public void aliasLinksAreSharedToo() throws Exception { withRegistered(new AliasUsingLinkFactory()).execute(new Statement() { @Override public void execute() throws IOException { Link link1 = Links.getLink("ardulink: Link link2 = Links.getLink("ardulink: assertAllSameInstances(link1, link2); close(link1, link2); } }); }