spec/liberty_buildpack/services/compose_mongo_spec.rb
def check_server_xml_update(root, sm, contents)
        server_xml_doc = REXML::Document.new(contents.join)
        server_xml = File.join(root, 'server.xml')
        sm.update_configuration(server_xml_doc, false, root)

        File.open(server_xml, 'w') { |file| server_xml_doc.write(file) }

        # check if dataSource properties and library were updated. Other elements should not be updated.
        expected_config = []
        expected_config << '<feature>jsp-2.2</feature>'
        expected_config << '<feature>ssl-1.0</feature>'
        expected_config << '<feature>mongodb-2.0</feature>'
        # hostNames and ports are being replaced directly without using the cloud runtime_vars when the mongo.rb code is changed to use the runtime_vars the test must be updated to use the get_hosts and get_ports
        t1 = "<mongo hostNames='myHost.com' id='#{get_mongo_id}' libraryRef='myLibrary' password='#{get_password}' ports='5432' sslEnabled='true' sslRef='composeMongoSSLConfig' user='#{get_user}'/>"
        expected_config << t1
        expected_config << "<mongoDB databaseName='#{get_db}' id='#{get_mongodb_id}' jndiName='myJndi' mongoRef='#{get_mongo_id}'/>"
        expected_config << "<library id='myLibrary'><fileset dir='lib' id='lib-id'/><fileset dir='#{get_lib_dir}'/></library>"
        expected_config << "<keyStore id='composeMongoKeyStore' location='#{get_keystore_location}' password='#{get_keystore_password}' type='jks'/>"
        expected_config << "<ssl id='composeMongoSSLConfig' keyStoreRef='composeMongoKeyStore'/>"

        validate_xml(server_xml, expected_config)
      end
#----------------------------------------------------------
# Helper methods to return constants used in checking server.xml contents
#----------------------------------------------------------
Helper methods to return constants used in checking server.xml contents
Helper methods to return constants used in checking server . xml contents
def check_server_xml_update(root, sm, contents)
        server_xml_doc = REXML::Document.new(contents.join)
        server_xml = File.join(root, 'server.xml')
        sm.update_configuration(server_xml_doc, false, root)
        File.open(server_xml, 'w') { |file| server_xml_doc.write(file) }
        expected_config = []
        expected_config << '<feature>jsp-2.2</feature>'
        expected_config << '<feature>ssl-1.0</feature>'
        expected_config << '<feature>mongodb-2.0</feature>'
        t1 = "<mongo hostNames='myHost.com' id='#{get_mongo_id}' libraryRef='myLibrary' password='#{get_password}' ports='5432' sslEnabled='true' sslRef='composeMongoSSLConfig' user='#{get_user}'/>"
        expected_config << t1
        expected_config << "<mongoDB databaseName='#{get_db}' id='#{get_mongodb_id}' jndiName='myJndi' mongoRef='#{get_mongo_id}'/>"
        expected_config << "<library id='myLibrary'><fileset dir='lib' id='lib-id'/><fileset dir='#{get_lib_dir}'/></library>"
        expected_config << "<keyStore id='composeMongoKeyStore' location='#{get_keystore_location}' password='#{get_keystore_password}' type='jks'/>"
        expected_config << "<ssl id='composeMongoSSLConfig' keyStoreRef='composeMongoKeyStore'/>"
        validate_xml(server_xml, expected_config)
      end
def check_server_xml_update ( root , sm , contents ) server_xml_doc = REXML :: Document . new ( contents . join ) server_xml = File . join ( root , 'server.xml' ) sm . update_configuration ( server_xml_doc , false , root ) File . open ( server_xml , 'w' ) { | file | server_xml_doc . write ( file ) } expected_config = [ ] expected_config << '<feature>jsp-2.2</feature>' expected_config << '<feature>ssl-1.0</feature>' expected_config << '<feature>mongodb-2.0</feature>' t1 = "<mongo hostNames='myHost.com' id='#{get_mongo_id}' libraryRef='myLibrary' password='#{get_password}' ports='5432' sslEnabled='true' sslRef='composeMongoSSLConfig' user='#{get_user}'/>" expected_config << t1 expected_config << "<mongoDB databaseName='#{get_db}' id='#{get_mongodb_id}' jndiName='myJndi' mongoRef='#{get_mongo_id}'/>" expected_config << "<library id='myLibrary'><fileset dir='lib' id='lib-id'/><fileset dir='#{get_lib_dir}'/></library>" expected_config << "<keyStore id='composeMongoKeyStore' location='#{get_keystore_location}' password='#{get_keystore_password}' type='jks'/>" expected_config << "<ssl id='composeMongoSSLConfig' keyStoreRef='composeMongoKeyStore'/>" validate_xml ( server_xml , expected_config ) end
Helper methods to return constants used in checking server.xml contents
Helper methods to return constants used in checking server . xml contents
# check if dataSource properties and library were updated. Other elements should not be updated. # hostNames and ports are being replaced directly without using the cloud runtime_vars when the mongo.rb code is changed to use the runtime_vars the test must be updated to use the get_hosts and get_ports
root
sm
contents