1
1
# **********************************************************************
3
# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
3
# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
5
5
# This copy of Ice is licensed to you under the terms described in the
6
6
# ICE_LICENSE file included in this distribution.
172
168
def __init__(self, communicator):
173
169
CallbackBase.__init__(self)
174
self._communicator = communicator
170
self._communicator = communicator
176
172
def ice_response(self, rso, so):
177
173
test(rso.p == None)
178
174
test(rso.e == Test.MyEnum.enum2)
472
468
def ice_exception(self, ex):
471
class AMI_MyClass_opMyEnumStringDI(CallbackBase):
473
CallbackBase.__init__(self)
475
def ice_response(self, ro, do):
476
di1 = {Test.MyEnum.enum1: 'abc'}
479
test(ro[Test.MyEnum.enum1] == "abc")
480
test(ro[Test.MyEnum.enum2] == "Hello!!")
481
test(ro[Test.MyEnum.enum3] == "qwerty")
484
def ice_exception(self, ex):
475
487
class AMI_MyClass_opMyStructMyEnumDI(CallbackBase):
476
488
def __init__(self):
477
489
CallbackBase.__init__(self)
568
580
test(not indirect.opByte_async(cb, 0, 0))
569
581
except Ice.Exception:
576
588
cb = AMI_MyClass_opVoidI()
577
589
p.opVoid_async(cb)
579
591
# Let's check if we can reuse the same callback object for another call.
580
592
p.opVoid_async(cb)
583
595
# Check that CommunicatorDestroyedException is raised directly.
584
596
initData = Ice.InitializationData()
602
614
cb = AMI_MyClass_opByteI()
603
615
p.opByte_async(cb, 0xff, 0x0f)
609
621
cb = AMI_MyClass_opBoolI()
610
622
p.opBool_async(cb, True, False)
616
628
cb = AMI_MyClass_opShortIntLongI()
617
629
p.opShortIntLong_async(cb, 10, 11, 12)
623
635
cb = AMI_MyClass_opFloatDoubleI()
624
636
p.opFloatDouble_async(cb, 3.14, 1.1E10)
626
638
# Let's check if we can reuse the same callback object for another call.
627
639
p.opFloatDouble_async(cb, 3.14, 1.1E10)
633
645
cb = AMI_MyClass_opStringI()
634
646
p.opString_async(cb, "hello", "world")
640
652
cb = AMI_MyClass_opMyEnumI()
641
653
p.opMyEnum_async(cb, Test.MyEnum.enum2)
647
659
cb = AMI_MyClass_opMyClassI(communicator)
648
660
p.opMyClass_async(cb, p)
796
808
cb = AMI_MyClass_opStringMyEnumDI()
797
809
p.opStringMyEnumD_async(cb, di1, di2)
815
di1 = {Test.MyEnum.enum1: 'abc'}
816
di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}
818
cb = AMI_MyClass_opMyEnumStringDI()
819
p.opMyEnumStringD_async(cb, di1, di2)
801
823
# opMyStructMyEnumD
839
861
test(len(p.ice_getContext()) == 0)
840
862
cb = AMI_MyClass_opContextNotEqualI(ctx)
841
863
p.opContext_async(cb)
844
866
test(len(p.ice_getContext()) == 0)
845
867
cb = AMI_MyClass_opContextEqualI(ctx)
846
868
p.opContext_async(cb, ctx)
849
871
p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
850
872
test(p2.ice_getContext() == ctx)
851
873
cb = AMI_MyClass_opContextEqualI(ctx)
852
874
p2.opContext_async(cb)
855
877
p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
856
878
test(p2.ice_getContext() == ctx)
857
879
cb = AMI_MyClass_opContextEqualI(ctx)
858
880
p2.opContext_async(cb, ctx)
861
derived = Test.MyDerivedClassPrx.checkedCast(p)
863
cb = AMI_MyDerivedClass_opDerivedI()
864
derived.opDerived_async(cb)
868
# Test that default context is obtained correctly from communicator.
872
# communicator.setDefaultContext(dflt)
873
# cb = AMI_MyClass_opContextNotEqualI(dflt)
874
# p.opContext_async(cb)
877
# p2 = Test.MyClassPrx.uncheckedCast(p.ice_context({}))
878
# cb = AMI_MyClass_opContextEqualI({})
879
# p2.opContext_async(cb)
882
# p2 = Test.MyClassPrx.uncheckedCast(p.ice_defaultContext())
883
# cb = AMI_MyClass_opContextEqualI(dflt)
884
# p2.opContext_async(cb)
887
# communicator.setDefaultContext({})
888
# cb = AMI_MyClass_opContextNotEqualI({})
889
# p2.opContext_async(cb)
892
# communicator.setDefaultContext(dflt)
893
# c = Test.MyClassPrx.checkedCast(communicator.stringToProxy("test:default -p 12010 -t 10000"))
894
# cb = AMI_MyClass_opContextEqualI({'a': 'b'})
895
# c.opContext_async(cb)
899
# c2 = Test.MyClassPrx.uncheckedCast(c.ice_context(dflt))
900
# cb = AMI_MyClass_opContextEqualI({'a': 'c'})
901
# c2.opContext_async(cb)
905
# c3 = Test.MyClassPrx.uncheckedCast(c2.ice_context(dflt))
906
# cb = AMI_MyClass_opContextEqualI({})
907
# c3.opContext_async(cb)
910
# c4 = Test.MyClassPrx.uncheckedCast(c2.ice_defaultContext())
911
# cb = AMI_MyClass_opContextEqualI({'a': 'b'})
912
# c4.opContext_async(cb)
916
# communicator.setDefaultContext(dflt)
918
# c5 = Test.MyClassPrx.uncheckedCast(c.ice_defaultContext())
919
# cb = AMI_MyClass_opContextEqualI({'a': 'd'})
920
# c5.opContext_async(cb)
923
# communicator.setDefaultContext({})
926
884
# Test implicit context propagation
931
889
initData.properties = communicator.getProperties().clone()
932
890
initData.properties.setProperty('Ice.ImplicitContext', i)
933
891
ic = Ice.initialize(data=initData)
935
893
ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
937
p = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010 -t 10000"))
895
p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010"))
939
897
ic.getImplicitContext().setContext(ctx)
940
898
test(ic.getImplicitContext().getContext() == ctx)
942
900
cb = AMI_MyClass_opContextEqualI(ctx)
943
p.opContext_async(cb)
901
p3.opContext_async(cb)
946
904
ic.getImplicitContext().put('zero', 'ZERO')
947
905
ctx = ic.getImplicitContext().getContext()
949
907
cb = AMI_MyClass_opContextEqualI(ctx)
950
p.opContext_async(cb)
908
p3.opContext_async(cb)
953
911
prxContext = {'one': 'UN', 'four': 'QUATRE'}
956
914
combined.update(prxContext)
957
915
test(combined['one'] == 'UN')
959
p = Test.MyClassPrx.uncheckedCast(p.ice_context(prxContext))
917
p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext))
960
918
ic.getImplicitContext().setContext({})
962
920
cb = AMI_MyClass_opContextEqualI(prxContext)
963
p.opContext_async(cb)
921
p3.opContext_async(cb)
966
924
ic.getImplicitContext().setContext(ctx)
968
926
cb = AMI_MyClass_opContextEqualI(combined)
969
p.opContext_async(cb)
927
p3.opContext_async(cb)
932
derived = Test.MyDerivedClassPrx.checkedCast(p)
934
cb = AMI_MyDerivedClass_opDerivedI()
935
derived.opDerived_async(cb)