コード例 #1
0
ファイル: BatchOnewaysAMI.py プロジェクト: skyhack1212/ice-1
def batchOneways(p):

    if sys.version_info[0] == 2:
        bs1 = []
        bs1[0:10 * 1024] = range(0, 10 * 1024)  # add 100,000 entries.
        bs1 = ['\x00' for x in bs1]  # set them all to \x00
        bs1 = ''.join(bs1)  # make into a byte array
    else:
        bs1 = bytes([0 for x in range(0, 10 * 1024)])
    batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

    batch.end_ice_flushBatchRequests(
        batch.begin_ice_flushBatchRequests())  # Empty flush
    test(batch.begin_ice_flushBatchRequests().isSent())  # Empty flush
    test(batch.begin_ice_flushBatchRequests().isCompleted())  # Empty flush
    test(batch.begin_ice_flushBatchRequests().sentSynchronously()
         )  # Empty flush

    for i in range(30):
        batch.begin_opByteSOneway(bs1, lambda: 0, lambda ex: test(False))

    count = 0
    while count < 27:  # 3 * 9 requests auto-flushed.
        count += p.opByteSOnewayCallCount()
        time.sleep(0.01)

    if p.ice_getConnection():

        batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
        batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

        batch1.end_ice_ping(batch1.begin_ice_ping())
        batch2.end_ice_ping(batch2.begin_ice_ping())
        batch1.end_ice_flushBatchRequests(
            batch1.begin_ice_flushBatchRequests())
        batch1.ice_getConnection().close(
            Ice.ConnectionClose.GracefullyWithWait)
        batch1.end_ice_ping(batch1.begin_ice_ping())
        batch2.end_ice_ping(batch2.begin_ice_ping())

        batch1.ice_getConnection()
        batch2.ice_getConnection()

        batch1.ice_getConnection().close(
            Ice.ConnectionClose.GracefullyWithWait)

        batch1.end_ice_ping(batch1.begin_ice_ping())
        batch2.end_ice_ping(batch2.begin_ice_ping())

    identity = Ice.Identity()
    identity.name = "invalid"
    batch3 = batch.ice_identity(identity)
    batch3.ice_ping()
    batch3.end_ice_flushBatchRequests(batch3.begin_ice_flushBatchRequests())

    # Make sure that a bogus batch request doesn't cause troubles to other ones.
    batch3.ice_ping()
    batch.ice_ping()
    batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests())
    batch.ice_ping()
コード例 #2
0
    def __init__(self,
                 ctx,
                 file_obj,
                 factory,
                 storage,
                 uuid="unknown",
                 call_context=None,
                 adapter=None):
        self.id = Ice.Identity()
        self.id.name = uuid
        self.uuid = uuid
        self.file_obj = file_obj
        self.factory = factory
        self.storage = storage
        self.call_context = call_context
        self.adapter = adapter
        self.can_write = factory.getAdminService().canUpdate(
            file_obj, call_context)
        omero.util.SimpleServant.__init__(self, ctx)

        self.stamp = time.time()
        self.storage.incr(self)

        self._closed = False

        if (not self.file_obj.isLoaded() or self.file_obj.getDetails() is None
                or self.file_obj.details.group is None):
            self.file_obj = self.ctx.getSession().getQueryService().get(
                'omero.model.OriginalFileI', unwrap(file_obj.id),
                {"omero.group": "-1"})
コード例 #3
0
ファイル: ComponentServer.py プロジェクト: marc-hanheide/cast
    def run(self, argv):
        status = 0
        ic = self.communicator()

        if (not ic):
            return

        pylog4cxx.configure()
        logger = pylog4cxx.Logger("cast.server.python.ComponentServer", "", "")
        logger.info("Python server version: \"%s\"" %
                    (cast.cdl.CASTRELEASESTRING))

        portArgs = "tcp -p %d" % cast.cdl.PYTHONSERVERPORT
        adapter = ic.createObjectAdapterWithEndpoints("ComponentServer3",
                                                      portArgs)

        idty = Ice.Identity()
        idty.name = "ComponentFactory"
        idty.category = "ComponentFactory"

        factory = CASTComponentFactory()
        adapter.add(factory, idty)

        adapter.activate()
        # logger.trace("Python Server Running...")
        ic.waitForShutdown()
コード例 #4
0
    def xtest_createLocalMirror(self):
        print('createLocalMirror')
        dataRoot = cvac.DirectoryPath( "corpus" );
        corpusConfigFile = cvac.FilePath( dataRoot, "CvacCorpusTest.properties" )
        corpus = self.cs.openCorpus( corpusConfigFile )
        if not corpus:
            raise RuntimeError("could not open corpus from config file at '"
                               +dataRoot.relativePath+"/"+corpusConfigFile.filename+"'")

        adapter = self.ic.createObjectAdapter("")
        ident = Ice.Identity()
        ident.name = IcePy.generateUUID()
        ident.category = ""
#        adapter.add( self, ident )
        adapter.add( TestCorpusCallback(), ident )
        adapter.activate()
#        adapter = self.ic.createObjectAdapter("CorpusServer")
#        adapter.add( TestCorpusCallback(), ic.stringToIdentity("CorpusServer:default -p 10011"))
#        adapter.activate()
#        receiver = cvac.CorpusCallbackPrx.uncheckedCast(
#            adapter.createProxy( self.ic.stringToIdentity("callbackReceiver")))
        
        self.cs.createLocalMirror( corpus, ident )
        if not self.cs.localMirrorExists( corpus ):
            raise RuntimeError( "could not create local mirror for",
                                corpusConfigFile.filename )
コード例 #5
0
    def getTable(self, file_obj, factory, current=None):
        """
        Create and/or register a table servant.
        """

        # Will throw an exception if not allowed.
        file_id = None
        if file_obj is not None and file_obj.id is not None:
            file_id = file_obj.id.val
        self.logger.info("getTable: %s %s", file_id, current.ctx)

        file_path = self.repo_mgr.getFilePath(file_obj)
        p = path(file_path).dirname()
        if not p.exists():
            p.makedirs()

        storage = self._storage_factory.getOrCreate(file_path, self.read_only)
        id = Ice.Identity()
        id.name = Ice.generateUUID()
        table = TableI(self.ctx, file_obj, factory, storage, uuid=id.name,
                       call_context=current.ctx)
        self.resources.add(table)

        prx = current.adapter.add(table, id)
        return self._table_cast(prx)
コード例 #6
0
 def __init__(self):
     super(Client, self).__init__()
     self._session_prx = None
     self.agent_receiver_ice_ident = Ice.Identity()
     self.agent_receiver_ice_ident.category = "RPCChannel"
     self.agent_receiver_ice_ident.name = Ice.generateUUID()
     self.agent_receiver_adapter = None
     self.agent_receiver = AgentReceiverI(self)
コード例 #7
0
ファイル: BatchOnewaysFuture.py プロジェクト: magicdogs/ice
def batchOneways(p):

    if sys.version_info[0] == 2:
        bs1 = []
        bs1[0:10 * 1024] = range(0, 10 * 1024) # add 100,000 entries.
        bs1 = ['\x00' for x in bs1] # set them all to \x00
        bs1 = ''.join(bs1) # make into a byte array
    else:
        bs1 = bytes([0 for x in range(0, 10 * 1024)])
    batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

    f = batch.ice_flushBatchRequestsAsync() # Empty flush
    f.result()

    test(batch.ice_flushBatchRequestsAsync().is_sent()) # Empty flush
    test(batch.ice_flushBatchRequestsAsync().done()) # Empty flush
    test(batch.ice_flushBatchRequestsAsync().sent_synchronously()) # Empty flush

    for i in range(30):
        batch.opByteSOnewayAsync(bs1)

    count = 0
    while count < 27: # 3 * 9 requests auto-flushed.
        count += p.opByteSOnewayCallCount()
        time.sleep(0.01)

    if p.ice_getConnection():

        batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
        batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

        batch1.ice_pingAsync()
        batch2.ice_pingAsync()
        batch1.ice_flushBatchRequestsAsync().result()
        batch1.ice_getConnection().close(False)
        batch1.ice_pingAsync()
        batch2.ice_pingAsync()

        batch1.ice_getConnection()
        batch2.ice_getConnection()

        batch1.ice_getConnection().close(False)

        test(not batch1.ice_pingAsync().done())
        test(not batch2.ice_pingAsync().done())

    identity = Ice.Identity()
    identity.name = "invalid";
    batch3 = batch.ice_identity(identity)
    batch3.ice_ping()
    batch3.ice_flushBatchRequestsAsync().result()

    # Make sure that a bogus batch request doesn't cause troubles to other ones.
    batch3.ice_ping()
    batch.ice_ping()
    batch.ice_flushBatchRequestsAsync().result()
    batch.ice_ping()
