test/test.rb in rjb-1.1.2 vs test/test.rb in rjb-1.1.3

- old
+ new

@@ -1,10 +1,15 @@ #!/usr/local/env ruby -# $Id: test.rb 58 2008-01-14 08:25:07Z kuwa1 $ +# $Id: test.rb 63 2008-03-04 15:34:24Z kuwa1 $ +begin + require 'rjb' +rescue LoadError + require 'rubygems' + require 'rjb' +end require 'test/unit' -require 'rjb' puts "start RJB(#{Rjb::VERSION}) test" class TestRjb < Test::Unit::TestCase include Rjb def setup @@ -224,10 +229,16 @@ test = import('jp.co.infoseek.hp.arton.rjb.Test') a = test.new assert("43210", a.concat(it)) end + def test_unbind() + it = TestIter.new + it = bind(it, 'java.util.Iterator') + assert(it, unbind(it)) + end + class TestComparator def compare(o1, o2) o1.to_i - o2.to_i end def equals(o) @@ -328,16 +339,49 @@ rescue RuntimeError => e assert_equal("`java.lang.NoSuchException' not found", e.message) end end + def test_throw_clear() + assert_nothing_raised { + begin + Rjb::throw('java.util.NoSuchElementException', 'test exception') + rescue #drop ruby exception + end + test = import('jp.co.infoseek.hp.arton.rjb.Test') + begin + Rjb::throw('java.util.NoSuchElementException', 'test exception') + rescue #drop ruby exception + end + test.new + begin + Rjb::throw('java.util.NoSuchElementException', 'test exception') + rescue #drop ruby exception + end + @jString.new_with_sig('Ljava.lang.String;', "abcde") + begin + Rjb::throw('java.util.NoSuchElementException', 'test exception') + rescue #drop ruby exception + end + it = TestIterator.new(0) + it = bind(it, 'java.util.Iterator') + begin + Rjb::throw('java.util.NoSuchElementException', 'test exception') + rescue NoSuchElementException + end + begin + Rjb::throw('java.lang.IllegalAccessException', 'test exception') + rescue IllegalAccessException + end + unbind(it) + } + end + def test_field() - point = import('java.awt.Point') - pnt = point.new(11, 13) - assert_equal(11, pnt.x) - assert_equal(13, pnt.y) - pnt.x = 32 - assert_equal(32, pnt.x) + test = import('jp.co.infoseek.hp.arton.rjb.Test').new + assert_equal('Hello World !!', test.helloData) + test.helloData = 'Goodby World !' + assert_equal('Goodby World !', test.helloData) end def test_instancemethod_from_class() begin assert_equal('true', @jString.valueOf(true))