예제 #1
0
 def test_narrow_fault(self):
     def raiser():
         raise Exception("Boom!")
     contextmock = mock.Mock(spec=CORBA.Object)
     contextmock._narrow.side_effect = raiser
     workingdirmock = mock.Mock(spec=NT.CosNaming._objref_NamingContext)
     workingdirmock.resolve.return_value = contextmock
     self.assertEqual(True, NT.getnode('foo', workingdirmock) is None)
예제 #2
0
 def initCORBA(self):
     '''
     Handles all the CORBA involved in creating a CommonNC.
     
     Parameters: None
     
     Returns: Nothing
     
     Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
     '''
     #Get orb stuff, and name service tree.
     #If any of this fails, must raise an exception because there's absolutely
     #nothing that can be done.
     try:
         self.nt = NameTree.nameTree(getORB())
     except Exception, e:
         print_exc()
         raise CORBAProblemExImpl(nvSeq=[NameValue("channelname",
                                                   self.channelName),
                                         NameValue("exception",
                                                   str(e))])
예제 #3
0
 def initCORBA(self):
     '''
     Handles all the CORBA involved in creating a CommonNC.
     
     Parameters: None
     
     Returns: Nothing
     
     Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
     '''
     #Get orb stuff, and name service tree.
     #If any of this fails, must raise an exception because there's absolutely
     #nothing that can be done.
     try:
         self.nt = NameTree.nameTree(getORB())
     except Exception, e:
         print_exc()
         raise CORBAProblemExImpl(nvSeq=[
             NameValue("channelname", self.channelName),
             NameValue("exception", str(e))
         ])
예제 #4
0
    def __init__(self, name="ACS Event Admin Client"):
        '''
        Just call superclass constructors here.
        '''
        PySimpleClient.__init__(self, name)

        #dictionary which consists of all active channels
        #the keys here are the channelNames in string format
        self.channels = {}
        
        #so long as this evaluates to true, the thread continues executing
        self.running = 1

        #start a new thread to continuously look for new channels in the naming
        #service
        self.getLogger().logInfo("Creating a thread to poll the CORBA Naming Service for new channels...")

        #Get the Naming Service helper class
        self.nt = NameTree.nameTree(getORB())
        
        start_new_thread(self.pollNamingService, ())
        return    
예제 #5
0
 def setUp(self, nsmock):
     topmock = mock.Mock(spec=NT.CosNaming._objref_NamingContext)
     nsmock._narrow.return_value = mock.Mock(spec=CORBA.Object)
     self.nt = NT.nameTree(None)
예제 #6
0
 def test_ok(self, nsmock):
     nsmock.return_value = mock.Mock(spec=CORBA.Object)
     nt = NT.nameTree(None)
     self.assertEqual(True, 'top' in nt.__dict__)
예제 #7
0
 def test_no_nameservice(self, nsmock):
     nsmock.return_value = None
     nt = NT.nameTree(None)
     self.assertEqual(False, 'top' in nt.__dict__)
예제 #8
0
 def test_normal_operation(self):
     contextmock = mock.Mock(spec=CORBA.Object)
     workingdirmock = mock.Mock(spec=NT.CosNaming._objref_NamingContext)
     workingdirmock.resolve.return_value = contextmock
     self.assertEqual(False, NT.getnode('foo', workingdirmock) is None)
예제 #9
0
 def test_resolve_fault(self):
     def raiser():
         raise Exception("Boom!")
     workingdirmock = mock.Mock(spec=NT.CosNaming._objref_NamingContext)
     workingdirmock.resolve.side_effect = raiser
     self.assertEqual(True, NT.getnode('foo', workingdirmock) is None)