コード例 #8
0
 def __init__(self, adapter_or_client, handle, poll=True):
     self.event = omero.util.concurrency.get_event(name="DeleteCallbackI")
     self.result = None
     self.poll = poll
     self.handle = handle
     self.adapter = adapter_or_client
     self.id = Ice.Identity(str(uuid.uuid4()), "DeleteHandleCallback")
     if not isinstance(self.adapter, Ice.ObjectAdapter):
         self.adapter = self.adapter.adapter
コード例 #9
0
    def run(self, argv):
        rtFile = self.communicator().getProperties().getPropertyWithDefault(
            "RoutingTable", "RTABLE")
        self.router.getRoutingTable().load(rtFile)

        self.router.pox = pox.PacketInjectorPrx.checkedCast(
            self.communicator().propertyToProxy(
                "SimpleRouter.Proxy").ice_twoway())
        if not self.router.pox:
            log.error(
                "ERROR: Cannot connect to POX controller or invalid configuration of the controller"
            )
            return -1

        ifFile = self.communicator().getProperties().getPropertyWithDefault(
            "Ifconfig", "IP_CONFIG")
        self.router.loadIfconfig(ifFile)

        adapter = self.communicator().createObjectAdapter("")
        ident = Ice.Identity()
        ident.name = Ice.generateUUID()
        ident.category = ""

        adapter.add(PacketHandler(self.router), ident)
        adapter.activate()
        self.router.pox.ice_getConnection().setAdapter(adapter)
        self.router.pox.addPacketHandler(ident)

        ifaces = self.router.pox.getIfaces()
        self.router.reset(ifaces)

        def poxPinger(self):
            while not self.shouldStop:
                time.sleep(1)
                try:
                    self.router.pox.ice_ping()
                except:
                    print("Connection to POX service broken, exiting...",
                          file=sys.stderr)
                    self.communicator().shutdown()

        self.shouldStop = False
        checkThread = threading.Thread(target=poxPinger, args=(self, ))
        checkThread.start()

        testAdapter = self.communicator().createObjectAdapterWithEndpoints(
            "Tester", "tcp -p 65500")
        testAdapter.add(Tester(self.router),
                        self.communicator().stringToIdentity("Tester"))
        testAdapter.activate()

        self.communicator().waitForShutdown()
        self.shouldStop = True
        self.router.arpCache.stop()
        checkThread.join()
        return 0
コード例 #10
0
ファイル: ComponentServer.py プロジェクト: marc-hanheide/cast
 def newComponent(self, id, type, newProcess, current):
     #print "Creating new", type
     component = self._createBase(type)
     tmp = Ice.Identity(id, type)
     component.setID(id, None)
     component.setObjectAdapter(current.adapter)
     component.setIceID(tmp)
     base = current.adapter.add(component, tmp)
     prx = cast.interfaces.CASTComponentPrx.uncheckedCast(base)
     return prx
コード例 #11
0
ファイル: Server.py プロジェクト: zhangtianshan/ice-demos
    def __init__(self, communicator, name, parent):
        self._name = name
        self._parent = parent
        self.lines = []

        assert (self._parent != None)

        # Create an identity
        #
        self._id = Ice.Identity()
        self._id.name = Ice.generateUUID()
コード例 #12
0
    def __init__(self, adapter_or_client, process, poll=True, category=None):
        self.event = omero.util.concurrency.get_event(name="ProcessCallbackI")
        self.result = None
        self.poll = poll
        self.process = process
        self.adapter, self.category = \
            adapter_and_category(adapter_or_client, category)

        self.id = Ice.Identity(str(uuid.uuid4()), self.category)
        self.prx = self.adapter.add(self, self.id)  # OK ADAPTER USAGE
        self.prx = omero.grid.ProcessCallbackPrx.uncheckedCast(self.prx)
        process.registerCallback(self.prx)
コード例 #13
0
    def __init__(self, hosts):
        self._hosts = hosts

        myID = Ice.Identity()
        myID.name = "Backend"
        # Add the identity to the object adapter
        self._adapter.add(self, myID)
        # Create a proxy for the new node and
        # add it as a child to the parent
        #
        thisNode = Matcloud.BackendPrx.uncheckedCast(
            self._adapter.createProxy(myID))
コード例 #14
0
ファイル: Server.py プロジェクト: zhangtianshan/ice-demos
    def __init__(self, communicator, name, parent):
        self._name = name
        self._parent = parent
        self._contents = []

        # Create an identity. The root directory has the fixed identity "RootDir"
        #
        self._id = Ice.Identity()
        if self._parent:
            self._id.name = Ice.generateUUID()
        else:
            self._id.name = "RootDir"
コード例 #15
0
    def activate(self, a):
        #
        # Create an identity. The root directory has the fixed identity "RootDir"
        #
        id = Ice.Identity()
        if self._parent:
            id.name = Ice.generateUUID()
        else:
            id.name = "RootDir"

        thisNode = Filesystem.NodePrx.uncheckedCast(a.add(self, id))
        if self._parent:
            self._parent.addChild(thisNode)
コード例 #16
0
ファイル: Base_Servant.py プロジェクト: bburhans/vtank
 def __init__(self, ip_string, client_type, userlevel, reporter=None):
     """
     @param ip_string IP string, which is retrieved from current.con.toString().
     @param client_type Type of client that this is.
     @param userlevel How powerful this user is.
     @param reporter Optional reporter function for debug output.
     """
     self.ip = ip_string
     self.type = client_type
     self.userlevel = userlevel
     self.reporter = reporter
     self.last_action = time()
     self.id = Ice.Identity()
     self.ingame = False
     self.server = None
コード例 #17
0
    def __init__(self, host):
        self._hosts = host
        #self._client = {}
        self._mutex = threading.Lock()
        self.unmap = {}

        myID = Ice.Identity()
        myID.name = "Frontend"
        # Add the identity to the object adapter
        #
        self._adapter.add(self, myID)
        # Create a proxy for the new node and
        # add it as a child to the parent
        #
        thisNode = Matcloud.FrontendPrx.uncheckedCast(
            self._adapter.createProxy(myID))
コード例 #18
0
ファイル: processor.py プロジェクト: patrick330602/fomf3dbd
def usermode_processor(client,
                       serverid="UsermodeProcessor",
                       cfg=None,
                       accepts_list=None,
                       stop_event=None,
                       omero_home=path.getcwd()):
    """
    Creates and activates a usermode processor for the given client.
    It is the responsibility of the client to call "cleanup()" on
    the ProcessorI implementation which is returned.

    cfg is the path to an --Ice.Config-valid file or files. If none
    is given, the value of ICE_CONFIG will be taken from the environment
    if available. Otherwise, all properties will be taken from the client
    instance.

    accepts_list is the list of IObject instances which will be passed to
    omero.api.IScripts.validateScript. If none is given, only the current
    Experimenter's own object will be passed.

    stop_event is an threading.Event. One will be acquired from
    omero.util.concurrency.get_event if none is provided.
    """

    if cfg is None:
        cfg = os.environ.get("ICE_CONFIG")

    if accepts_list is None:
        uid = client.sf.getAdminService().getEventContext().userId
        accepts_list = [omero.model.ExperimenterI(uid, False)]

    if stop_event is None:
        stop_event = omero.util.concurrency.get_event(name="UsermodeProcessor")

    id = Ice.Identity()
    id.name = "%s-%s" % (serverid, uuid.uuid4())
    id.category = client.getCategory()

    ctx = omero.util.ServerContext(serverid, client.ic, stop_event)
    impl = omero.processor.ProcessorI(ctx,
                                      use_session=client.sf,
                                      accepts_list=accepts_list,
                                      cfg=cfg,
                                      omero_home=omero_home,
                                      category=id.category)
    ctx.add_servant(client.adapter, impl, ice_identity=id)
    return impl
