InfinispanPingService { protected int getTimeoutOrElse(String timeout, int defaultValue) { String t = System.getProperty(timeout); return t != null && !t.isEmpty() ? Integer.parseInt(t) : defaultValue; } InfinispanPingService(RemoteCacheImpl remoteCache); boolean ping(); void stop();  }
@Test public void testExternalTimeoutVariable() { { InfinispanPingService service = spy(new InfinispanPingService(remoteCache)); int result = service.getTimeoutOrElse(InfinispanPingService.PING, 5); assertEquals(5, result); } { System.setProperty(InfinispanPingService.PING, String.valueOf(4)); InfinispanPingService service = spy(new InfinispanPingService(remoteCache)); int result = service.getTimeoutOrElse(InfinispanPingService.PING, 5); assertEquals(4, result); } { System.setProperty(InfinispanPingService.PING, ""); InfinispanPingService service = spy(new InfinispanPingService(remoteCache)); int result = service.getTimeoutOrElse(InfinispanPingService.PING, 5); assertEquals(5, result); } }