예제 #1
0
 def test_several_events_config_file(self):
     config = helpers.ConfigElement()
     config.java_home = "invalid"
     config.proactive_home = "invalid"
   
     event = helpers.EventElement()
     event.start    = helpers.EventStartElement("Monday", '0', "0", "0")
     event.duration = helpers.EventDurationElement(0, 0, 0, 1)
     events = [event, event, event, event]
     
     connection = helpers.CustomConnectionElement()
     connection.java_starter_class = "invalid"
     
     self.file = helpers.write_config_file(config, events, connection)
     _check_validity_with_xmllint(self.file)
     palinagent.daemon.main._parse_config_file(self.file)
예제 #2
0
 def test_wrong_namespace_config_file(self):
     (config, events, connection) = _get_simplest_config()
     self.file = helpers.write_config_file(config, events, connection)
         
     # Change the namespace
     updated_fname = tempfile.mktemp()
     updated = open(updated_fname, 'w')
     orig = open(self.file, 'r')
     for line in orig.readlines():
         updated.write(line.replace(palinagent.daemon.main.xmlns, "invalid:name:space"))
     orig.close()
     updated.close()
     os.remove(self.file)
     self.file = updated_fname
     
     self.assertRaises(AgentConfigFileError, palinagent.daemon.main._parse_config_file, self.file)
예제 #3
0
 def test_malformed_config_file(self):
     (config, events, connection) = _get_simplest_config()
     self.file = helpers.write_config_file(config, events, connection)
         
     # Randomly removed some lines
     updated_fname = tempfile.mktemp()
     updated = open(updated_fname, 'w')
     orig = open(self.file, 'r')
     for line in orig.readlines():
         if random.randint(0, 10) < 9:
             updated.write(line.replace(palinagent.daemon.main.xmlns, "invalid:name:space"))
     orig.close()
     updated.close()
     os.remove(self.file)
     self.file = updated_fname
     
     self.assertRaises(AgentConfigFileError, palinagent.daemon.main._parse_config_file, self.file)
예제 #4
0
 def test_too_many_enabled(self):
     ''' Checks that an exception is thrown when several connections are enabled '''
     (config, events, connection) = _get_simplest_config()
     self.file = helpers.write_config_file(config, events, connection)
         
     # Randomly removed some lines
     updated_fname = tempfile.mktemp()
     updated = open(updated_fname, 'w')
     orig = open(self.file, 'r')
     for line in orig.readlines():
         updated.write(line.replace('</connections>' , '<localBind enabled="true"/></connections>'))
     orig.close()
     updated.close()
     os.remove(self.file)
     self.file = updated_fname
     
     tree = palinagent.daemon.main._parse_config_file(self.file)
     self.assertRaises(palinagent.daemon.errors.AgentConfigFileError, palinagent.daemon.action.parse, tree)
예제 #5
0
 def test_simple_config_file(self):
     (config, events, connection) = _get_simplest_config()
     self.file = helpers.write_config_file(config, events, connection)
     _check_validity_with_xmllint(self.file)
     palinagent.daemon.main._parse_config_file(self.file)