コード例 #19
0
ファイル: Client.py プロジェクト: DavidGB18/hello.ice
    def run(self, argv):
        broker = self.communicator()

        servant = PrinterI()
        identity = Ice.Identity(Ice.generateUUID())

        adapter = broker.createObjectAdapter("")
        adapter.add(servant, identity)
        adapter.activate()

        proxy = broker.stringToProxy(argv[1])
        server = Example.CallbackPrx.checkedCast(proxy)
        server.ice_getConnection().setAdapter(adapter)
        server.attach(identity)

        self.communicator().waitForShutdown()
        return 0
コード例 #20
0
 def _init_Ice(self):
     import Ice
     props = Ice.createProperties()
     props.setProperty("Ice.ThreadPool.Server.SizeMax", "16")
     # props.setProperty("Ice.ThreadPool.SizeMax", "16")
     props.setProperty("Ice.MessageSizeMax", "0")
     # props.setProperty("Ice.Trace.ThreadPool", "1")
     # props.setProperty("Ice.Trace.Network", "1")
     # props.setProperty("Ice.Trace.Protocol", "1")
     data = Ice.InitializationData()
     data.properties = props
     self._ice_ic = ic = Ice.initialize(data=data)
     self._ice_adapter = adapter = ic.createObjectAdapter("")
     self._ice_ident = ident = Ice.Identity()
     ident.name = Ice.generateUUID()
     adapter.add(self, ident)
     adapter.activate()
コード例 #21
0
    def run(self, args):
        if len(args) > 1:
            print(self.appName() + ": too many arguments")
            return 1

        server = Demo.CallbackSenderPrx.checkedCast(self.communicator().propertyToProxy('CallbackSender.Proxy'))
        if not server:
            print(self.appName() + ": invalid proxy")
            return 1

        adapter = self.communicator().createObjectAdapter("")
        ident = Ice.Identity()
        ident.name = Ice.generateUUID()
        ident.category = ""
        adapter.add(CallbackReceiverI(), ident)
        adapter.activate()
        server.ice_getConnection().setAdapter(adapter)
        server.addClient(ident)
        self.communicator().waitForShutdown()

        return 0
コード例 #22
0
    def __init__(self, adapter_or_client, handle, category=None):

        if adapter_or_client is None:
            raise omero.ClientError("Null client")

        if handle is None:
            raise omero.ClientError("Null handle")

        self.event = omero.util.concurrency.get_event(name="CmdCallbackI")
        self.state = (None, None)  # (Response, Status)
        self.handle = handle
        self.adapter, self.category = \
                adapter_and_category(adapter_or_client, category)

        self.id = Ice.Identity(str(uuid.uuid4()), self.category)
        self.prx = self.adapter.add(self, self.id)  # OK ADAPTER USAGE
        self.prx = omero.cmd.CmdCallbackPrx.uncheckedCast(self.prx)
        handle.addCallback(self.prx)

        # Now check just in case the process exited VERY quickly
        self.poll()
コード例 #23
0
    def run (self, argv):
        """Ejecuci�n del c�digo asociado al renderAgent"""
                
        self.shutdownOnInterrupt()

        # Conexión con Glacier2.
        router = Glacier2.RouterPrx.checkedCast(self.communicator().getDefaultRouter())
        session = router.createSession('david', 'david')
        
        self.obtainServiceRoot()
        self.getBasicServices()
        self.addRenderService('render', TYPEOFSERVICE)

        # Subscripci�n al DirectoryFacilitator.
        self.subscribeDF()

        ### ACCIONES ESPECÍFICAS.
        self.obtainProxies()
        # Informar del tiempo de ejecuci�n del benchmark.
        self.notifyBenchmarkValue()
        ### FIN ACCIONES ESPECÍFICAS.

        # Subscripci�n al Master.
        oa = self.communicator().createObjectAdapter('MyAdapter')
        ident = Ice.Identity()
        ident.name = Ice.generateUUID()
        ident.category = router.getServerProxy().ice_getIdentity().category
        prx = MASYRO.RenderAgentPrx.uncheckedCast(oa.add(self, ident))
        self.subscribeMaster(prx)

	self.communicator().waitForShutdown()
        # Baja del DirectoryFacilitator y del AMS.
        self.deregister()
        self.unsubscribeDF()
        # Eliminaci�n de la subscripci�n al Master.
        self.unsubscribeMaster()
        # Limpieza de recursos.
        self.clear()

	return 0
コード例 #24
0
    def __init__(self,
                 adapter_or_client,
                 handle,
                 category=None,
                 foreground_poll=True):

        if adapter_or_client is None:
            raise omero.ClientError("Null client")

        if handle is None:
            raise omero.ClientError("Null handle")

        self.event = omero.util.concurrency.get_event(name="CmdCallbackI")
        self.state = (None, None)  # (Response, Status)
        self.handle = handle
        self.adapter, self.category = \
            adapter_and_category(adapter_or_client, category)

        self.id = Ice.Identity(native_str(uuid.uuid4()), self.category)
        self.prx = self.adapter.add(self, self.id)  # OK ADAPTER USAGE
        self.prx = omero.cmd.CmdCallbackPrx.uncheckedCast(self.prx)
        handle.addCallback(self.prx)
        self.initialPoll(foreground_poll)
コード例 #25
0
    def xtest_openCorpusLabelMe(self):
        print('openCorpusLabelMe')
        dataRoot = cvac.DirectoryPath( "corpus" );
        corpusConfigFile = cvac.FilePath( dataRoot, "LabelMeCarsTest.properties" )
#        corpusConfigFile = cvac.FilePath( dataRoot, "NpsVisionLabelMe.properties" )
        corpus = self.cs.openCorpus( corpusConfigFile )
        if not corpus:
            raise RuntimeError("could not open corpus from config file at '"
                               +dataRoot.relativePath+"/"+corpusConfigFile.filename+"'"+"\n"
                               +"Did you build CVAC with BUILD_LABELME_CORPUS=ON?")
        adapter = self.ic.createObjectAdapter("")
        ident = Ice.Identity()
        ident.name = IcePy.generateUUID()
        ident.category = ""
        adapter.add( TestCorpusCallback(), ident )
        adapter.activate()
        
        self.cs.createLocalMirror( corpus, ident )

        labels = self.cs.getDataSet( corpus )
        if not labels:
            raise RuntimeError("could not obtain labels from Corpus '"
                               +corpus.name+"'")
