public void init(long expirationPeriod, SessionLookup sessionLookup) { this.expirationTime = System.currentTimeMillis() + expirationPeriod; for (TransferSimpUser user : this.users.values()) { user.afterDeserialization(sessionLookup); } }
public class JavaApplication1 { public static void main(String[] args) { System.out.println("Working Directory = " + System.getProperty("user.dir")); } }
public static String[] concat(String[] array, String value) { String[] result = new String[array.length + 1]; System.arraycopy(array, 0, result, 0, array.length); result[result.length - 1] = value; return result; }
@Override public void setTimeout(Integer timeout) { super.setTimeout(timeout); String rmiTimeout = System.getProperty("sun.rmi.transport.tcp.responseTimeout"); if (timeout != null && timeout > 0 && (StringUtils.isEmpty(rmiTimeout))) { System.setProperty("sun.rmi.transport.tcp.responseTimeout", String.valueOf(timeout)); } }
/** * Returns the remaining nanos until the given timeout, or 0L if the timeout has already elapsed. * Caller must have previously sanitized timeoutNanos using toSafeNanos. */ private static long remainingNanos(long startTime, long timeoutNanos) { // assert timeoutNanos == 0L || startTime != 0L; // TODO : NOT CORRECT, BUT TESTS PASS ANYWAYS! // if (true) return timeoutNanos; // ONLY 2 TESTS FAIL IF WE DO: // if (true) return 0; return (timeoutNanos <= 0L) ? 0L : timeoutNanos - (System.nanoTime() - startTime); }
@Test public void getActiveProfiles_fromSystemProperties() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo"); assertThat(Arrays.asList(environment.getActiveProfiles()), hasItem("foo")); System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); }
@After public void after() { if (enabled != null) { System.setProperty("ENABLED", enabled); } else { System.clearProperty("ENABLED"); } if (context != null) { context.close(); } }
@Override public void destroy() throws Exception { System.setProperty("security.destroy", "true"); } }
/** Calls {@link System#nanoTime()}. */ @SuppressWarnings("GoodTime") // reading system time without TimeSource static long systemNanoTime() { return System.nanoTime(); }
@Test public void testReplaceFromSystemPropertyWithDefault() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:foo}"); assertEquals("bar", resolved); } finally { System.getProperties().remove("test.prop"); } }
@Test public void suppressGetenvAccessThroughSystemProperty() { System.setProperty("spring.getenv.ignore", "true"); assertTrue(environment.getSystemEnvironment().isEmpty()); System.clearProperty("spring.getenv.ignore"); }
@Override public Class getObjectType() { System.setProperty("factory.object.type", "true"); return Properties.class; }
/** * Returns the 'current time' of the Scheduler in the specified time unit. * @param unit the time unit * @return the 'current time' * @since 2.0 */ public long now(@NonNull TimeUnit unit) { return unit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS); }
/** * Get the <em>profile value</em> indicated by the specified key from the * system properties. * @see System#getProperty(String) */ @Override public String get(String key) { Assert.hasText(key, "'key' must not be empty"); return System.getProperty(key); }
@Override public Object[] toArray() { Object[] copyTo = new Object[size]; System.arraycopy(queue, 0, copyTo, 0, size); return copyTo; }
/** * Returns System.nanoTime() unless the timeout has already elapsed. Returns 0L if and only if the * timeout has already elapsed. */ private static long initNanoTime(long timeoutNanos) { if (timeoutNanos <= 0L) { return 0L; } else { long startTime = System.nanoTime(); return (startTime == 0L) ? 1L : startTime; } }
@Test public void testReplaceFromSystemPropertyWithExpressionDefault() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:#{foo.bar}}"); assertEquals("bar", resolved); } finally { System.getProperties().remove("test.prop"); } }
@Test public void resolveSystemProperty() throws Exception { System.setProperty("systemProperty", "22"); Object value = resolver.resolveArgument(paramSystemProperty, null, webRequest, null); System.clearProperty("systemProperty"); assertEquals("22", value); }
@Test public void retrieveMaxCacheSizeFromSystemPropertyContainingWhitespace() { System.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "42\t"); assertEquals(42, retrieveMaxCacheSize()); }
/** * Returns the 'current time' of the Worker in the specified time unit. * @param unit the time unit * @return the 'current time' * @since 2.0 */ public long now(@NonNull TimeUnit unit) { return unit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS); }