use of org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistryImpl in project sling by apache.
the class ConnectorRegistryImplTest method testRegisterUnregister.
@Test
public void testRegisterUnregister() throws Exception {
BaseConfig config = new SimpleConnectorConfig() {
@Override
public long getConnectorPingTimeout() {
return 20000;
}
};
AnnouncementRegistryImpl announcementRegistry = AnnouncementRegistryImpl.testConstructorAndActivate(MockFactory.mockResourceResolverFactory(), new DummySlingSettingsService(UUID.randomUUID().toString()), config);
ConnectorRegistry c = ConnectorRegistryImpl.testConstructor(announcementRegistry, config);
final URL url = new URL("http://localhost:1234/connector");
final ClusterViewService cvs = i.getClusterViewService();
try {
c.registerOutgoingConnector(null, url);
fail("should have complained");
} catch (IllegalArgumentException e) {
// ok
}
try {
c.registerOutgoingConnector(cvs, null);
fail("should have complained");
} catch (IllegalArgumentException e) {
// ok
}
TopologyConnectorClientInformation client = c.registerOutgoingConnector(cvs, url);
try {
// should not be able to register same url twice
client = c.registerOutgoingConnector(cvs, url);
// ok - no longer complains - SLING-3446
} catch (IllegalStateException e) {
// SLING-3446
fail("should no longer be thrown");
}
try {
c.unregisterOutgoingConnector(null);
fail("should have complained");
} catch (IllegalArgumentException e) {
// ok
}
c.unregisterOutgoingConnector(client.getId());
}
Aggregations