Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@apache.org Received: (qmail 44424 invoked from network); 16 Aug 2002 14:25:13 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 16 Aug 2002 14:25:13 -0000 Received: (qmail 11687 invoked by uid 97); 16 Aug 2002 14:25:25 -0000 Delivered-To: qmlist-jakarta-archive-ant-user@jakarta.apache.org Received: (qmail 11671 invoked by uid 97); 16 Aug 2002 14:25:25 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 11659 invoked by uid 98); 16 Aug 2002 14:25:24 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-Id: <3D5D0AF1.8060802@altern.org> Date: Fri, 16 Aug 2002 16:23:45 +0200 From: Jerome Lacoste User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020811 X-Accept-Language: en-us, en MIME-Version: 1.0 To: ant-user@jakarta.apache.org Subject: System.getProperties() returns an empty list when unit test runwithin Ant Content-Type: multipart/mixed; boundary="------------030800000306050006050107" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------030800000306050006050107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Anties, I've got this strange problem: one of my UnitTest fails when I run it within Ant, while it doens't fail when I run it directly from the same VM. I've had trouble like that before and they are usualy environment related but this one is very strange: Here's the code of my Unit Test: public void testSystemGetProperties() { // Skip debug code to printout System.getProperties() ... if (System.getProperties().size() == 0) { fail("WARNING something is wrong in your environment. System.getProperties().size() == 0"); } } As you can see, System.getProperties().size() == 0 fails when I run this test within ant. According to the API this should never happen. Even more strange is that if I try to access any single System property within the same code, I will obtain it without problem! I.e. System.getProperty("user.dir") works OK but System.getProperties() still returns an empty list!! The following batch file demonstrate the problem for me: > type runtest.bat %JAVA_HOME%\bin\java -cp classes\test;classes;lib\junit3.7\junit.jar;lib\log4j\log4j-1.2.4.jar no.bbc.basis.util.PropertyFileReaderTest ant test.case -Dtestcase=no.bbc.basis.util.PropertyFileReaderTest The first call works while the second doesn't My Ant test.case target is realy simple: where the classpath is set using a fileset filter of all jar file in my lib directories + my classes dir It seems to be an environment problem, but I can't figure it out. I first though it to be a JDK problem, but given the fact that my test works when I invoke it from the command line but not within Ant, I am confused. I've searched throught the Ant mailing list, the releases notes for Ant 1.5, Sun's bug database and Google without luck. I am currently downloading a newer version of Ant (1.5) and of the JDK (1.4.1beta) to rerun my tests, but on my modem line, it's going to take some time. In the meantime I submit my problem to you in case one of you spots a problem. Some more information about my environment: I am developing on WinNT 4.0. Here's my environment: ANT_HOME=D:\dev\jakarta-ant-1.4.1 CLASSPATH=D:\j2sdk1.4.0_01\lib\tools.jar JAVA_HOME=D:\j2sdk1.4.0_01 Path=D:\dev\jakarta-ant-1.4.1\bin;C:\WINNT\SYSTEM32;C:\WINNT;C:\WINNT\SYSTEM32\WBEM;C:\DMI\WIN32\BIN;D:\PROGRA~1\ULTRAE~1 D:\>ant -version Ant version 1.4.1 compiled on October 11 2001 >%JAVA_HOME%\bin\java -version java version "1.4.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03) Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode) Attached are: - SysProp_fromJDK: output of Properties printed out by my test code when code executed from the command line: - SysProp_fromAnt: Same properties printed out by my test code when code is executed within Ant Notice how System.getProperties() displays 0 elements but all its properties are effectively found! Here's the diff of the two output files: Comparing: D:\Projects\Basis\ProofOfConcept\bugs\System_getProperties_in_Ant\SysProp_fromAnt.txt To: D:\Projects\Basis\ProofOfConcept\bugs\System_getProperties_in_Ant\SysProp_fromJDK.txt ==== ==== 2 Displaying 50 element(s) in properties [System.getProperties()]: 32 user.timezone=Europe/Berlin !> p->user.timezone= 36 java.class.path=D:\j2sdk1.4.0_01\lib\tools.jar;D:\dev\jakarta-ant-1.4.1\lib\optional.jar;D:\dev\jakarta-ant-1.4.1\lib\junit.jar;D:\dev\jakarta-ant-1.4.1\lib\jaxp.jar;D:\dev\jakarta-ant-1.4.1\lib\crimson.jar;D:\dev\jakarta-ant-1.4.1\lib\ant.jar;D:\j2sdk1.4.0_01\lib\tools.jar !> p->java.class.path=classes\test;classes;lib\junit3.7\junit.jar;lib\log4j\log4j-1.2.4.jar [Don't ask me why the "user.timezone" is not properly propagated.] Only noticeable difference is the java.class.path, but isn't that normal? Cheers, Jerome --------------030800000306050006050107 Content-Type: text/plain; name="SysProp_fromJDK.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SysProp_fromJDK.txt" testSystemGetProperties Displaying 50 element(s) in properties [System.getProperties()]: p->java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition p->sun.boot.library.path=D:\j2sdk1.4.0_01\jre\bin p->java.vm.version=1.4.0_01-b03 p->java.vm.vendor=Sun Microsystems Inc. p->java.vendor.url=http://java.sun.com/ p->path.separator=; p->java.vm.name=Java HotSpot(TM) Client VM p->file.encoding.pkg=sun.io p->user.country=US p->sun.os.patch.level=Service Pack 6 p->java.vm.specification.name=Java Virtual Machine Specification p->user.dir=D:\Projects\Basis\ProofOfConcept p->java.runtime.version=1.4.0_01-b03 p->java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment p->java.endorsed.dirs=D:\j2sdk1.4.0_01\jre\lib\endorsed p->os.arch=x86 p->java.io.tmpdir=C:\TEMP\ p->line.separator= p->java.vm.specification.vendor=Sun Microsystems Inc. p->user.variant= p->os.name=Windows NT p->sun.java2d.fontpath= p->java.library.path=D:\j2sdk1.4.0_01\bin;.;C:\WINNT\System32;C:\WINNT;D:\dev\jakarta-ant-1.4.1\bin;C:\WINNT\SYSTEM32;C:\WINNT;C:\WINNT\SYSTEM32\WBEM;C:\DMI\WIN32\BIN;D:\PROGRA~1\ULTRAE~1 p->java.specification.name=Java Platform API Specification p->java.class.version=48.0 p->java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory p->os.version=4.0 p->user.home=C:\WINNT\Profiles\Jerome p->user.timezone= p->java.awt.printerjob=sun.awt.windows.WPrinterJob p->file.encoding=Cp1252 p->java.specification.version=1.4 p->java.class.path=classes\test;classes;lib\junit3.7\junit.jar;lib\log4j\log4j-1.2.4.jar p->user.name=Jerome p->java.vm.specification.version=1.0 p->java.home=D:\j2sdk1.4.0_01\jre p->sun.arch.data.model=32 p->user.language=en p->java.specification.vendor=Sun Microsystems Inc. p->awt.toolkit=sun.awt.windows.WToolkit p->java.vm.info=mixed mode p->java.version=1.4.0_01 p->java.ext.dirs=D:\j2sdk1.4.0_01\jre\lib\ext p->sun.boot.class.path=D:\j2sdk1.4.0_01\jre\lib\rt.jar;D:\j2sdk1.4.0_01\jre\lib\i18n.jar;D:\j2sdk1.4.0_01\jre\lib\sunrsasign.jar;D:\j2sdk1.4.0_01\jre\lib\jsse.jar;D:\j2sdk1.4.0_01\jre\lib\jce.jar;D:\j2sdk1.4.0_01\jre\lib\charsets.jar;D:\j2sdk1.4.0_01\jre\classes p->java.vendor=Sun Microsystems Inc. p->file.separator=\ p->java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi p->sun.io.unicode.encoding=UnicodeLittle p->sun.cpu.endian=little p->sun.cpu.isalist= --------------030800000306050006050107 Content-Type: text/plain; name="SysProp_fromAnt.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SysProp_fromAnt.txt" testSystemGetProperties Displaying 0 element(s) in properties [System.getProperties()]: p->java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition p->sun.boot.library.path=D:\j2sdk1.4.0_01\jre\bin p->java.vm.version=1.4.0_01-b03 p->java.vm.vendor=Sun Microsystems Inc. p->java.vendor.url=http://java.sun.com/ p->path.separator=; p->java.vm.name=Java HotSpot(TM) Client VM p->file.encoding.pkg=sun.io p->user.country=US p->sun.os.patch.level=Service Pack 6 p->java.vm.specification.name=Java Virtual Machine Specification p->user.dir=D:\Projects\Basis\ProofOfConcept p->java.runtime.version=1.4.0_01-b03 p->java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment p->java.endorsed.dirs=D:\j2sdk1.4.0_01\jre\lib\endorsed p->os.arch=x86 p->java.io.tmpdir=C:\TEMP\ p->line.separator= p->java.vm.specification.vendor=Sun Microsystems Inc. p->user.variant= p->os.name=Windows NT p->sun.java2d.fontpath= p->java.library.path=D:\j2sdk1.4.0_01\bin;.;C:\WINNT\System32;C:\WINNT;D:\dev\jakarta-ant-1.4.1\bin;C:\WINNT\SYSTEM32;C:\WINNT;C:\WINNT\SYSTEM32\WBEM;C:\DMI\WIN32\BIN;D:\PROGRA~1\ULTRAE~1 p->java.specification.name=Java Platform API Specification p->java.class.version=48.0 p->java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory p->os.version=4.0 p->user.home=C:\WINNT\Profiles\Jerome p->user.timezone=Europe/Berlin p->java.awt.printerjob=sun.awt.windows.WPrinterJob p->file.encoding=Cp1252 p->java.specification.version=1.4 p->java.class.path=D:\j2sdk1.4.0_01\lib\tools.jar;D:\dev\jakarta-ant-1.4.1\lib\optional.jar;D:\dev\jakarta-ant-1.4.1\lib\junit.jar;D:\dev\jakarta-ant-1.4.1\lib\jaxp.jar;D:\dev\jakarta-ant-1.4.1\lib\crimson.jar;D:\dev\jakarta-ant-1.4.1\lib\ant.jar;D:\j2sdk1.4.0_01\lib\tools.jar p->user.name=Jerome p->java.vm.specification.version=1.0 p->java.home=D:\j2sdk1.4.0_01\jre p->sun.arch.data.model=32 p->user.language=en p->java.specification.vendor=Sun Microsystems Inc. p->awt.toolkit=sun.awt.windows.WToolkit p->java.vm.info=mixed mode p->java.version=1.4.0_01 p->java.ext.dirs=D:\j2sdk1.4.0_01\jre\lib\ext p->sun.boot.class.path=D:\j2sdk1.4.0_01\jre\lib\rt.jar;D:\j2sdk1.4.0_01\jre\lib\i18n.jar;D:\j2sdk1.4.0_01\jre\lib\sunrsasign.jar;D:\j2sdk1.4.0_01\jre\lib\jsse.jar;D:\j2sdk1.4.0_01\jre\lib\jce.jar;D:\j2sdk1.4.0_01\jre\lib\charsets.jar;D:\j2sdk1.4.0_01\jre\classes p->java.vendor=Sun Microsystems Inc. p->file.separator=\ p->java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi p->sun.io.unicode.encoding=UnicodeLittle p->sun.cpu.endian=little p->sun.cpu.isalist= --------------030800000306050006050107 Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: --------------030800000306050006050107--