@SuppressWarnings("unchecked") @Test public void testUpdateRrdWithLocaleThatUsesCommasForDecimals() throws Exception { Locale defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.FRENCH); NumberFormat nf = NumberFormat.getInstance(); Assert.assertEquals("ensure that the newly set default locale (" + Locale.getDefault() + ") uses ',' as the decimal marker", "1,5", nf.format(1.5)); LatencyStoringServiceMonitorAdaptor adaptor = new LatencyStoringServiceMonitorAdaptor(null, m_pollerConfig, new Package()); LinkedHashMap<String, Number> map = new LinkedHashMap<String, Number>(); map.put("cheese", 1.5); expect(m_pollerConfig.getStep(isA(Package.class))).andReturn(0).anyTimes(); expect(m_pollerConfig.getRRAList(isA(Package.class))).andReturn(new ArrayList<String>(0)); expect(m_rrdStrategy.getDefaultFileExtension()).andReturn(".rrd").anyTimes(); expect(m_rrdStrategy.createDefinition(isA(String.class), isA(String.class), isA(String.class), anyInt(), isAList(RrdDataSource.class), isAList(String.class))).andReturn(new Object()); m_rrdStrategy.createFile(isA(Object.class), (Map<String, String>) eq(null)); expect(m_rrdStrategy.openFile(isA(String.class))).andReturn(new Object()); m_rrdStrategy.updateFile(isA(Object.class), isA(String.class), endsWith(":1.5")); m_rrdStrategy.closeFile(isA(Object.class)); m_mocks.replayAll(); adaptor.updateRRD("foo", InetAddress.getLocalHost(), "baz", map); m_mocks.verifyAll(); Locale.setDefault(defaultLocale); }
public void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value) { LinkedHashMap<String, Number> lhm = new LinkedHashMap<String, Number>(); lhm.put(dsName, value); updateRRD(repository, addr, rrdBaseName, lhm); }
LatencyStoringServiceMonitorAdaptor implements ServiceMonitor { public void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value) { LinkedHashMap<String, Number> lhm = new LinkedHashMap<String, Number>(); lhm.put(dsName, value); updateRRD(repository, addr, rrdBaseName, lhm); } }
LatencyStoringServiceMonitorAdaptor implements ServiceMonitor { public void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value) { LinkedHashMap<String, Number> lhm = new LinkedHashMap<String, Number>(); lhm.put(dsName, value); updateRRD(repository, addr, rrdBaseName, lhm); } LatencyStoringServiceMonitorAdaptor(ServiceMonitor monitor, PollerConfig config, Package pkg); }
LatencyStoringServiceMonitorAdaptor implements ServiceMonitor { public void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value) { LinkedHashMap<String, Number> lhm = new LinkedHashMap<String, Number>(); lhm.put(dsName, value); updateRRD(repository, addr, rrdBaseName, lhm); } LatencyStoringServiceMonitorAdaptor(ServiceMonitor monitor, PollerConfig config, Package pkg); void initialize(Map<String, Object> parameters); void initialize(MonitoredService svc); PollStatus poll(MonitoredService svc, Map<String, Object> parameters); void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value); void updateRRD(String repository, InetAddress addr, String rrdBaseName, LinkedHashMap<String, Number> entries); boolean createRRD(String repository, InetAddress addr, String rrdBaseName, String dsName); boolean createRRD(String repository, InetAddress addr, String rrdBaseName, List<RrdDataSource> dsList); void release(); void release(MonitoredService svc); void refreshThresholds(); }
LatencyStoringServiceMonitorAdaptor implements ServiceMonitor { public void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value) { LinkedHashMap<String, Number> lhm = new LinkedHashMap<String, Number>(); lhm.put(dsName, value); updateRRD(repository, addr, rrdBaseName, lhm); } LatencyStoringServiceMonitorAdaptor(ServiceMonitor monitor, PollerConfig config, Package pkg); void initialize(Map<String, Object> parameters); void initialize(MonitoredService svc); PollStatus poll(MonitoredService svc, Map<String, Object> parameters); void updateRRD(String repository, InetAddress addr, String rrdBaseName, String dsName, long value); void updateRRD(String repository, InetAddress addr, String rrdBaseName, LinkedHashMap<String, Number> entries); boolean createRRD(String repository, InetAddress addr, String rrdBaseName, String dsName); boolean createRRD(String repository, InetAddress addr, String rrdBaseName, List<RrdDataSource> dsList); void release(); void release(MonitoredService svc); void refreshThresholds(); static final String DEFAULT_BASENAME; }