Пример #1
0
	def testValidateVersionProperty(self):
		print "testValidateVersionProperty"
		pf = PropertiesFile(self.simplePropertiesFileName)
		# default key property.file.version
		version = pf.validateVersionProperty()
		self.assertEqual(version, 1)
		# default key wrong value
		version = pf.validateVersionProperty(propertyValue="false-version")
		self.assertEqual(version, 0)
		# non-existent key
		version = pf.validateVersionProperty(propertyKey="non.key")
		self.assertEqual(version, 0)
		# default key correct version
		version = pf.validateVersionProperty(propertyValue="ENV_VERSION")
		self.assertEqual(version, 1)
		# non-existent key value exists
		version = pf.validateVersionProperty(propertyKey="non.key", propertyValue="ENV_VERSION")
		self.assertEqual(version, 0)
		# specified key value correct
		version = pf.validateVersionProperty(propertyKey="property.file.version", propertyValue="ENV_VERSION")
		self.assertEqual(version, 1)
Пример #2
0
import os, sys
from propertiesutils import XmlProperties
from propertiesutils import PropertiesFile
xmlProps = XmlProperties("tmp/ant-properties.xml")
antPropertiesFile = "tmp/ant-properties.properties"
xmlProps.transformProperties(antPropertiesFile)
apf = PropertiesFile(antPropertiesFile)
# add some validation of existence of config file
configFilePath = apf.get("config.file.path")
if os.path.isfile(configFilePath):
	epf = PropertiesFile(configFilePath)
else:
	print "[ERROR] configuration properties file " + configFilePath + " does not exist"
	sys.exit("missing environment configuration file")
# add some validation of version
envVersion = apf.get("config.file.version")
if epf.validateVersionProperty(propertyValue=envVersion):
	version = epf.get("property.file.version")
	config_file_name = apf.get("config.file.name")
	tpf = epf.createTokenisedProperties("{@", "@}", "configmaps/" + config_file_name + version + ".properties")
else:
	print "[ERROR] invalid configuration file version"
	sys.exit("invalid configuration file")