SiriServerSubscriptionManager implements StatusProviderService { public void recordPublicationStatistics(SiriServerSubscriptionEvent event, long timeNeededToPublish, boolean connectionError) { ServerSubscriptionChannel channel = _channelsByAddress.get(event.getAddress()); if (channel == null) { return; } channel.updatePublicationStatistics(event, timeNeededToPublish, connectionError); } SiriServerSubscriptionManager(); @Inject void setSchedulingService(SchedulingService schedulingService); void addListener(SiriSubscriptionManagerListener listener); void removeListener(SiriSubscriptionManagerListener listener); void setConsumerAddressDefaultForRequestorRef(String requestorRef,
      String consumerAddressDefault); void setConsumerAddressDefault(String consumerAddressDefault); void addModuleDeliveryFilter(SiriModuleDeliveryFilterMatcher matcher,
      SiriModuleDeliveryFilter filter); void setServer(SiriServer server); @PreDestroy void stop(); List<String> getActiveSubscriptionChannels(); synchronized void handleSubscriptionRequest(
      SubscriptionRequest subscriptionRequest, ESiriVersion originalVersion,
      List<StatusResponseStructure> statuses); synchronized void terminateSubscriptionChannelWithAddress(
      String address); synchronized void terminateSubscriptionsForRequest(
      TerminateSubscriptionRequestStructure request,
      List<TerminationResponseStatus> statuses); synchronized void terminateSubscriptionWithId(SubscriptionId id); List<SiriServerSubscriptionEvent> publish(ServiceDelivery delivery); void recordPublicationStatistics(SiriServerSubscriptionEvent event,
      long timeNeededToPublish, boolean connectionError); @Override synchronized void getStatus(Map<String, String> status);  }
@Test public void testRecordPublicationStatistics() { VehicleMonitoringSubscriptionStructure vmRequest = new VehicleMonitoringSubscriptionStructure(); vmRequest.setSubscriberRef(SiriTypeFactory.particpantRef("alpha")); vmRequest.setSubscriptionIdentifier(SiriTypeFactory.subscriptionId("beta")); SubscriptionRequest request = new SubscriptionRequest(); request.setAddress("10.0.0.1"); request.getVehicleMonitoringSubscriptionRequest().add(vmRequest); List<StatusResponseStructure> statuses = new ArrayList<StatusResponseStructure>(); Date when = new Date(); _manager.handleSubscriptionRequest(request, ESiriVersion.V1_3, statuses); ServiceDelivery delivery = new ServiceDelivery(); delivery.setResponseTimestamp(new Date(System.currentTimeMillis() - 2000)); SiriServerSubscriptionEvent event = new SiriServerSubscriptionEvent( new SubscriptionId("alpha", "beta"), "10.0.0.1", ESiriVersion.V1_3, delivery); _manager.recordPublicationStatistics(event, 1000, true); Map<String, String> status = new HashMap<String, String>(); _manager.getStatus(status); assertEquals( "1000", status.get("siri.server.activeChannel[10.0.0.1].averageTimeNeededToPublish")); long delay = Long.parseLong(status.get("siri.server.activeChannel[10.0.0.1].averagePublicationDelay")); assertEquals(delay, 2000.0, 10.0); assertEquals("1", status.get("siri.server.activeChannel[10.0.0.1].connectionErrorCount")); assertEquals(SubscriptionSupport.getDateAsString(when), status.get("siri.server.activeChannel[10.0.0.1].creationTime")); }