Ejemplo n.º 1
0
 def test_getDestinationAddress(self):
     self.assertEqual(
         module.getDestinationAddress("bblabl.ch::Topics::MyTopic"),
         "/topic/MyTopic")
     self.assertEqual(
         module.getDestinationAddress("bblabl.ch::Queues::MyQueue"),
         "/queue/MyQueue")
Ejemplo n.º 2
0
 def test_twoDifferentCallbacks(self):
     myCallback = module.generateDefaultCallback()
     myCallback2 = module.generateDefaultCallback()
     myCallback("", "test message")
     myCallback2("", "test message2")
     self.assertEqual(myCallback.get(), "test message")
     self.assertRaises(Queue.Empty, myCallback.get)
     self.assertEqual(myCallback2.get(), "test message2")
     self.assertRaises(Queue.Empty, myCallback2.get)
Ejemplo n.º 3
0
 def test_twoDifferentCallbacks( self ):
   myCallback = module.generateDefaultCallback()
   myCallback2 = module.generateDefaultCallback()
   myCallback("", "test message")
   myCallback2("", "test message2")
   self.assertEqual(myCallback.get(), "test message")
   self.assertRaises(Queue.Empty, myCallback.get)
   self.assertEqual(myCallback2.get(), "test message2")
   self.assertRaises(Queue.Empty, myCallback2.get)
Ejemplo n.º 4
0
  def test_getQueueByInvalidName(self):
    """ Try to get a queue by invalid names
    """

    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': {}}

    # try different possibilities
    result = module.getMQParamsFromCS('%s' % QUEUE_NAME)
    self.assertFalse(result['OK'])

    result = module.getMQParamsFromCS(mqURI=MQSERVICE_NAME + "::" + QUEUE_TYPE + "::" + "InvalidName")
    self.assertFalse(result['OK'])

    result = module.getMQParamsFromCS('%s::' % MQSERVICE_NAME)
    self.assertFalse(result['OK'])

    result = module.getMQParamsFromCS('%s::%s' % (MQSERVICE_NAME, QUEUE_NAME))
    self.assertFalse(result['OK'])
Ejemplo n.º 5
0
  def test_getQueueByInvalidName( self ):
    """ Try to get a queue by invalid names
    """

    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': {}}

    # try different possibilities
    result = module.getMQParamsFromCS( '%s' % QUEUE_NAME )
    self.assertFalse( result['OK'] )
    
    result = module.getMQParamsFromCS( mqURI = MQSERVICE_NAME+"::" +QUEUE_TYPE+ "::"+ "InvalidName" )
    self.assertFalse( result['OK'] )

    result = module.getMQParamsFromCS( '%s::' % MQSERVICE_NAME )
    self.assertFalse( result['OK'] )

    result = module.getMQParamsFromCS( '%s::%s' % ( MQSERVICE_NAME, QUEUE_NAME ) )
    self.assertFalse( result['OK'] )
Ejemplo n.º 6
0
 def test_severalMessages(self):
     myCallback = module.generateDefaultCallback()
     myCallback("", "test message1")
     myCallback("", "test message2")
     myCallback("", "test message3")
     myCallback("", "test message4")
     self.assertEqual(myCallback.get(), "test message1")
     self.assertEqual(myCallback.get(), "test message2")
     self.assertEqual(myCallback.get(), "test message3")
     self.assertEqual(myCallback.get(), "test message4")
     self.assertRaises(Queue.Empty, myCallback.get)
Ejemplo n.º 7
0
 def test_severalMessages( self ):
   myCallback = module.generateDefaultCallback()
   myCallback("", "test message1")
   myCallback("", "test message2")
   myCallback("", "test message3")
   myCallback("", "test message4")
   self.assertEqual(myCallback.get(), "test message1")
   self.assertEqual(myCallback.get(), "test message2")
   self.assertEqual(myCallback.get(), "test message3")
   self.assertEqual(myCallback.get(), "test message4")
   self.assertRaises(Queue.Empty, myCallback.get)
Ejemplo n.º 8
0
  def test_getQueue(self):

    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': QUEUE_CONFIG}

    # check returned value
    result = module.getMQParamsFromCS(mqURI=MQSERVICE_NAME + "::" + QUEUE_TYPE + "::" + QUEUE_NAME)
    self.assertTrue(result['OK'])

    # check queue parameters
    self.assertEqual(result['Value']['Queue'], QUEUE_NAME)
    self.assertEqual(result['Value']['Host'], MQSERVICE_NAME)
    self.assertTrue(result['Value']['Acknowledgement'])

    with self.assertRaises(KeyError):
      result['Value']['Topic']
