}
@Test
public void testHttpAnnouncementWithCustomProperties()
{
final StaticAnnouncementHttpServerInfoImpl httpServerInfo = new StaticAnnouncementHttpServerInfoImpl(
URI.create("http://127.0.0.1:4444"),
URI.create("http://example.com:4444"),
URI.create("https://example.com:4444")
);
Injector injector = Guice.createInjector(
new ApplicationNameModule("test-application"),
new TestingDiscoveryModule(),
new TestingMBeanModule(),
new ReportingModule(),
new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(AnnouncementHttpServerInfo.class).toInstance(httpServerInfo);
DiscoveryBinder.discoveryBinder(binder).bindHttpAnnouncement("apple").addProperty("a", "apple");
}
}
);
ServiceAnnouncement announcement = serviceAnnouncement("apple")
.addProperty("a", "apple")
.addProperty("http", httpServerInfo.getHttpUri().toASCIIString())
.addProperty("http-external", httpServerInfo.getHttpExternalUri().toASCIIString())
.addProperty("https", httpServerInfo.getHttpsUri().toASCIIString())
.build();
Set<ServiceAnnouncement> announcements = injector.getInstance(Key.get(new TypeLiteral<Set<ServiceAnnouncement>>()
{
}));