コード例 #26
0
ファイル: AllTests.py プロジェクト: zhaochf/ice
def allTests(communicator, collocated):
    sys.stdout.write("testing stringToProxy... ")
    sys.stdout.flush()

    #
    # Test nil proxies.
    #
    p = communicator.stringToProxy('')
    test(p == None)
    p = communicator.propertyToProxy('bogus')
    test(p == None)

    ref = "test:default -p 12010"
    base = communicator.stringToProxy(ref)
    test(base)

    b1 = communicator.stringToProxy("test")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy("test ")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy(" test ")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy(" test")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy("'test -f facet'")
    test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    try:
        b1 = communicator.stringToProxy("\"test -f facet'")
        test(False)
    except Ice.ProxyParseException:
        pass
    b1 = communicator.stringToProxy("\"test -f facet\"")
    test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy("\"test -f facet@test\"")
    test(b1.ice_getIdentity().name == "test -f facet@test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    b1 = communicator.stringToProxy("\"test -f facet@test @test\"")
    test(b1.ice_getIdentity().name == "test -f facet@test @test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getFacet()) == 0)
    try:
        b1 = communicator.stringToProxy("test test")
        test(False)
    except Ice.ProxyParseException:
        pass
    b1 = communicator.stringToProxy("test\\040test")
    test(b1.ice_getIdentity().name == "test test"
         and len(b1.ice_getIdentity().category) == 0)
    try:
        b1 = communicator.stringToProxy("test\\777")
        test(False)
    except Ice.IdentityParseException:
        pass
    b1 = communicator.stringToProxy("test\\40test")
    test(b1.ice_getIdentity().name == "test test")

    # Test some octal and hex corner cases.
    b1 = communicator.stringToProxy("test\\4test")
    test(b1.ice_getIdentity().name == "test\4test")
    b1 = communicator.stringToProxy("test\\04test")
    test(b1.ice_getIdentity().name == "test\4test")
    b1 = communicator.stringToProxy("test\\004test")
    test(b1.ice_getIdentity().name == "test\4test")
    b1 = communicator.stringToProxy("test\\1114test")
    test(b1.ice_getIdentity().name == "test\1114test")

    b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test")
    test(b1.ice_getIdentity().name == "test\b\f\n\r\t\'\"\\test"
         and len(b1.ice_getIdentity().category) == 0)

    b1 = communicator.stringToProxy("category/test")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
         len(b1.ice_getAdapterId()) == 0)

    b1 = communicator.stringToProxy("test@adapter")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getAdapterId() == "adapter")
    try:
        b1 = communicator.stringToProxy("id@adapter test")
        test(False)
    except Ice.ProxyParseException:
        pass
    b1 = communicator.stringToProxy("category/test@adapter")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
         b1.ice_getAdapterId() == "adapter")
    b1 = communicator.stringToProxy("category/test@adapter:tcp")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
         b1.ice_getAdapterId() == "adapter:tcp")
    b1 = communicator.stringToProxy("'category 1/test'@adapter")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category 1" and \
         b1.ice_getAdapterId() == "adapter")
    b1 = communicator.stringToProxy("'category/test 1'@adapter")
    test(b1.ice_getIdentity().name == "test 1" and b1.ice_getIdentity().category == "category" and \
         b1.ice_getAdapterId() == "adapter")
    b1 = communicator.stringToProxy("'category/test'@'adapter 1'")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
         b1.ice_getAdapterId() == "adapter 1")
    b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \
         b1.ice_getAdapterId() == "adapter")
    b1 = communicator.stringToProxy(
        "\"category \\/test@foo/test\"@\"adapter:tcp\"")
    test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \
         b1.ice_getAdapterId() == "adapter:tcp")

    b1 = communicator.stringToProxy("id -f facet")
    test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet")
    b1 = communicator.stringToProxy("id -f 'facet x'")
    test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet x")
    b1 = communicator.stringToProxy("id -f \"facet x\"")
    test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet x")
    try:
        b1 = communicator.stringToProxy("id -f \"facet x")
        test(False)
    except Ice.ProxyParseException:
        pass
    try:
        b1 = communicator.stringToProxy("id -f \'facet x")
        test(False)
    except Ice.ProxyParseException:
        pass
    b1 = communicator.stringToProxy("test -f facet:tcp")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet" and len(b1.ice_getAdapterId()) == 0)
    b1 = communicator.stringToProxy("test -f \"facet:tcp\"")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet:tcp" and len(b1.ice_getAdapterId()) == 0)
    b1 = communicator.stringToProxy("test -f facet@test")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet" and b1.ice_getAdapterId() == "test")
    b1 = communicator.stringToProxy("test -f 'facet@test'")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet@test" and len(b1.ice_getAdapterId()) == 0)
    b1 = communicator.stringToProxy("test -f 'facet@test'@test")
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         b1.ice_getFacet() == "facet@test" and b1.ice_getAdapterId() == "test")
    try:
        b1 = communicator.stringToProxy("test -f facet@test @test")
        test(False)
    except Ice.ProxyParseException:
        pass
    b1 = communicator.stringToProxy("test")
    test(b1.ice_isTwoway())
    b1 = communicator.stringToProxy("test -t")
    test(b1.ice_isTwoway())
    b1 = communicator.stringToProxy("test -o")
    test(b1.ice_isOneway())
    b1 = communicator.stringToProxy("test -O")
    test(b1.ice_isBatchOneway())
    b1 = communicator.stringToProxy("test -d")
    test(b1.ice_isDatagram())
    b1 = communicator.stringToProxy("test -D")
    test(b1.ice_isBatchDatagram())
    b1 = communicator.stringToProxy("test")
    test(not b1.ice_isSecure())
    b1 = communicator.stringToProxy("test -s")
    test(b1.ice_isSecure())

    try:
        b1 = communicator.stringToProxy("test:tcp@adapterId")
        test(False)
    except Ice.EndpointParseException:
        pass
    # This is an unknown endpoint warning, not a parse exception.
    #
    #try:
    #   b1 = communicator.stringToProxy("test -f the:facet:tcp")
    #   test(False)
    #except Ice.EndpointParseException:
    #   pass
    try:
        b1 = communicator.stringToProxy("test::tcp")
        test(False)
    except Ice.EndpointParseException:
        pass
    print("ok")

    sys.stdout.write("testing propertyToProxy... ")
    sys.stdout.flush()
    prop = communicator.getProperties()
    propertyPrefix = "Foo.Proxy"
    prop.setProperty(propertyPrefix, "test:default -p 12010")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
         len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0)

    property = propertyPrefix + ".Locator"
    test(not b1.ice_getLocator())
    prop.setProperty(property, "locator:default -p 10000")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getLocator()
         and b1.ice_getLocator().ice_getIdentity().name == "locator")
    prop.setProperty(property, "")

    property = propertyPrefix + ".LocatorCacheTimeout"
    test(b1.ice_getLocatorCacheTimeout() == -1)
    prop.setProperty(property, "1")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getLocatorCacheTimeout() == 1)
    prop.setProperty(property, "")

    # Now retest with an indirect proxy.
    prop.setProperty(propertyPrefix, "test")
    property = propertyPrefix + ".Locator"
    prop.setProperty(property, "locator:default -p 10000")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getLocator()
         and b1.ice_getLocator().ice_getIdentity().name == "locator")
    prop.setProperty(property, "")

    property = propertyPrefix + ".LocatorCacheTimeout"
    test(b1.ice_getLocatorCacheTimeout() == -1)
    prop.setProperty(property, "1")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getLocatorCacheTimeout() == 1)
    prop.setProperty(property, "")

    # This cannot be tested so easily because the property is cached
    # on communicator initialization.
    #
    #prop.setProperty("Ice.Default.LocatorCacheTimeout", "60")
    #b1 = communicator.propertyToProxy(propertyPrefix)
    #test(b1.ice_getLocatorCacheTimeout() == 60)
    #prop.setProperty("Ice.Default.LocatorCacheTimeout", "")

    prop.setProperty(propertyPrefix, "test:default -p 12010")

    property = propertyPrefix + ".Router"
    test(not b1.ice_getRouter())
    prop.setProperty(property, "router:default -p 10000")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getRouter()
         and b1.ice_getRouter().ice_getIdentity().name == "router")
    prop.setProperty(property, "")

    property = propertyPrefix + ".PreferSecure"
    test(not b1.ice_isPreferSecure())
    prop.setProperty(property, "1")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_isPreferSecure())
    prop.setProperty(property, "")

    property = propertyPrefix + ".ConnectionCached"
    test(b1.ice_isConnectionCached())
    prop.setProperty(property, "0")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(not b1.ice_isConnectionCached())
    prop.setProperty(property, "")

    property = propertyPrefix + ".InvocationTimeout"
    test(b1.ice_getInvocationTimeout() == -1)
    prop.setProperty(property, "1000")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getInvocationTimeout() == 1000)
    prop.setProperty(property, "")

    property = propertyPrefix + ".EndpointSelection"
    test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
    prop.setProperty(property, "Random")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
    prop.setProperty(property, "Ordered")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered)
    prop.setProperty(property, "")
    property = propertyPrefix + ".CollocationOptimized"
    test(b1.ice_isCollocationOptimized())
    prop.setProperty(property, "0")
    b1 = communicator.propertyToProxy(propertyPrefix)
    test(not b1.ice_isCollocationOptimized())
    prop.setProperty(property, "")

    print("ok")

    sys.stdout.write("testing proxyToProperty... ")
    sys.stdout.flush()

    b1 = communicator.stringToProxy("test")
    b1 = b1.ice_collocationOptimized(True)
    b1 = b1.ice_connectionCached(True)
    b1 = b1.ice_preferSecure(False)
    b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)
    b1 = b1.ice_locatorCacheTimeout(100)
    b1 = b1.ice_invocationTimeout(1234)
    b1 = b1.ice_encodingVersion(Ice.EncodingVersion(1, 0))

    router = communicator.stringToProxy("router")
    router = router.ice_collocationOptimized(False)
    router = router.ice_connectionCached(True)
    router = router.ice_preferSecure(True)
    router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random)
    router = router.ice_locatorCacheTimeout(200)
    router = router.ice_invocationTimeout(1500)

    locator = communicator.stringToProxy("locator")
    locator = locator.ice_collocationOptimized(True)
    locator = locator.ice_connectionCached(False)
    locator = locator.ice_preferSecure(True)
    locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random)
    locator = locator.ice_locatorCacheTimeout(300)
    locator = locator.ice_invocationTimeout(1500)

    locator = locator.ice_router(Ice.RouterPrx.uncheckedCast(router))
    b1 = b1.ice_locator(Ice.LocatorPrx.uncheckedCast(locator))

    proxyProps = communicator.proxyToProperty(b1, "Test")
    test(len(proxyProps) == 21)

    test(proxyProps["Test"] == "test -t -e 1.0")
    test(proxyProps["Test.CollocationOptimized"] == "1")
    test(proxyProps["Test.ConnectionCached"] == "1")
    test(proxyProps["Test.PreferSecure"] == "0")
    test(proxyProps["Test.EndpointSelection"] == "Ordered")
    test(proxyProps["Test.LocatorCacheTimeout"] == "100")
    test(proxyProps["Test.InvocationTimeout"] == "1234")

    test(proxyProps["Test.Locator"] == "locator -t -e " +
         Ice.encodingVersionToString(Ice.currentEncoding()))
    test(proxyProps["Test.Locator.CollocationOptimized"] == "1")
    test(proxyProps["Test.Locator.ConnectionCached"] == "0")
    test(proxyProps["Test.Locator.PreferSecure"] == "1")
    test(proxyProps["Test.Locator.EndpointSelection"] == "Random")
    test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300")
    test(proxyProps["Test.Locator.InvocationTimeout"] == "1500")

    test(proxyProps["Test.Locator.Router"] == "router -t -e " +
         Ice.encodingVersionToString(Ice.currentEncoding()))
    test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0")
    test(proxyProps["Test.Locator.Router.ConnectionCached"] == "1")
    test(proxyProps["Test.Locator.Router.PreferSecure"] == "1")
    test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random")
    test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200")
    test(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500")

    print("ok")

    sys.stdout.write("testing ice_getCommunicator... ")
    sys.stdout.flush()

    test(base.ice_getCommunicator() == communicator)

    print("ok")

    sys.stdout.write("testing proxy methods... ")
    sys.stdout.flush()


    test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) \
         == "other")

    #
    # Verify that ToStringMode is passed correctly
    #
    ident = Ice.Identity("test", "\x7F\xE2\x82\xAC")

    idStr = Ice.identityToString(ident, Ice.ToStringMode.Unicode)
    test(idStr == "\\u007f\xE2\x82\xAC/test")
    ident2 = Ice.stringToIdentity(idStr)
    test(ident == ident2)
    test(Ice.identityToString(ident) == idStr)

    idStr = Ice.identityToString(ident, Ice.ToStringMode.ASCII)
    test(idStr == "\\u007f\\u20ac/test")
    ident2 = Ice.stringToIdentity(idStr)
    test(ident == ident2)

    idStr = Ice.identityToString(ident, Ice.ToStringMode.Compat)
    test(idStr == "\\177\\342\\202\\254/test")
    ident2 = Ice.stringToIdentity(idStr)
    test(ident == ident2)

    ident2 = Ice.stringToIdentity(communicator.identityToString(ident))
    test(ident == ident2)

    test(base.ice_facet("facet").ice_getFacet() == "facet")
    test(base.ice_adapterId("id").ice_getAdapterId() == "id")
    test(base.ice_twoway().ice_isTwoway())
    test(base.ice_oneway().ice_isOneway())
    test(base.ice_batchOneway().ice_isBatchOneway())
    test(base.ice_datagram().ice_isDatagram())
    test(base.ice_batchDatagram().ice_isBatchDatagram())
    test(base.ice_secure(True).ice_isSecure())
    test(not base.ice_secure(False).ice_isSecure())
    test(base.ice_collocationOptimized(True).ice_isCollocationOptimized())
    test(not base.ice_collocationOptimized(False).ice_isCollocationOptimized())
    test(base.ice_preferSecure(True).ice_isPreferSecure())
    test(not base.ice_preferSecure(False).ice_isPreferSecure())
    test(
        base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() ==
        Ice.Encoding_1_0)
    test(
        base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion() ==
        Ice.Encoding_1_1)
    test(
        base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() !=
        Ice.Encoding_1_1)

    try:
        base.ice_timeout(0)
        test(False)
    except RuntimeError:
        pass

    try:
        base.ice_timeout(-1)
    except RuntimeError:
        test(False)

    try:
        base.ice_timeout(-2)
        test(False)
    except RuntimeError:
        pass

    try:
        base.ice_invocationTimeout(0)
        test(False)
    except RuntimeError:
        pass

    try:
        base.ice_invocationTimeout(-1)
    except RuntimeError:
        test(False)

    try:
        base.ice_invocationTimeout(-2)
        test(False)
    except RuntimeError:
        pass

    try:
        base.ice_locatorCacheTimeout(0)
    except RuntimeError:
        test(False)

    try:
        base.ice_locatorCacheTimeout(-1)
    except RuntimeError:
        test(False)

    try:
        base.ice_locatorCacheTimeout(-2)
        test(False)
    except RuntimeError:
        pass

    print("ok")

    sys.stdout.write("testing proxy comparison... ")
    sys.stdout.flush()

    test(
        communicator.stringToProxy("foo") == communicator.stringToProxy("foo"))
    test(
        communicator.stringToProxy("foo") != communicator.stringToProxy("foo2")
    )
    test(
        communicator.stringToProxy("foo") < communicator.stringToProxy("foo2"))
    test(not (communicator.stringToProxy("foo2") < communicator.stringToProxy(
        "foo")))

    compObj = communicator.stringToProxy("foo")

    test(compObj.ice_facet("facet") == compObj.ice_facet("facet"))
    test(compObj.ice_facet("facet") != compObj.ice_facet("facet1"))
    test(compObj.ice_facet("facet") < compObj.ice_facet("facet1"))
    test(not (compObj.ice_facet("facet") < compObj.ice_facet("facet")))

    test(compObj.ice_oneway() == compObj.ice_oneway())
    test(compObj.ice_oneway() != compObj.ice_twoway())
    test(compObj.ice_twoway() < compObj.ice_oneway())
    test(not (compObj.ice_oneway() < compObj.ice_twoway()))

    test(compObj.ice_secure(True) == compObj.ice_secure(True))
    test(compObj.ice_secure(False) != compObj.ice_secure(True))
    test(compObj.ice_secure(False) < compObj.ice_secure(True))
    test(not (compObj.ice_secure(True) < compObj.ice_secure(False)))

    test(
        compObj.ice_collocationOptimized(True) ==
        compObj.ice_collocationOptimized(True))
    test(
        compObj.ice_collocationOptimized(False) !=
        compObj.ice_collocationOptimized(True))
    test(
        compObj.ice_collocationOptimized(False) <
        compObj.ice_collocationOptimized(True))
    test(not (compObj.ice_collocationOptimized(True) <
              compObj.ice_collocationOptimized(False)))

    test(
        compObj.ice_connectionCached(True) == compObj.ice_connectionCached(
            True))
    test(
        compObj.ice_connectionCached(False) != compObj.ice_connectionCached(
            True))
    test(
        compObj.ice_connectionCached(False) < compObj.ice_connectionCached(
            True))
    test(not (compObj.ice_connectionCached(True) <
              compObj.ice_connectionCached(False)))

    test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) == \
         compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))
    test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) != \
         compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
    test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) < \
         compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
    test(not (compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) < \
         compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random)))

    test(compObj.ice_connectionId("id2") == compObj.ice_connectionId("id2"))
    test(compObj.ice_connectionId("id1") != compObj.ice_connectionId("id2"))
    test(compObj.ice_connectionId("id1") < compObj.ice_connectionId("id2"))
    test(not (
        compObj.ice_connectionId("id2") < compObj.ice_connectionId("id1")))
    test(compObj.ice_connectionId("id1").ice_getConnectionId() == "id1")
    test(compObj.ice_connectionId("id2").ice_getConnectionId() == "id2")

    test(compObj.ice_compress(True) == compObj.ice_compress(True))
    test(compObj.ice_compress(False) != compObj.ice_compress(True))
    test(compObj.ice_compress(False) < compObj.ice_compress(True))
    test(not (compObj.ice_compress(True) < compObj.ice_compress(False)))

    test(compObj.ice_timeout(20) == compObj.ice_timeout(20))
    test(compObj.ice_timeout(10) != compObj.ice_timeout(20))
    test(compObj.ice_timeout(10) < compObj.ice_timeout(20))
    test(not (compObj.ice_timeout(20) < compObj.ice_timeout(10)))

    loc1 = Ice.LocatorPrx.uncheckedCast(
        communicator.stringToProxy("loc1:default -p 10000"))
    loc2 = Ice.LocatorPrx.uncheckedCast(
        communicator.stringToProxy("loc2:default -p 10000"))
    test(compObj.ice_locator(None) == compObj.ice_locator(None))
    test(compObj.ice_locator(loc1) == compObj.ice_locator(loc1))
    test(compObj.ice_locator(loc1) != compObj.ice_locator(None))
    test(compObj.ice_locator(None) != compObj.ice_locator(loc2))
    test(compObj.ice_locator(loc1) != compObj.ice_locator(loc2))
    test(compObj.ice_locator(None) < compObj.ice_locator(loc1))
    test(not (compObj.ice_locator(loc1) < compObj.ice_locator(None)))
    test(compObj.ice_locator(loc1) < compObj.ice_locator(loc2))
    test(not (compObj.ice_locator(loc2) < compObj.ice_locator(loc1)))

    rtr1 = Ice.RouterPrx.uncheckedCast(
        communicator.stringToProxy("rtr1:default -p 10000"))
    rtr2 = Ice.RouterPrx.uncheckedCast(
        communicator.stringToProxy("rtr2:default -p 10000"))
    test(compObj.ice_router(None) == compObj.ice_router(None))
    test(compObj.ice_router(rtr1) == compObj.ice_router(rtr1))
    test(compObj.ice_router(rtr1) != compObj.ice_router(None))
    test(compObj.ice_router(None) != compObj.ice_router(rtr2))
    test(compObj.ice_router(rtr1) != compObj.ice_router(rtr2))
    test(compObj.ice_router(None) < compObj.ice_router(rtr1))
    test(not (compObj.ice_router(rtr1) < compObj.ice_router(None)))
    test(compObj.ice_router(rtr1) < compObj.ice_router(rtr2))
    test(not (compObj.ice_router(rtr2) < compObj.ice_router(rtr1)))

    ctx1 = {}
    ctx1["ctx1"] = "v1"
    ctx2 = {}
    ctx2["ctx2"] = "v2"
    test(compObj.ice_context({}) == compObj.ice_context({}))
    test(compObj.ice_context(ctx1) == compObj.ice_context(ctx1))
    test(compObj.ice_context(ctx1) != compObj.ice_context({}))
    test(compObj.ice_context({}) != compObj.ice_context(ctx2))
    test(compObj.ice_context(ctx1) != compObj.ice_context(ctx2))
    test(compObj.ice_context(ctx1) < compObj.ice_context(ctx2))
    test(not (compObj.ice_context(ctx2) < compObj.ice_context(ctx1)))

    test(compObj.ice_preferSecure(True) == compObj.ice_preferSecure(True))
    test(compObj.ice_preferSecure(True) != compObj.ice_preferSecure(False))
    test(compObj.ice_preferSecure(False) < compObj.ice_preferSecure(True))
    test(not (
        compObj.ice_preferSecure(True) < compObj.ice_preferSecure(False)))

    compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")
    compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001")
    test(compObj1 != compObj2)
    test(compObj1 < compObj2)
    test(not (compObj2 < compObj1))

    compObj1 = communicator.stringToProxy("foo@MyAdapter1")
    compObj2 = communicator.stringToProxy("foo@MyAdapter2")
    test(compObj1 != compObj2)
    test(compObj1 < compObj2)
    test(not (compObj2 < compObj1))

    test(
        compObj1.ice_locatorCacheTimeout(20) ==
        compObj1.ice_locatorCacheTimeout(20))
    test(
        compObj1.ice_locatorCacheTimeout(10) !=
        compObj1.ice_locatorCacheTimeout(20))
    test(
        compObj1.ice_locatorCacheTimeout(10) <
        compObj1.ice_locatorCacheTimeout(20))
    test(not (compObj1.ice_locatorCacheTimeout(20) <
              compObj1.ice_locatorCacheTimeout(10)))

    test(
        compObj1.ice_invocationTimeout(20) == compObj1.ice_invocationTimeout(
            20))
    test(
        compObj1.ice_invocationTimeout(10) != compObj1.ice_invocationTimeout(
            20))
    test(
        compObj1.ice_invocationTimeout(10) < compObj1.ice_invocationTimeout(20)
    )
    test(not (compObj1.ice_invocationTimeout(20) <
              compObj1.ice_invocationTimeout(10)))

    compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000")
    compObj2 = communicator.stringToProxy("foo@MyAdapter1")
    test(compObj1 != compObj2)
    test(compObj1 < compObj2)
    test(not (compObj2 < compObj1))

    endpts1 = communicator.stringToProxy(
        "foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()
    endpts2 = communicator.stringToProxy(
        "foo:tcp -h 127.0.0.1 -p 10001").ice_getEndpoints()
    test(endpts1 != endpts2)
    test(endpts1 < endpts2)
    test(not (endpts2 < endpts1))
    test(endpts1 == communicator.stringToProxy(
        "foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints())

    test(
        compObj1.ice_encodingVersion(Ice.Encoding_1_0) ==
        compObj1.ice_encodingVersion(Ice.Encoding_1_0))
    test(
        compObj1.ice_encodingVersion(Ice.Encoding_1_0) !=
        compObj1.ice_encodingVersion(Ice.Encoding_1_1))
    test(
        compObj.ice_encodingVersion(Ice.Encoding_1_0) <
        compObj.ice_encodingVersion(Ice.Encoding_1_1))
    test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) <
              compObj.ice_encodingVersion(Ice.Encoding_1_0)))

    #
    # TODO: Ideally we should also test comparison of fixed proxies.
    #

    print("ok")

    sys.stdout.write("testing checked cast... ")
    sys.stdout.flush()
    cl = Test.MyClassPrx.checkedCast(base)
    test(cl)

    derived = Test.MyDerivedClassPrx.checkedCast(cl)
    test(derived)
    test(cl == base)
    test(derived == base)
    test(cl == derived)

    loc = Ice.LocatorPrx.checkedCast(base)
    test(loc == None)

    #
    # Upcasting
    #
    cl2 = Test.MyClassPrx.checkedCast(derived)
    obj = Ice.ObjectPrx.checkedCast(derived)
    test(cl2)
    test(obj)
    test(cl2 == obj)
    test(cl2 == derived)

    print("ok")

    sys.stdout.write("testing checked cast with context... ")
    sys.stdout.flush()
    tccp = Test.MyClassPrx.checkedCast(base)
    c = tccp.getContext()
    test(c == None or len(c) == 0)

    c = {}
    c["one"] = "hello"
    c["two"] = "world"
    tccp = Test.MyClassPrx.checkedCast(base, c)
    c2 = tccp.getContext()
    test(c == c2)
    print("ok")

    sys.stdout.write("testing encoding versioning... ")
    sys.stdout.flush()
    ref20 = "test -e 2.0:default -p 12010"
    cl20 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref20))
    try:
        cl20.ice_ping()
        test(false)
    except Ice.UnsupportedEncodingException:
        # Server 2.0 endpoint doesn't support 1.1 version.
        pass

    ref10 = "test -e 1.0:default -p 12010"
    cl10 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref10))
    cl10.ice_ping()
    cl10.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
    cl.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()

    # 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
    # call will use the 1.1 encoding
    ref13 = "test -e 1.3:default -p 12010"
    cl13 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref13))
    cl13.ice_ping()

    print("ok")

    sys.stdout.write("testing opaque endpoints... ")
    sys.stdout.flush()

    try:
        # Invalid -x option
        p = communicator.stringToProxy("id:opaque -t 99 -v abc -x abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Missing -t and -v
        p = communicator.stringToProxy("id:opaque")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Repeated -t
        p = communicator.stringToProxy("id:opaque -t 1 -t 1 -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Repeated -v
        p = communicator.stringToProxy("id:opaque -t 1 -v abc -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Missing -t
        p = communicator.stringToProxy("id:opaque -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Missing -v
        p = communicator.stringToProxy("id:opaque -t 1")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Missing arg for -t
        p = communicator.stringToProxy("id:opaque -t -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Missing arg for -v
        p = communicator.stringToProxy("id:opaque -t 1 -v")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Not a number for -t
        p = communicator.stringToProxy("id:opaque -t x -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # < 0 for -t
        p = communicator.stringToProxy("id:opaque -t -1 -v abc")
        test(False)
    except Ice.EndpointParseException:
        pass

    try:
        # Invalid char for -v
        p = communicator.stringToProxy("id:opaque -t 99 -v x?c")
        test(False)
    except Ice.EndpointParseException:
        pass

    # Legal TCP endpoint expressed as opaque endpoint
    p1 = communicator.stringToProxy(
        "test -e 1.1:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==")
    pstr = communicator.proxyToString(p1)
    test(pstr == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")

    # Opaque endpoint encoded with 1.1 encoding.
    p2 = communicator.stringToProxy(
        "test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==")
    test(
        communicator.proxyToString(p2) ==
        "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")

    if communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0:
        # Working?
        ssl = communicator.getProperties().getProperty(
            "Ice.Default.Protocol") == "ssl"
        tcp = communicator.getProperties().getProperty(
            "Ice.Default.Protocol") == "tcp"
        if tcp:
            p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()

        # Two legal TCP endpoints expressed as opaque endpoints
        p1 = communicator.stringToProxy(
            "test -e 1.0:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMusuAAAQJwAAAA=="
        )
        pstr = communicator.proxyToString(p1)
        test(
            pstr ==
            "test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000"
        )

        #
        # Test that an SSL endpoint and a nonsense endpoint get written
        # back out as an opaque endpoint.
        #
        p1 = communicator.stringToProxy(
            "test -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch"
        )
        pstr = communicator.proxyToString(p1)
        if ssl:
            test(
                pstr ==
                "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch"
            )
        elif tcp:
            test(
                pstr ==
                "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch"
            )

        #
        # Try to invoke on the SSL endpoint to verify that we get a
        # NoEndpointException (or ConnectionRefusedException when
        # running with SSL).
        #
        try:
            p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
            test(False)
        except Ice.NoEndpointException:
            test(not ssl)
        except Ice.ConnectFailedException:
            test(not tcp)

        #
        # Test that the proxy with an SSL endpoint and a nonsense
        # endpoint (which the server doesn't understand either) can be
        # sent over the wire and returned by the server without losing
        # the opaque endpoints.
        #
        p2 = derived.echo(p1)
        pstr = communicator.proxyToString(p2)
        if ssl:
            test(
                pstr ==
                "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch"
            )
        elif tcp:
            test(
                pstr ==
                "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch"
            )

    print("ok")

    return cl
コード例 #27
0
ファイル: BatchOneways.py プロジェクト: chuanqingli/ice
def batchOneways(p):

    if sys.version_info[0] == 2:
        bs1 = []
        bs1[0:10 * 1024] = range(0, 10 * 1024)  # add 100,000 entries.
        bs1 = ['\x00' for x in bs1]  # set them all to \x00
        bs1 = ''.join(bs1)  # make into a byte array
    else:
        bs1 = bytes([0 for x in range(0, 10 * 1024)])

    try:
        p.opByteSOneway(bs1)
    except Ice.MemoryLimitException:
        test(False)

    batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

    batch.ice_flushBatchRequests()  # Empty flush
    if batch.ice_getConnection():
        batch.ice_getConnection().flushBatchRequests(
            Ice.CompressBatch.BasedOnProxy)
    batch.ice_getCommunicator().flushBatchRequests(
        Ice.CompressBatch.BasedOnProxy)

    p.opByteSOnewayCallCount()  # Reset the call count

    for i in range(30):
        batch.opByteSOneway(bs1)

    count = 0
    while count < 27:  # 3 * 9 requests auto-flushed.
        count += p.opByteSOnewayCallCount()
        time.sleep(0.01)

    if p.ice_getConnection():
        batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
        batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())

        batch1.ice_ping()
        batch2.ice_ping()
        batch1.ice_flushBatchRequests()
        batch1.ice_getConnection().close(
            Ice.ConnectionClose.GracefullyWithWait)
        batch1.ice_ping()
        batch2.ice_ping()

        batch1.ice_getConnection()
        batch2.ice_getConnection()

        batch1.ice_ping()
        batch1.ice_getConnection().close(
            Ice.ConnectionClose.GracefullyWithWait)

        batch1.ice_ping()
        batch2.ice_ping()

    identity = Ice.Identity()
    identity.name = "invalid"
    batch3 = batch.ice_identity(identity)
    batch3.ice_ping()
    batch3.ice_flushBatchRequests()

    # Make sure that a bogus batch request doesn't cause troubles to other ones.
    batch3.ice_ping()
    batch.ice_ping()
    batch.ice_flushBatchRequests()
    batch.ice_ping()

    if batch.ice_getConnection():
        initData = Ice.InitializationData()
        initData.properties = p.ice_getCommunicator().getProperties().clone()
        interceptor = BatchRequestInterceptorI()
        initData.batchRequestInterceptor = interceptor.enqueue

        ic = Ice.initialize(data=initData)

        batch = Test.MyClassPrx.uncheckedCast(
            ic.stringToProxy(p.ice_toString())).ice_batchOneway()

        test(interceptor.count() == 0)
        batch.ice_ping()
        batch.ice_ping()
        batch.ice_ping()
        test(interceptor.count() == 0)

        interceptor.setEnabled(True)
        batch.ice_ping()
        batch.ice_ping()
        batch.ice_ping()
        test(interceptor.count() == 3)

        batch.ice_flushBatchRequests()
        batch.ice_ping()
        test(interceptor.count() == 1)

        batch.opByteSOneway(bs1)
        test(interceptor.count() == 2)
        batch.opByteSOneway(bs1)
        test(interceptor.count() == 3)

        batch.opByteSOneway(bs1)  # This should trigger the flush
        batch.ice_ping()
        test(interceptor.count() == 2)

        ic.destroy()
コード例 #28
0
ファイル: AllTests.py プロジェクト: zj771484545/ice
def allTests(helper, communicator):
    ref = "ServerManager:{0}".format(helper.getTestEndpoint())
    manager = Test.ServerManagerPrx.checkedCast(communicator.stringToProxy(ref))
    locator = communicator.getDefaultLocator()
    test(manager)

    registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry())
    test(registry)

    sys.stdout.write("testing stringToProxy... ")
    sys.stdout.flush()
    base = communicator.stringToProxy("test @ TestAdapter")
    base2 = communicator.stringToProxy("test @ TestAdapter")
    base3 = communicator.stringToProxy("test")
    base4 = communicator.stringToProxy("ServerManager")
    base5 = communicator.stringToProxy("test2")
    print("ok")

    sys.stdout.write("testing ice_locator and ice_getLocator...  ")
    sys.stdout.flush()
    test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()))
    anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator"))
    base = base.ice_locator(anotherLocator)
    test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator))
    communicator.setDefaultLocator(None)
    base = communicator.stringToProxy("test @ TestAdapter")
    test(not base.ice_getLocator())
    base = base.ice_locator(anotherLocator)
    test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator))
    communicator.setDefaultLocator(locator)
    base = communicator.stringToProxy("test @ TestAdapter")
    test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()))

    #
    # We also test ice_router/ice_getRouter (perhaps we should add a
    # test/Ice/router test?)
    #
    test(not base.ice_getRouter())
    anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter"))
    base = base.ice_router(anotherRouter)
    test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter))
    router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter"))
    communicator.setDefaultRouter(router)
    base = communicator.stringToProxy("test @ TestAdapter")
    test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter()))
    communicator.setDefaultRouter(None)
    base = communicator.stringToProxy("test @ TestAdapter")
    test(not base.ice_getRouter())
    print("ok")

    sys.stdout.write("starting server... ")
    sys.stdout.flush()
    manager.startServer()
    print("ok")

    sys.stdout.write("testing checked cast... ")
    sys.stdout.flush()
    obj = Test.TestIntfPrx.checkedCast(base)
    obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test@TestAdapter"))
    obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test   @TestAdapter"))
    obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test@   TestAdapter"))
    test(obj)
    obj2 = Test.TestIntfPrx.checkedCast(base2)
    test(obj2)
    obj3 = Test.TestIntfPrx.checkedCast(base3)
    test(obj3)
    obj4 = Test.ServerManagerPrx.checkedCast(base4)
    test(obj4)
    obj5 = Test.TestIntfPrx.checkedCast(base5)
    test(obj5)
    print("ok")

    sys.stdout.write("testing id@AdapterId indirect proxy... ")
    sys.stdout.flush()
    obj.shutdown()
    manager.startServer()
    try:
        obj2 = Test.TestIntfPrx.checkedCast(base2)
        obj2.ice_ping()
    except Ice.LocalException:
        test(False)
    print("ok")

    sys.stdout.write("testing identity indirect proxy... ")
    sys.stdout.flush()
    obj.shutdown()
    manager.startServer()
    try:
        obj3 = Test.TestIntfPrx.checkedCast(base3)
        obj3.ice_ping()
    except Ice.LocalException as ex:
        print(ex)
        test(False)
    try:
        obj2 = Test.TestIntfPrx.checkedCast(base2)
        obj2.ice_ping()
    except Ice.LocalException as ex:
        print(ex)
        test(False)
    obj.shutdown()
    manager.startServer()
    try:
        obj2 = Test.TestIntfPrx.checkedCast(base2)
        obj2.ice_ping()
    except Ice.LocalException as ex:
        print(ex)
        test(False)
    try:
        obj3 = Test.TestIntfPrx.checkedCast(base3)
        obj3.ice_ping()
    except Ice.LocalException as ex:
        print(ex)
        test(False)
    obj.shutdown()
    manager.startServer()

    try:
        obj2 = Test.TestIntfPrx.checkedCast(base2)
        obj2.ice_ping()
    except Ice.LocalException:
        test(False)
    obj.shutdown()
    manager.startServer()
    try:
        obj3 = Test.TestIntfPrx.checkedCast(base3)
        obj3.ice_ping()
    except Ice.LocalException:
        test(False)
    obj.shutdown()
    manager.startServer()
    try:
        obj2 = Test.TestIntfPrx.checkedCast(base2)
        obj2.ice_ping()
    except Ice.LocalException:
        test(False)
    obj.shutdown()
    manager.startServer()

    try:
        obj5 = Test.TestIntfPrx.checkedCast(base5)
        obj5.ice_ping()
    except Ice.LocalException:
        test(False)
    print("ok")

    sys.stdout.write("testing reference with unknown identity... ")
    sys.stdout.flush()
    try:
        base = communicator.stringToProxy("unknown/unknown")
        base.ice_ping()
        test(False)
    except Ice.NotRegisteredException as ex:
        test(ex.kindOfObject == "object")
        test(ex.id == "unknown/unknown")
    print("ok")

    sys.stdout.write("testing reference with unknown adapter... ")
    sys.stdout.flush()
    try:
        base = communicator.stringToProxy("test @ TestAdapterUnknown")
        base.ice_ping()
        test(False)
    except Ice.NotRegisteredException as ex:
        test(ex.kindOfObject == "object adapter")
        test(ex.id == "TestAdapterUnknown")
    print("ok")

    sys.stdout.write("testing object reference from server... ")
    sys.stdout.flush()
    hello = obj.getHello()
    hello.sayHello()
    print("ok")

    sys.stdout.write("testing object reference from server after shutdown... ")
    sys.stdout.flush()
    obj.shutdown()
    manager.startServer()
    hello.sayHello()
    print("ok")

    sys.stdout.write("testing object migration... ")
    sys.stdout.flush()
    hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello"))
    obj.migrateHello()
    hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
    hello.sayHello()
    obj.migrateHello()
    hello.sayHello()
    obj.migrateHello()
    hello.sayHello()
    print("ok")

    sys.stdout.write("shutdown server... ")
    sys.stdout.flush()
    obj.shutdown()
    print("ok")

    sys.stdout.write("testing whether server is gone... ")
    sys.stdout.flush()
    try:
        obj2.ice_ping()
        test(False)
    except Ice.LocalException:
        pass
    try:
        obj3.ice_ping()
        test(False)
    except Ice.LocalException:
        pass
    try:
        obj5.ice_ping()
        test(False)
    except Ice.LocalException:
        pass
    print("ok")

    sys.stdout.write("testing indirect references to collocated objects... ")
    sys.stdout.flush()
    communicator.getProperties().setProperty("Hello.AdapterId", Ice.generateUUID())
    adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default")

    id = Ice.Identity()
    id.name = Ice.generateUUID()
    adapter.add(HelloI(), id)

    helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(Ice.identityToString(id)))
    test(not helloPrx.ice_getConnection())

    helloPrx = Test.HelloPrx.checkedCast(adapter.createIndirectProxy(id))
    test(not helloPrx.ice_getConnection())

    helloPrx = Test.HelloPrx.checkedCast(adapter.createDirectProxy(id))
    test(not helloPrx.ice_getConnection())

    print("ok")

    sys.stdout.write("shutdown server manager... ")
    sys.stdout.flush()
    manager.shutdown()
    print("ok")
