summaryrefslogtreecommitdiffstats
path: root/test/Java
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-11-21 21:14:41 (GMT)
committerSteven Knight <knight@baldmt.com>2004-11-21 21:14:41 (GMT)
commit9ee53a60a770d6f5a33624405d35ad4063378367 (patch)
tree361012066ed284ecad1482552d177f86a0cd664d /test/Java
parent07c75889f874a050aff782d1488d0269fb936744 (diff)
downloadSCons-9ee53a60a770d6f5a33624405d35ad4063378367.zip
SCons-9ee53a60a770d6f5a33624405d35ad4063378367.tar.gz
SCons-9ee53a60a770d6f5a33624405d35ad4063378367.tar.bz2
More command-line output customizability: , , , .
Diffstat (limited to 'test/Java')
-rw-r--r--test/Java/JAR.py266
-rw-r--r--test/Java/JARCOM.py65
-rw-r--r--test/Java/JARCOMSTR.py69
-rw-r--r--test/Java/JARFLAGS.py94
-rw-r--r--test/Java/JAVAC.py314
-rw-r--r--test/Java/JAVACCOM.py68
-rw-r--r--test/Java/JAVACCOMSTR.py72
-rw-r--r--test/Java/JAVACFLAGS.py73
-rw-r--r--test/Java/JAVAH.py315
-rw-r--r--test/Java/JAVAHCOM.py69
-rw-r--r--test/Java/JAVAHCOMSTR.py85
-rw-r--r--test/Java/RMIC.py325
-rw-r--r--test/Java/RMICCOM.py79
-rw-r--r--test/Java/RMICCOMSTR.py85
14 files changed, 1979 insertions, 0 deletions
diff --git a/test/Java/JAR.py b/test/Java/JAR.py
new file mode 100644
index 0000000..ea51213
--- /dev/null
+++ b/test/Java/JAR.py
@@ -0,0 +1,266 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.write('myjar.py', r"""
+import sys
+args = sys.argv[1:]
+while args:
+ a = args[0]
+ if a == 'cf':
+ out = args[1]
+ args = args[1:]
+ else:
+ break
+ args = args[1:]
+outfile = open(out, 'wb')
+for file in args:
+ infile = open(file, 'rb')
+ for l in infile.readlines():
+ if l[:7] != '/*jar*/':
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(tools = ['jar'],
+ JAR = r'%s myjar.py')
+env.Jar(target = 'test1.jar', source = 'test1.class')
+""" % (python))
+
+test.write('test1.class', """\
+test1.class
+/*jar*/
+line 3
+""")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test1.jar', "test1.class\nline 3\n")
+
+if os.path.normcase('.class') == os.path.normcase('.CLASS'):
+
+ test.write('SConstruct', """
+env = Environment(tools = ['jar'],
+ JAR = r'%s myjar.py')
+env.Jar(target = 'test2.jar', source = 'test2.CLASS')
+""" % (python))
+
+ test.write('test2.CLASS', """\
+test2.CLASS
+/*jar*/
+line 3
+""")
+
+ test.run(arguments = '.', stderr = None)
+
+ test.must_match('test2.jar', "test2.CLASS\nline 3\n")
+
+test.write('myjar2.py', r"""
+import sys
+import string
+f=open(sys.argv[2], 'wb')
+f.write(string.join(sys.argv[1:]))
+f.write("\n")
+f.close()
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(tools = ['jar'],
+ JAR = r'%s myjar2.py',
+ JARFLAGS='cvf')
+env.Jar(target = 'classes.jar', source = [ 'testdir/bar.class',
+ 'foo.mf' ],
+ TESTDIR='testdir',
+ JARCHDIR='$TESTDIR')
+""" % (python))
+
+test.subdir('testdir')
+test.write([ 'testdir', 'bar.class' ], 'foo')
+test.write('foo.mf',
+ """Manifest-Version : 1.0
+ blah
+ blah
+ blah
+ """)
+test.run(arguments='classes.jar')
+test.must_match('classes.jar',
+ 'cvfm classes.jar foo.mf -C testdir bar.class\n')
+
+if test.detect_tool('javac'):
+ where_javac = test.detect('JAVAC', 'javac')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javac = env.WhereIs('javac', os.environ['PATH'])
+ if not where_javac:
+ where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+if test.detect_tool('jar'):
+ where_jar = test.detect('JAR', 'jar')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_jar = env.WhereIs('jar', os.environ['PATH'])
+ if not where_jar:
+ where_jar = env.WhereIs('jar', '/usr/local/j2sdk1.3.1/bin')
+ if not where_jar:
+ print "Could not find Java jar, skipping test(s)."
+ test.pass_test(1)
+
+
+test.write("wrapper.py", """\
+import os
+import string
+import sys
+open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:]))
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+foo = Environment(tools = ['javac', 'jar'],
+ JAVAC = '%(where_javac)s',
+ JAR = '%(where_jar)s')
+jar = foo.Dictionary('JAR')
+bar = foo.Copy(JAR = r'%(python)s wrapper.py ' + jar)
+foo.Java(target = 'classes', source = 'com/sub/foo')
+bar.Java(target = 'classes', source = 'com/sub/bar')
+foo.Jar(target = 'foo', source = 'classes/com/sub/foo')
+bar.Jar(target = 'bar', source = 'classes/com/sub/bar')
+""" % locals())
+
+test.subdir('com',
+ ['com', 'sub'],
+ ['com', 'sub', 'foo'],
+ ['com', 'sub', 'bar'])
+
+test.write(['com', 'sub', 'foo', 'Example1.java'], """\
+package com.sub.foo;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example2.java'], """\
+package com.sub.foo;
+
+public class Example2
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example3.java'], """\
+package com.sub.foo;
+
+public class Example3
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example4.java'], """\
+package com.sub.bar;
+
+public class Example4
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example5.java'], """\
+package com.sub.bar;
+
+public class Example5
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example6.java'], """\
+package com.sub.bar;
+
+public class Example6
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.run(arguments = '.')
+
+test.must_match('wrapper.out',
+ "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" % locals())
+
+test.must_exist('foo.jar')
+test.must_exist('bar.jar')
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
diff --git a/test/Java/JARCOM.py b/test/Java/JARCOM.py
new file mode 100644
index 0000000..0d7ebba
--- /dev/null
+++ b/test/Java/JARCOM.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ability to configure the $JARCOM construction variable.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+
+
+test.write('myjar.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*jar*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'jar'],
+ JARCOM = r'%(python)s myjar.py $TARGET $SOURCES')
+env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in'])
+""" % locals())
+
+test.write('file1.in', "file1.in\n/*jar*/\n")
+test.write('file2.in', "file2.in\n/*jar*/\n")
+test.write('file3.in', "file3.in\n/*jar*/\n")
+
+test.run()
+
+test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/JARCOMSTR.py b/test/Java/JARCOMSTR.py
new file mode 100644
index 0000000..aa8a6ad
--- /dev/null
+++ b/test/Java/JARCOMSTR.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that the $JARCOMSTR construction variable allows you to configure
+the jar output.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+
+
+test.write('myjar.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*jar*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'jar'],
+ JARCOM = r'%(python)s myjar.py $TARGET $SOURCES',
+ JARCOMSTR = "Jar'ing up $TARGET from $SOURCES")
+env.Jar(target = 'test1', source = ['file1.in', 'file2.in', 'file3.in'])
+""" % locals())
+
+test.write('file1.in', "file1.in\n/*jar*/\n")
+test.write('file2.in', "file2.in\n/*jar*/\n")
+test.write('file3.in', "file3.in\n/*jar*/\n")
+
+test.run(stdout = test.wrap_stdout("""\
+Jar'ing up test1.jar from file1.in file2.in file3.in
+"""))
+
+test.must_match('test1.jar', "file1.in\nfile2.in\nfile3.in\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py
new file mode 100644
index 0000000..7e3669d
--- /dev/null
+++ b/test/Java/JARFLAGS.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+if test.detect_tool('javac'):
+ where_javac = test.detect('JAVAC', 'javac')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javac = env.WhereIs('javac', os.environ['PATH'])
+ if not where_javac:
+ where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+if test.detect_tool('jar'):
+ where_jar = test.detect('JAR', 'jar')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_jar = env.WhereIs('jar', os.environ['PATH'])
+ if not where_jar:
+ where_jar = env.WhereIs('jar', '/usr/local/j2sdk1.3.1/bin')
+ if not where_jar:
+ print "Could not find Java jar, skipping test(s)."
+ test.pass_test(1)
+
+test.write('SConstruct', """
+env = Environment(tools = ['javac', 'jar'],
+ JAVAC = '%(where_javac)s',
+ JAR = '%(where_jar)s',
+ JARFLAGS = 'cvf')
+env['JARFLAGS'] = 'cvf'
+class_files = env.Java(target = 'classes', source = 'src')
+env.Jar(target = 'test.jar', source = class_files)
+""" % locals())
+
+test.write(['src', 'Example1.java'], """\
+package src;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.run(arguments = '.',
+ match=TestSCons.match_re_dotall,
+ stdout = test.wrap_stdout("""\
+%(where_javac)s -d classes -sourcepath src src/Example1\.java
+%(where_jar)s cvf test.jar classes/src/Example1\.class
+.*
+adding: classes/src/Example1\.class.*
+""" % locals()))
+
+test.must_exist('test.jar')
+
+test.pass_test()
diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py
new file mode 100644
index 0000000..779045f
--- /dev/null
+++ b/test/Java/JAVAC.py
@@ -0,0 +1,314 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+
+
+test.write('myjavac.py', r"""
+import sys
+args = sys.argv[1:]
+while args:
+ a = args[0]
+ if a == '-d':
+ args = args[1:]
+ elif a == '-sourcepath':
+ args = args[1:]
+ else:
+ break
+ args = args[1:]
+for file in args:
+ infile = open(file, 'rb')
+ outfile = open(file[:-5] + '.class', 'wb')
+ for l in infile.readlines():
+ if l[:9] != '/*javac*/':
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(tools = ['javac'],
+ JAVAC = r'%s myjavac.py')
+env.Java(target = '.', source = '.')
+""" % (python))
+
+test.write('test1.java', """\
+test1.java
+/*javac*/
+line 3
+""")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test1.class', "test1.java\nline 3\n")
+
+if os.path.normcase('.java') == os.path.normcase('.JAVA'):
+
+ test.write('SConstruct', """\
+env = Environment(tools = ['javac'],
+ JAVAC = r'%s myjavac.py')
+env.Java(target = '.', source = '.')
+""" % python)
+
+ test.write('test2.JAVA', """\
+test2.JAVA
+/*javac*/
+line 3
+""")
+
+ test.run(arguments = '.', stderr = None)
+
+ test.must_match('test2.class', "test2.JAVA\nline 3\n")
+
+
+if test.detect_tool('javac'):
+ where_javac = test.detect('JAVAC', 'javac')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javac = env.WhereIs('javac', os.environ['PATH'])
+ if not where_javac:
+ where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javac:
+ print "Could not find Java, skipping test(s)."
+ test.pass_test(1)
+
+
+
+test.write("wrapper.py", """\
+import os
+import string
+import sys
+open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:]))
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+foo = Environment(tools = ['javac'],
+ JAVAC = '%s')
+javac = foo.Dictionary('JAVAC')
+bar = foo.Copy(JAVAC = r'%s wrapper.py ' + javac)
+foo.Java(target = 'class1', source = 'com/sub/foo')
+bar.Java(target = 'class2', source = 'com/sub/bar')
+foo.Java(target = 'class3', source = ['src1', 'src2'])
+""" % (where_javac, python))
+
+test.subdir('com',
+ ['com', 'sub'],
+ ['com', 'sub', 'foo'],
+ ['com', 'sub', 'bar'],
+ 'src1',
+ 'src2')
+
+test.write(['com', 'sub', 'foo', 'Example1.java'], """\
+package com.sub.foo;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example2.java'], """\
+package com.other;
+
+public class Example2
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example3.java'], """\
+package com.sub.foo;
+
+public class Example3
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example4.java'], """\
+package com.sub.bar;
+
+public class Example4
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example5.java'], """\
+package com.other;
+
+public class Example5
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example6.java'], """\
+package com.sub.bar;
+
+public class Example6
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['src1', 'Example7.java'], """\
+public class Example7
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+# Acid-test file for parsing inner Java classes, courtesy Chad Austin.
+test.write(['src2', 'Test.java'], """\
+class Empty {
+}
+
+interface Listener {
+ public void execute();
+}
+
+public
+class
+Test {
+ class Inner {
+ void go() {
+ use(new Listener() {
+ public void execute() {
+ System.out.println("In Inner");
+ }
+ });
+ }
+ String s1 = "class A";
+ String s2 = "new Listener() { }";
+ /* class B */
+ /* new Listener() { } */
+ }
+
+ public static void main(String[] args) {
+ new Test().run();
+ }
+
+ void run() {
+ use(new Listener() {
+ public void execute() {
+ use(new Listener( ) {
+ public void execute() {
+ System.out.println("Inside execute()");
+ }
+ });
+ }
+ });
+
+ new Inner().go();
+ }
+
+ void use(Listener l) {
+ l.execute();
+ }
+}
+
+class Private {
+ void run() {
+ new Listener() {
+ public void execute() {
+ }
+ };
+ }
+}
+""")
+
+test.run(arguments = '.')
+
+test.must_match('wrapper.out', "wrapper.py %s -d class2 -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n" % where_javac)
+
+test.must_exist(test.workpath('class1', 'com', 'sub', 'foo', 'Example1.class'))
+test.must_exist(test.workpath('class1', 'com', 'other', 'Example2.class'))
+test.must_exist(test.workpath('class1', 'com', 'sub', 'foo', 'Example3.class'))
+
+test.must_exist(test.workpath('class2', 'com', 'sub', 'bar', 'Example4.class'))
+test.must_exist(test.workpath('class2', 'com', 'other', 'Example5.class'))
+test.must_exist(test.workpath('class2', 'com', 'sub', 'bar', 'Example6.class'))
+
+test.must_exist(test.workpath('class3', 'Example7.class'))
+
+test.must_exist(test.workpath('class3', 'Empty.class'))
+test.must_exist(test.workpath('class3', 'Listener.class'))
+test.must_exist(test.workpath('class3', 'Private.class'))
+test.must_exist(test.workpath('class3', 'Private$1.class'))
+test.must_exist(test.workpath('class3', 'Test.class'))
+test.must_exist(test.workpath('class3', 'Test$1.class'))
+test.must_exist(test.workpath('class3', 'Test$2.class'))
+test.must_exist(test.workpath('class3', 'Test$3.class'))
+test.must_exist(test.workpath('class3', 'Test$Inner.class'))
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
diff --git a/test/Java/JAVACCOM.py b/test/Java/JAVACCOM.py
new file mode 100644
index 0000000..171649c
--- /dev/null
+++ b/test/Java/JAVACCOM.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ability to configure the $JAVACCOM construction variable.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+
+
+test.write('myjavac.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*javac*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'javac'],
+ JAVACCOM = r'%(python)s myjavac.py $TARGET $SOURCES')
+env.Java(target = 'classes', source = 'src')
+""" % locals())
+
+test.write(['src', 'file1.java'], "file1.java\n/*javac*/\n")
+test.write(['src', 'file2.java'], "file2.java\n/*javac*/\n")
+test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n")
+
+test.run()
+
+test.must_match(['classes', 'src', 'file1.class'],
+ "file1.java\nfile2.java\nfile3.java\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/JAVACCOMSTR.py b/test/Java/JAVACCOMSTR.py
new file mode 100644
index 0000000..306ae57
--- /dev/null
+++ b/test/Java/JAVACCOMSTR.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that the $JAVACCOMSTR construction variable allows you to configure
+the javac output.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+
+
+test.write('myjavac.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*javac*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'javac'],
+ JAVACCOM = r'%(python)s myjavac.py $TARGET $SOURCES',
+ JAVACCOMSTR = "Compiling class(es) $TARGET from $SOURCES")
+env.Java(target = 'classes', source = 'src')
+""" % locals())
+
+test.write(['src', 'file1.java'], "file1.java\n/*javac*/\n")
+test.write(['src', 'file2.java'], "file2.java\n/*javac*/\n")
+test.write(['src', 'file3.java'], "file3.java\n/*javac*/\n")
+
+test.run(stdout = test.wrap_stdout("""\
+Compiling class(es) classes/src/file1.class from src/file1.java src/file2.java src/file3.java
+"""))
+
+test.must_match(['classes', 'src', 'file1.class'],
+ "file1.java\nfile2.java\nfile3.java\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py
new file mode 100644
index 0000000..ef084cd
--- /dev/null
+++ b/test/Java/JAVACFLAGS.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if test.detect_tool('javac'):
+ where_javac = test.detect('JAVAC', 'javac')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javac = env.WhereIs('javac', os.environ['PATH'])
+ if not where_javac:
+ where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+test.subdir('src')
+
+test.write('SConstruct', """
+env = Environment(tools = ['javac'],
+ JAVAC = '%(where_javac)s',
+ JAVACFLAGS = '-O')
+env.Java(target = 'classes', source = 'src')
+""" % locals())
+
+test.write(['src', 'Example1.java'], """\
+package src;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.run(arguments = '.',
+ stdout = test.wrap_stdout("%(where_javac)s -O -d classes -sourcepath src src/Example1.java\n" % locals()))
+
+test.must_exist(['classes', 'src', 'Example1.class'])
+
+test.pass_test()
diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py
new file mode 100644
index 0000000..b70fde0
--- /dev/null
+++ b/test/Java/JAVAH.py
@@ -0,0 +1,315 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.write('myjavah.py', r"""
+import sys
+args = sys.argv[1:]
+while args:
+ a = args[0]
+ if a == '-d':
+ outdir = args[1]
+ args = args[1:]
+ elif a == '-o':
+ outfile = open(args[1], 'wb')
+ args = args[1:]
+ elif a == '-classpath':
+ args = args[1:]
+ elif a == '-sourcepath':
+ args = args[1:]
+ else:
+ break
+ args = args[1:]
+for file in args:
+ infile = open(file, 'rb')
+ for l in infile.readlines():
+ if l[:9] != '/*javah*/':
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(tools = ['javah'],
+ JAVAH = r'%s myjavah.py')
+env.JavaH(target = File('test1.h'), source = 'test1.java')
+""" % (python))
+
+test.write('test1.java', """\
+test1.java
+/*javah*/
+line 3
+""")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test1.h', "test1.java\nline 3\n")
+
+if os.path.normcase('.java') == os.path.normcase('.JAVA'):
+
+ test.write('SConstruct', """\
+env = Environment(tools = ['javah'],
+ JAVAH = r'%s myjavah.py')
+env.JavaH(target = File('test2.h'), source = 'test2.JAVA')
+""" % python)
+
+ test.write('test2.JAVA', """\
+test2.JAVA
+/*javah*/
+line 3
+""")
+
+ test.run(arguments = '.', stderr = None)
+
+ test.must_match('test2.h', "test2.JAVA\nline 3\n")
+
+
+if test.detect_tool('javac'):
+ where_javac = test.detect('JAVAC', 'javac')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javac = env.WhereIs('javac', os.environ['PATH'])
+ if not where_javac:
+ where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javac:
+ print "Could not find Java javac, skipping test(s)."
+ test.pass_test(1)
+
+if test.detect_tool('javah'):
+ where_javah = test.detect('JAVAH', 'javah')
+else:
+ import SCons.Environment
+ env = SCons.Environment.Environment()
+ where_javah = env.WhereIs('javah', os.environ['PATH'])
+ if not where_javah:
+ where_javah = env.WhereIs('javah', '/usr/local/j2sdk1.3.1/bin')
+ if not where_javah:
+ print "Could not find Java javah, skipping test(s)."
+ test.pass_test(1)
+
+
+
+test.write("wrapper.py", """\
+import os
+import string
+import sys
+open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:]))
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+foo = Environment(tools = ['javac', 'javah'],
+ JAVAC = '%(where_javac)s',
+ JAVAH = '%(where_javah)s')
+javah = foo.Dictionary('JAVAH')
+bar = foo.Copy(JAVAH = r'%(python)s wrapper.py ' + javah)
+foo.Java(target = 'class1', source = 'com/sub/foo')
+bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar')
+foo_classes = foo.Java(target = 'class3', source = 'src')
+foo.JavaH(target = 'outdir1',
+ source = ['class1/com/sub/foo/Example1.class',
+ 'class1/com/other/Example2',
+ 'class1/com/sub/foo/Example3'],
+ JAVACLASSDIR = 'class1')
+bar.JavaH(target = 'outdir2', source = bar_classes)
+foo.JavaH(target = File('output.h'), source = foo_classes)
+foo.Install('class4/com/sub/foo', 'class1/com/sub/foo/Example1.class')
+foo.JavaH(target = 'outdir4',
+ source = ['class4/com/sub/foo/Example1.class'],
+ JAVACLASSDIR = 'class4')
+""" % locals())
+
+test.subdir('com',
+ ['com', 'sub'],
+ ['com', 'sub', 'foo'],
+ ['com', 'sub', 'bar'],
+ 'src')
+
+test.write(['com', 'sub', 'foo', 'Example1.java'], """\
+package com.sub.foo;
+
+public class Example1
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example2.java'], """\
+package com.other;
+
+public class Example2
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example3.java'], """\
+package com.sub.foo;
+
+public class Example3
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example4.java'], """\
+package com.sub.bar;
+
+public class Example4
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example5.java'], """\
+package com.other;
+
+public class Example5
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example6.java'], """\
+package com.sub.bar;
+
+public class Example6
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
+""")
+
+test.write(['src', 'Test.java'], """\
+class Empty {
+}
+
+interface Listener {
+ public void execute();
+}
+
+public
+class
+Test {
+ class Inner {
+ void go() {
+ use(new Listener() {
+ public void execute() {
+ System.out.println("In Inner");
+ }
+ });
+ }
+ String s1 = "class A";
+ String s2 = "new Listener() { }";
+ /* class B */
+ /* new Listener() { } */
+ }
+
+ public static void main(String[] args) {
+ new Test().run();
+ }
+
+ void run() {
+ use(new Listener() {
+ public void execute() {
+ use(new Listener( ) {
+ public void execute() {
+ System.out.println("Inside execute()");
+ }
+ });
+ }
+ });
+
+ new Inner().go();
+ }
+
+ void use(Listener l) {
+ l.execute();
+ }
+}
+
+class Private {
+ void run() {
+ new Listener() {
+ public void execute() {
+ }
+ };
+ }
+}
+""")
+
+test.run(arguments = '.')
+
+test.fail_test(test.read('wrapper.out') != "wrapper.py %(where_javah)s -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" % locals())
+
+test.must_exist(['outdir1', 'com_sub_foo_Example1.h'])
+test.must_exist(['outdir1', 'com_other_Example2.h'])
+test.must_exist(['outdir1', 'com_sub_foo_Example3.h'])
+
+test.must_exist(['outdir2', 'com_sub_bar_Example4.h'])
+test.must_exist(['outdir2', 'com_other_Example5.h'])
+test.must_exist(['outdir2', 'com_sub_bar_Example6.h'])
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
diff --git a/test/Java/JAVAHCOM.py b/test/Java/JAVAHCOM.py
new file mode 100644
index 0000000..1cc4208
--- /dev/null
+++ b/test/Java/JAVAHCOM.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ability to configure the $JAVAHCOM construction variable.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+
+
+test.write('myjavah.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*javah*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'javah'],
+ JAVAHCOM = r'%(python)s myjavah.py $TARGET $SOURCES')
+env.JavaH(target = 'out', source = 'file1.class')
+env.JavaH(target = 'out', source = 'file2.class')
+env.JavaH(target = 'out', source = 'file3.class')
+""" % locals())
+
+test.write('file1.class', "file1.class\n/*javah*/\n")
+test.write('file2.class', "file2.class\n/*javah*/\n")
+test.write('file3.class', "file3.class\n/*javah*/\n")
+
+test.run()
+
+test.must_match(['out', 'file1.h'], "file1.class\n")
+test.must_match(['out', 'file2.h'], "file2.class\n")
+test.must_match(['out', 'file3.h'], "file3.class\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/JAVAHCOMSTR.py b/test/Java/JAVAHCOMSTR.py
new file mode 100644
index 0000000..2a14e1c
--- /dev/null
+++ b/test/Java/JAVAHCOMSTR.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that the $JAVAHCOMSTR construction variable allows you to configure
+the javah output.
+"""
+
+import os.path
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+
+
+out_file1_h = os.path.join('out', 'file1.h')
+out_file2_h = os.path.join('out', 'file2.h')
+out_file3_h = os.path.join('out', 'file3.h')
+
+
+
+test.write('myjavah.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*javah*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'javah'],
+ JAVAHCOM = r'%(python)s myjavah.py $TARGET $SOURCES',
+ JAVAHCOMSTR = 'Building javah $TARGET from $SOURCES')
+env.JavaH(target = 'out', source = 'file1.class')
+env.JavaH(target = 'out', source = 'file2.class')
+env.JavaH(target = 'out', source = 'file3.class')
+""" % locals())
+
+test.write('file1.class', "file1.class\n/*javah*/\n")
+test.write('file2.class', "file2.class\n/*javah*/\n")
+test.write('file3.class', "file3.class\n/*javah*/\n")
+
+test.run(stdout = test.wrap_stdout("""\
+Building javah %(out_file1_h)s from file1.class
+Building javah %(out_file2_h)s from file2.class
+Building javah %(out_file3_h)s from file3.class
+""" % locals()))
+
+test.must_match(['out', 'file1.h'], "file1.class\n")
+test.must_match(['out', 'file2.h'], "file2.class\n")
+test.must_match(['out', 'file3.h'], "file3.class\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/RMIC.py b/test/Java/RMIC.py
new file mode 100644
index 0000000..8f3623c
--- /dev/null
+++ b/test/Java/RMIC.py
@@ -0,0 +1,325 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.write('myrmic.py', r"""
+import os.path
+import sys
+args = sys.argv[1:]
+while args:
+ a = args[0]
+ if a == '-d':
+ outdir = args[1]
+ args = args[1:]
+ elif a == '-classpath':
+ args = args[1:]
+ elif a == '-sourcepath':
+ args = args[1:]
+ else:
+ break
+ args = args[1:]
+for file in args:
+ infile = open(file, 'rb')
+ outfile = open(os.path.join(outdir, file[:-5] + '.class'), 'wb')
+ for l in infile.readlines():
+ if l[:8] != '/*rmic*/':
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(tools = ['rmic'],
+ RMIC = r'%s myrmic.py')
+env.RMIC(target = 'outdir', source = 'test1.java')
+""" % (python))
+
+test.write('test1.java', """\
+test1.java
+/*rmic*/
+line 3
+""")
+
+test.run(arguments = '.', stderr = None)
+
+test.fail_test(test.read(['outdir', 'test1.class']) != "test1.java\nline 3\n")
+
+if os.path.normcase('.java') == os.path.normcase('.JAVA'):
+
+ test.write('SConstruct', """\
+env = Environment(tools = ['rmic'],
+ RMIC = r'%s myrmic.py')
+env.RMIC(target = 'outdir', source = 'test2.JAVA')
+""" % python)
+
+ test.write('test2.JAVA', """\
+test2.JAVA
+/*rmic*/
+line 3
+""")
+
+ test.run(arguments = '.', stderr = None)
+
+ test.fail_test(test.read(['outdir', 'test2.class']) != "test2.JAVA\nline 3\n")
+
+
+if not os.path.exists('/usr/local/j2sdk1.3.1/bin/rmic'):
+ print "Could not find Java, skipping test(s)."
+ test.pass_test(1)
+
+
+
+test.write("wrapper.py", """\
+import os
+import string
+import sys
+open('%s', 'ab').write("wrapper.py %%s\\n" %% string.join(sys.argv[1:]))
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+import string
+foo = Environment(tools = ['javac', 'rmic'],
+ JAVAC = '/usr/local/j2sdk1.3.1/bin/javac',
+ RMIC = '/usr/local/j2sdk1.3.1/bin/rmic')
+foo.Java(target = 'class1', source = 'com/sub/foo')
+foo.RMIC(target = 'outdir1',
+ source = ['class1/com/sub/foo/Example1.class',
+ 'class1/com/sub/foo/Example2'],
+ JAVACLASSDIR = 'class1')
+
+rmic = foo.Dictionary('RMIC')
+bar = foo.Copy(RMIC = r'%s wrapper.py ' + rmic)
+bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar')
+# XXX This is kind of a Python brute-force way to do what Ant
+# does with its "excludes" attribute. We should probably find
+# a similar friendlier way to do this.
+bar_classes = filter(lambda c: string.find(str(c), 'Hello') == -1, bar_classes)
+bar.RMIC(target = Dir('outdir2'), source = bar_classes)
+""" % python)
+
+test.subdir('com',
+ ['com', 'other'],
+ ['com', 'sub'],
+ ['com', 'sub', 'foo'],
+ ['com', 'sub', 'bar'],
+ 'src3a',
+ 'src3b')
+
+test.write(['com', 'sub', 'foo', 'Hello.java'], """\
+package com.sub.foo;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface Hello extends Remote {
+ String sayHello() throws RemoteException;
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example1.java'], """\
+package com.sub.foo;
+
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.UnicastRemoteObject;
+
+public class Example1 extends UnicastRemoteObject implements Hello {
+
+ public Example1() throws RemoteException {
+ super();
+ }
+
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+ public static void main(String args[]) {
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }
+
+ try {
+ Example1 obj = new Example1();
+
+ Naming.rebind("//myhost/HelloServer", obj);
+
+ System.out.println("HelloServer bound in registry");
+ } catch (Exception e) {
+ System.out.println("Example1 err: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+""")
+
+test.write(['com', 'sub', 'foo', 'Example2.java'], """\
+package com.sub.foo;
+
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.UnicastRemoteObject;
+
+public class Example2 extends UnicastRemoteObject implements Hello {
+
+ public Example2() throws RemoteException {
+ super();
+ }
+
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+ public static void main(String args[]) {
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }
+
+ try {
+ Example2 obj = new Example2();
+
+ Naming.rebind("//myhost/HelloServer", obj);
+
+ System.out.println("HelloServer bound in registry");
+ } catch (Exception e) {
+ System.out.println("Example2 err: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Hello.java'], """\
+package com.sub.bar;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface Hello extends Remote {
+ String sayHello() throws RemoteException;
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example3.java'], """\
+package com.sub.bar;
+
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.UnicastRemoteObject;
+
+public class Example3 extends UnicastRemoteObject implements Hello {
+
+ public Example3() throws RemoteException {
+ super();
+ }
+
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+ public static void main(String args[]) {
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }
+
+ try {
+ Example3 obj = new Example3();
+
+ Naming.rebind("//myhost/HelloServer", obj);
+
+ System.out.println("HelloServer bound in registry");
+ } catch (Exception e) {
+ System.out.println("Example3 err: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+""")
+
+test.write(['com', 'sub', 'bar', 'Example4.java'], """\
+package com.sub.bar;
+
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.UnicastRemoteObject;
+
+public class Example4 extends UnicastRemoteObject implements Hello {
+
+ public Example4() throws RemoteException {
+ super();
+ }
+
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+ public static void main(String args[]) {
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }
+
+ try {
+ Example4 obj = new Example4();
+
+ Naming.rebind("//myhost/HelloServer", obj);
+
+ System.out.println("HelloServer bound in registry");
+ } catch (Exception e) {
+ System.out.println("Example4 err: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+""")
+
+test.run(arguments = '.')
+
+test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/rmic -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n")
+
+test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Skel.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Skel.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example2_Stub.class')))
+
+test.fail_test(not os.path.exists(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example3_Skel.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example3_Stub.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example4_Skel.class')))
+test.fail_test(not os.path.exists(test.workpath('outdir2', 'com', 'sub', 'bar', 'Example4_Stub.class')))
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
diff --git a/test/Java/RMICCOM.py b/test/Java/RMICCOM.py
new file mode 100644
index 0000000..109c22e
--- /dev/null
+++ b/test/Java/RMICCOM.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ability to configure the $RMICCOM construction variable.
+"""
+
+import os.path
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+
+
+out_file1 = os.path.join('out', 'file1', 'class_Skel.class')
+out_file2 = os.path.join('out', 'file2', 'class_Skel.class')
+out_file3 = os.path.join('out', 'file3', 'class_Skel.class')
+
+
+
+test.write('myrmic.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*rmic*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'rmic'],
+ RMICCOM = r'%(python)s myrmic.py $TARGET $SOURCES')
+env.RMIC(target = 'out', source = 'file1.class')
+env.RMIC(target = 'out', source = 'file2.class')
+env.RMIC(target = 'out', source = 'file3.class')
+""" % locals())
+
+test.write('file1.class', "file1.class\n/*rmic*/\n")
+test.write('file2.class', "file2.class\n/*rmic*/\n")
+test.write('file3.class', "file3.class\n/*rmic*/\n")
+
+test.run()
+
+test.must_match(out_file1, "file1.class\n")
+test.must_match(out_file2, "file2.class\n")
+test.must_match(out_file3, "file3.class\n")
+
+
+
+test.pass_test()
diff --git a/test/Java/RMICCOMSTR.py b/test/Java/RMICCOMSTR.py
new file mode 100644
index 0000000..1bcf300
--- /dev/null
+++ b/test/Java/RMICCOMSTR.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that the $RMICCOMSTR construction variable allows you to configure
+the rmic output.
+"""
+
+import os.path
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.subdir('src')
+
+
+
+out_file1 = os.path.join('out', 'file1', 'class_Skel.class')
+out_file2 = os.path.join('out', 'file2', 'class_Skel.class')
+out_file3 = os.path.join('out', 'file3', 'class_Skel.class')
+
+
+
+test.write('myrmic.py', r"""
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in filter(lambda l: l != '/*rmic*/\n', infile.readlines()):
+ outfile.write(l)
+sys.exit(0)
+""")
+
+test.write('SConstruct', """
+env = Environment(TOOLS = ['default', 'rmic'],
+ RMICCOM = r'%(python)s myrmic.py $TARGET $SOURCES',
+ RMICCOMSTR = 'Building rmic $TARGET from $SOURCES')
+env.RMIC(target = 'out', source = 'file1.class')
+env.RMIC(target = 'out', source = 'file2.class')
+env.RMIC(target = 'out', source = 'file3.class')
+""" % locals())
+
+test.write('file1.class', "file1.class\n/*rmic*/\n")
+test.write('file2.class', "file2.class\n/*rmic*/\n")
+test.write('file3.class', "file3.class\n/*rmic*/\n")
+
+test.run(stdout = test.wrap_stdout("""\
+Building rmic %(out_file1)s from file1.class
+Building rmic %(out_file2)s from file2.class
+Building rmic %(out_file3)s from file3.class
+""" % locals()))
+
+test.must_match(out_file1, "file1.class\n")
+test.must_match(out_file2, "file2.class\n")
+test.must_match(out_file3, "file3.class\n")
+
+
+
+test.pass_test()