@Test public void testHandleTopologyEvent() throws IOException, InvalidSyntaxException { TopologyEvent event = Mockito.mock(TopologyEvent.class); TopologyView view = Mockito.mock(TopologyView.class); InstanceDescription description = Mockito.mock(InstanceDescription.class); Mockito.when(description.getProperty(Mockito.matches(InstanceDescription.PROPERTY_ENDPOINTS))) .thenReturn("https: Mockito.when(description.getProperty(Mockito.matches(PublicationPropertyProvider.ENDPOINT_PATHS))) .thenReturn("/libs/distribute"); Mockito.when(view.findInstances(Mockito.any())).thenReturn(Collections.singleton(description)); Mockito.when(event.getNewView()).thenReturn(view); ConfigurationAdmin configAdmin = Mockito.mock(ConfigurationAdmin.class); Configuration sampleConfig = new Configuration() { private Dictionary<String, Object> properties = new Hashtable<>(); @Override public String getPid() { return "org.apache.sling"; } @Override public Dictionary<String, Object> getProperties() { return properties; } @Override public void update(Dictionary<String, ?> properties) throws IOException { this.properties = (Dictionary<String, Object>) properties; } @Override public void delete() throws IOException { throw new UnsupportedOperationException(); } @Override public String getFactoryPid() { throw new UnsupportedOperationException(); } @Override public void update() throws IOException { throw new UnsupportedOperationException(); } @Override public void setBundleLocation(String location) { throw new UnsupportedOperationException(); } @Override public String getBundleLocation() { throw new UnsupportedOperationException(); } @Override public long getChangeCount() { throw new UnsupportedOperationException(); } }; Mockito.when(configAdmin.listConfigurations(Mockito.any())).thenReturn(new Configuration[] { sampleConfig }); ForwardAgentEndpointSynchronization sync = new ForwardAgentEndpointSynchronization(configAdmin, new ForwardAgentEndpointSynchronizationConfig() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public String agentTarget() { return null; } }); sync.handleTopologyEvent(event); assertTrue(Arrays.equals(new String[] { "https: (String[]) sampleConfig.getProperties().get(ForwardAgentEndpointSynchronization.ENDPOINT_PROPERTY))); }
@Override public void handleTopologyEvent(TopologyEvent event) { Set<InstanceDescription> renderers = event.getNewView().findInstances(id -> INSTANCE_TYPE.RENDERER.toString() .equals(id.getProperty(PublicationPropertyProvider.INSTANCE_TYPE))); updateInstances(renderers); }
ForwardAgentEndpointSynchronization implements TopologyEventListener { @Override public void handleTopologyEvent(TopologyEvent event) { Set<InstanceDescription> renderers = event.getNewView().findInstances(id -> INSTANCE_TYPE.RENDERER.toString() .equals(id.getProperty(PublicationPropertyProvider.INSTANCE_TYPE))); updateInstances(renderers); } }
ForwardAgentEndpointSynchronization implements TopologyEventListener { @Override public void handleTopologyEvent(TopologyEvent event) { Set<InstanceDescription> renderers = event.getNewView().findInstances(id -> INSTANCE_TYPE.RENDERER.toString() .equals(id.getProperty(PublicationPropertyProvider.INSTANCE_TYPE))); updateInstances(renderers); } @Activate  ForwardAgentEndpointSynchronization(@Reference ConfigurationAdmin configAdmin,
            ForwardAgentEndpointSynchronizationConfig config); }
ForwardAgentEndpointSynchronization implements TopologyEventListener { @Override public void handleTopologyEvent(TopologyEvent event) { Set<InstanceDescription> renderers = event.getNewView().findInstances(id -> INSTANCE_TYPE.RENDERER.toString() .equals(id.getProperty(PublicationPropertyProvider.INSTANCE_TYPE))); updateInstances(renderers); } @Activate  ForwardAgentEndpointSynchronization(@Reference ConfigurationAdmin configAdmin,
            ForwardAgentEndpointSynchronizationConfig config); @Override void handleTopologyEvent(TopologyEvent event); }
ForwardAgentEndpointSynchronization implements TopologyEventListener { @Override public void handleTopologyEvent(TopologyEvent event) { Set<InstanceDescription> renderers = event.getNewView().findInstances(id -> INSTANCE_TYPE.RENDERER.toString() .equals(id.getProperty(PublicationPropertyProvider.INSTANCE_TYPE))); updateInstances(renderers); } @Activate  ForwardAgentEndpointSynchronization(@Reference ConfigurationAdmin configAdmin,
            ForwardAgentEndpointSynchronizationConfig config); @Override void handleTopologyEvent(TopologyEvent event); static final String ENDPOINT_PROPERTY; }