From 14069410f14b1007c9bdb1823ca4d50ca143ab08 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 15 Feb 2002 14:54:35 +0000 Subject: [PATCH] Add testcase for sysproperty handling. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271365 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/types/CommandlineJavaTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java index d88d51aae..2cd7d7e77 100644 --- a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java +++ b/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java @@ -134,4 +134,26 @@ public class CommandlineJavaTest extends TestCase { assertEquals("arg1", s[5]); } + public void testSysproperties() { + String currentClasspath = System.getProperty("java.class.path"); + assertNotNull(currentClasspath); + assertNull(System.getProperty("key")); + CommandlineJava c = new CommandlineJava(); + Environment.Variable v = new Environment.Variable(); + v.setKey("key"); + v.setValue("value"); + c.addSysproperty(v); + try { + c.setSystemProperties(); + String newClasspath = System.getProperty("java.class.path"); + assertNotNull(newClasspath); + assertEquals(currentClasspath, newClasspath); + assertNotNull(System.getProperty("key")); + assertEquals("value", System.getProperty("key")); + } finally { + c.restoreSystemProperties(); + } + assertNull(System.getProperty("key")); + } + }