def testObjectArgument():
    f = Foo()
    base = BigInteger.valueOf(12)
    result = base.multiply(BigInteger.valueOf(2))
    eq_(result.longValue(), f.doubleIt(base))
    eq_(result, Reflector.call(f, "doubleIt", [Number], [base]))
    eq_(len(Reflector.getExceptionTypes(f.getClass(), "doubleIt", [Number])), 2)
Example #2
0
def testInstantiating():
    eq_("name",
        Foo().name
        )  # Foo picks up a Java bean accessor by having a get* method...
    jcreated = Reflector.instantiate(Foo)
    assert_true(isinstance(jcreated, Foo))
    eq_("name", Reflector.call(jcreated, 'getName'))
def testPrimitiveArgument():
    f = Foo()
    f.setValue(12)
    eq_(12, f.value)
    f.value += 1
    eq_(13, f.getValue())
    Reflector.call(f, "setValue", [clamp.jint], [18])
    eq_(18, f.value)
Example #4
0
def testPrimitiveArgument():
    f = Foo()
    f.setValue(12)
    eq_(12, f.value)
    f.value += 1
    eq_(13, f.getValue())
    Reflector.call(f, "setValue", [Integer.TYPE], [18])
    eq_(18, f.value)
Example #5
0
def testObjectArgument():
    f = Foo()
    base = BigInteger.valueOf(12)
    result = base.multiply(BigInteger.valueOf(2))
    eq_(result.longValue(), f.doubleIt(base))
    eq_(result, Reflector.call(f, "doubleIt", [Number], [base]))
    eq_(len(Reflector.getExceptionTypes(f.getClass(), "doubleIt", [Number])),
        2)
Example #6
0
def test_default_constructor():
    allarg = Reflector.instantiate(OptionalArg, [String, String], ['one', 'two'])
    eq_("one", allarg.first)
    eq_("two", allarg.second)
    onearg = Reflector.instantiate(OptionalArg, [String], ['one'])
    eq_("one", onearg.first)
    eq_(7, onearg.second)
    noarg = Reflector.instantiate(OptionalArg, [], [])
    eq_(None, noarg.first)
    eq_(7, noarg.second)
Example #7
0
def testObjectArgument():
    f = Foo()
    base = BigInteger.valueOf(12)
    result = base.multiply(BigInteger.valueOf(2))
    eq_(result, f.doubleIt(base))
    eq_(result, Reflector.call(f, "doubleIt", [Number], [base]))
    #XXX: getting to the IFoo interface this way is brittle.
    iface = f.__class__.__base__.__bases__[0]
    excepts = Reflector.getExceptionTypes(iface, "doubleIt", [Number])
    eq_(len(excepts), 2)
def testObjectArgument():
    f = Foo()
    base = BigInteger.valueOf(12)
    result = base.multiply(BigInteger.valueOf(2))
    eq_(result , f.doubleIt(base))
    eq_(result, Reflector.call(f, "doubleIt", [Number], [base]))
    #XXX: getting to the IFoo interface this way is brittle.
    iface = f.__class__.__base__.__bases__[0]
    excepts = Reflector.getExceptionTypes(iface, "doubleIt", [Number])
    eq_(len(excepts), 2)
Example #9
0
def testOnClass():
    eq_("int", Reflector.call(OverloadedMethods(7), "primitiveOrObject", [jint], [12]))
    eq_("String", Reflector.call(OverloadedMethods('hi'), "primitiveOrObject", [String], ["hello"]))
    eq_("int", Reflector.instantiate(OverloadedMethods, [jint], [7]).val)
    eq_("int", Reflector.call(OverloadedMethods(7), "overloadedDefault", [jint], [12]))
    eq_("String", Reflector.call(OverloadedMethods('hi'), "overloadedDefault", [String], ["hello"]))
    eq_("float", Reflector.call(OverloadedMethods('hi'), "overloadedDefault", [], []))
Example #10
0
def testOnClass():
    eq_(
        "int",
        Reflector.call(OverloadedMethods(7), "primitiveOrObject", [jint],
                       [12]))
    eq_(
        "String",
        Reflector.call(OverloadedMethods('hi'), "primitiveOrObject", [String],
                       ["hello"]))
    eq_("int", Reflector.instantiate(OverloadedMethods, [jint], [7]).val)
    eq_(
        "int",
        Reflector.call(OverloadedMethods(7), "overloadedDefault", [jint],
                       [12]))
    eq_(
        "String",
        Reflector.call(OverloadedMethods('hi'), "overloadedDefault", [String],
                       ["hello"]))
    eq_("float",
        Reflector.call(OverloadedMethods('hi'), "overloadedDefault", [], []))
def testInstantiating():
    eq_("name", Foo().name)  # Foo picks up a Java bean accessor by having a get* method...
    jcreated = Reflector.instantiate(Foo)
    assert_true(isinstance(jcreated, Foo))
    eq_("name", Reflector.call(jcreated, "getName"))
Example #12
0
def test_constructor_gen():
    inst = Reflector.instantiate(PrimitiveArg, [Integer.TYPE], [7])
    eq_(7, inst.val)
Example #13
0
def testPrimitiveReturn():
    eq_(7, Foo().getValue())
    eq_(7, Reflector.call(Foo(), "getValue"))
Example #14
0
def test_extendingclass():
    clamped = Reflector.instantiate(ClampedList, [], [])
    eq_(5, Reflector.call(clamped, 'get', [Integer.TYPE], [5]))
    assert_raises(UnsupportedOperationException, clamped.add, 5)
Example #15
0
def test_extendingclamped():
    extra = Reflector.instantiate(ExtraMethodList, [], [])
    last = Reflector.call(extra, "last", [], [])
    eq_(9, last)
Example #16
0
def test_constructor_gen():
    eq_('clamp.test.test_constructor.PrimitiveArg', PrimitiveArg(7).getClass().name)
    inst = Reflector.instantiate(PrimitiveArg, [Integer.TYPE], [7])
    eq_(7, inst.val)
    # check against the 1st constructor as we're generating a superfluous no-arg constructor
    eq_(EOFException, inst.getClass().constructors[1].exceptionTypes[0])
def testPrimitiveReturn():
    eq_(7, Foo().getValue())
    eq_(7, Reflector.call(Foo(), "getValue"))