コード例 #29
0
ファイル: AllTests.py プロジェクト: zxh1986123/ice
def allTests(communicator):

    oa = communicator.createObjectAdapterWithEndpoints("MyOA",
                                                       "tcp -h localhost")
    oa.activate()

    servant = MyObjectI.MyObjectI()

    # Register default servant with category "foo"
    oa.addDefaultServant(servant, "foo")

    # Start test
    sys.stdout.write("testing single category... ")
    sys.stdout.flush()

    r = oa.findDefaultServant("foo")
    test(r == servant)

    r = oa.findDefaultServant("bar")
    test(r == None)

    identity = Ice.Identity()
    identity.category = "foo"

    names = ("foo", "bar", "x", "y", "abcdefg")

    for idx in range(0, 5):
        identity.name = names[idx]
        prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
        prx.ice_ping()
        test(prx.getName() == names[idx])

    identity.name = "ObjectNotExist"
    prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
    try:
        prx.ice_ping()
        test(false)
    except Ice.ObjectNotExistException:
        # Expected
        pass

    try:
        prx.getName()
        test(false)
    except Ice.ObjectNotExistException:
        # Expected
        pass

    identity.name = "FacetNotExist"
    prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
    try:
        prx.ice_ping()
        test(false)
    except Ice.FacetNotExistException:
        # Expected
        pass

    try:
        prx.getName()
        test(false)
    except Ice.FacetNotExistException:
        # Expected
        pass

    identity.category = "bar"
    for idx in range(0, 5):
        identity.name = names[idx]
        prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))

        try:
            prx.ice_ping()
            test(false)
        except Ice.ObjectNotExistException:
            # Expected
            pass

        try:
            prx.getName()
            test(false)
        except Ice.ObjectNotExistException:
            # Expected
            pass

    oa.removeDefaultServant("foo")
    identity.category = "foo"
    prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
    try:
        prx.ice_ping()
    except Ice.ObjectNotExistException:
        # Expected
        pass

    print("ok")

    sys.stdout.write("testing default category... ")
    sys.stdout.flush()

    oa.addDefaultServant(servant, "")

    r = oa.findDefaultServant("bar")
    test(r == None)

    r = oa.findDefaultServant("")
    test(r == servant)

    for idx in range(0, 5):
        identity.name = names[idx]
        prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
        prx.ice_ping()
        test(prx.getName() == names[idx])

    print("ok")
コード例 #30
0
 def create_callback_identity(self, name):
     return Ice.Identity(name, self.category_for_client)