public class JavaApplication1 { public static void main(String[] args) { System.out.println("Working Directory = " + System.getProperty("user.dir")); } }
/** * 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); }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the operating system's default line separator. This method is equivalent to {@code * writeLines(lines, System.getProperty("line.separator"))}. * * @throws IOException if an I/O error occurs while writing to this sink * @since 22.0 */ @Beta public void writeLines(Stream<? extends CharSequence> lines) throws IOException { writeLines(lines, System.getProperty("line.separator")); }
/** * Writes the given lines of text to this sink with each line (including the last) terminated with * the operating system's default line separator. This method is equivalent to {@code * writeLines(lines, System.getProperty("line.separator"))}. * * @throws IOException if an I/O error occurs while writing to this sink */ public void writeLines(Iterable<? extends CharSequence> lines) throws IOException { writeLines(lines, System.getProperty("line.separator")); }
/** * Returns the current value for this system property by delegating to {@link * System#getProperty(String)}. */ public @Nullable String value() { return System.getProperty(key); }
public void testWriteLinesStream_systemDefaultSeparator() throws IOException { String separator = System.getProperty("line.separator"); sink.writeLines(lines.stream()); assertContainsExpectedLines(separator); }
@BeforeClass public static void compilerAssumptions() { // JiBX compiler is currently not compatible with JDK 9 Assume.assumeTrue(System.getProperty("java.version").startsWith("1.8.")); }
@BeforeClass public static void compilerAssumptions() { // JiBX compiler is currently not compatible with JDK 9 Assume.assumeTrue(System.getProperty("java.version").startsWith("1.8.")); }
public void testWriteLines_stream() throws IOException { sink.writeLines(ImmutableList.of("foo", "bar", "baz").stream()); String separator = System.getProperty("line.separator"); assertEquals("foo" + separator + "bar" + separator + "baz" + separator, sink.getString()); }
public void testWriteLines_systemDefaultSeparator() throws IOException { String separator = System.getProperty("line.separator"); sink.writeLines(lines); assertContainsExpectedLines(separator); }
@Test public void verifyPropertiesAreAvailableInEnvironment() { String userHomeKey = "user.home"; assertEquals(System.getProperty(userHomeKey), env.getProperty(userHomeKey)); assertEquals("enigma", env.getProperty("explicit")); }
@Test @EnabledOnMac void enabledIfWithSpelOsCheckInCustomComposedAnnotation() { String os = System.getProperty("os.name").toLowerCase(); assertTrue(os.contains("mac"), "This test must be enabled on Mac OS"); assertFalse(os.contains("win"), "This test must be disabled on Windows"); }
public void testWriteLines_withDefaultSeparator() throws IOException { sink.writeLines(ImmutableList.of("foo", "bar", "baz")); String separator = System.getProperty("line.separator"); assertEquals("foo" + separator + "bar" + separator + "baz" + separator, sink.getString()); }
@Test @DisabledOnMac void disabledIfWithSpelOsCheckInCustomComposedAnnotation() { assertFalse(System.getProperty("os.name").contains("Mac"), "This test must be disabled on Mac OS"); }
@Parameterized.Parameters(name = "server [{0}]") public static Object[][] arguments() { File base = new File(System.getProperty("java.io.tmpdir")); return new Object[][] { {new JettyHttpServer()}, {new ReactorHttpServer()}, {new TomcatHttpServer(base.getAbsolutePath())}, {new UndertowHttpServer()} }; }
@Test public void testPropertyPlaceholderConfigurerWithSystemPropertyFallback() { factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class) .addPropertyValue("country", "${os.name}").getBeanDefinition()); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); ppc.postProcessBeanFactory(factory); TestBean tb = (TestBean) factory.getBean("tb"); assertEquals(System.getProperty("os.name"), tb.getCountry()); }
public void testGetValue() { for (StandardSystemProperty property : StandardSystemProperty.values()) { assertEquals(System.getProperty(property.key()), property.value()); } }
@Test public void testCustomDestroyBean() throws Exception { beanFactory.getBean("custom-destroy"); beanFactory.destroySingletons(); assertNull(System.getProperty("security.destroy")); }
@Test public void testSpringDestroyBean() throws Exception { beanFactory.getBean("spring-destroy"); beanFactory.destroySingletons(); assertNull(System.getProperty("security.destroy")); }
@Test public void testCustomFactoryType() throws Exception { assertNull(beanFactory.getType("spring-factory")); assertNull(System.getProperty("factory.object.type")); }