Ejemplo n.º 9
0
  def test_getQueue( self ):

    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': QUEUE_CONFIG}

    # check returned value
    result = module.getMQParamsFromCS(mqURI = MQSERVICE_NAME+"::" +QUEUE_TYPE+ "::"+ QUEUE_NAME )
    self.assertTrue( result['OK'] )

    # check queue parameters
    self.assertEqual( result['Value']['Queue'], QUEUE_NAME )
    self.assertEqual( result['Value']['Host'], MQSERVICE_NAME )
    self.assertTrue( result['Value']['Acknowledgement'] )

    with self.assertRaises( KeyError ):
      result['Value']['Topic']
Ejemplo n.º 10
0
  def test_getTopic( self ):
    """ Try to get a topic 
    """
    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': TOPIC_CONFIG}

    # check returned value
    TOPIC_NAME=QUEUE_NAME
    result = module.getMQParamsFromCS(mqURI = MQSERVICE_NAME+"::" +TOPIC_TYPE+ "::"+ TOPIC_NAME )
    self.assertTrue( result['OK'] )

    # check topic parameters
    self.assertEqual( result['Value']['Topic'], TOPIC_NAME )
    self.assertEqual( result['Value']['Host'], MQSERVICE_NAME )
    self.assertTrue( result['Value']['Acknowledgement'] )

    with self.assertRaises( KeyError ):
      result['Value']['Queue']
Ejemplo n.º 11
0
  def test_getTopic(self):
    """ Try to get a topic
    """
    module.gConfig.getConfigurationTree.return_value = {'OK': True, 'Value': TOPIC_CONFIG}

    # check returned value
    TOPIC_NAME = QUEUE_NAME
    result = module.getMQParamsFromCS(mqURI=MQSERVICE_NAME + "::" + TOPIC_TYPE + "::" + TOPIC_NAME)
    self.assertTrue(result['OK'])

    # check topic parameters
    self.assertEqual(result['Value']['Topic'], TOPIC_NAME)
    self.assertEqual(result['Value']['Host'], MQSERVICE_NAME)
    self.assertTrue(result['Value']['Acknowledgement'])

    with self.assertRaises(KeyError):
      result['Value']['Queue']
Ejemplo n.º 12
0
    def test_getQueue(self):

        module.gConfig.getConfigurationTree.return_value = {
            "OK": True,
            "Value": QUEUE_CONFIG
        }

        # check returned value
        result = module.getMQParamsFromCS(mqURI=MQSERVICE_NAME + "::" +
                                          QUEUE_TYPE + "::" + QUEUE_NAME)
        self.assertTrue(result["OK"])

        # check queue parameters
        self.assertEqual(result["Value"]["Queue"], QUEUE_NAME)
        self.assertEqual(result["Value"]["Host"], MQSERVICE_NAME)
        self.assertTrue(result["Value"]["Acknowledgement"])

        with self.assertRaises(KeyError):
            result["Value"]["Topic"]
Ejemplo n.º 13
0
 def test_EmptyMessage(self):
     myCallback = module.generateDefaultCallback()
     self.assertRaises(Queue.Empty, myCallback.get)
Ejemplo n.º 14
0
 def test_getMQService(self):
   self.assertEqual(module.getMQService("bblabl.ch::Topics::MyTopic"), "bblabl.ch")
   self.assertEqual(module.getMQService("bblabl.ch::Queues::MyQueue"), "bblabl.ch")
Ejemplo n.º 15
0
 def test_putOneGetOneMessage( self ):
   myCallback = module.generateDefaultCallback()
   myCallback("", "test message")
   self.assertEqual(myCallback.get(), "test message")
Ejemplo n.º 16
0
 def test_EmptyMessage( self ):
   myCallback = module.generateDefaultCallback()
   self.assertRaises(Queue.Empty, myCallback.get)
Ejemplo n.º 17
0
 def test_getDestinationName(self):
   self.assertEqual(module.getDestinationName("bblabl.ch::Topics::MyTopic"), "MyTopic")
   self.assertEqual(module.getDestinationName("bblabl.ch::Queues::MyQueue"), "MyQueue")
Ejemplo n.º 18
0
 def test_getDestinationAddress(self):
   self.assertEqual(module.getDestinationAddress("bblabl.ch::Topics::MyTopic"), "/topic/MyTopic")
   self.assertEqual(module.getDestinationAddress("bblabl.ch::Queues::MyQueue"), "/queue/MyQueue")
Ejemplo n.º 19
0
 def test_putOneGetOneMessage(self):
     myCallback = module.generateDefaultCallback()
     myCallback("", "test message")
     self.assertEqual(myCallback.get(), "test message")
Ejemplo n.º 20
0
 def test_getMQService(self):
     self.assertEqual(module.getMQService("bblabl.ch::Topics::MyTopic"),
                      "bblabl.ch")
     self.assertEqual(module.getMQService("bblabl.ch::Queues::MyQueue"),
                      "bblabl.ch")
Ejemplo n.º 21
0
 def test_getDestinationName(self):
     self.assertEqual(
         module.getDestinationName("bblabl.ch::Topics::MyTopic"), "MyTopic")
     self.assertEqual(
         module.getDestinationName("bblabl.ch::Queues::MyQueue"), "MyQueue")