How to use hibernate method in lisa

Best Python code snippet using lisa_python

conf.py

Source:conf.py Github

copy

Full Screen

1from lxml import etree2from optparse import OptionParser3CFG_FILE = "src/main/resources/hibernate.cfg.xml"4optparser = OptionParser()5optparser.add_option("-q", "--query-cache",6 action="store",7 dest="querycache",8 help="hibernate.cache.use_query_cache",9 type="choice",10 choices=["true", "false"],11 metavar="true|false",12 )13optparser.add_option("-m", "--minimal-puts",14 action="store",15 dest="minimalputs",16 help="hibernate.cache.use_minimal_puts",17 type="choice",18 choices=["true", "false"],19 metavar="true|false",20 )21optparser.add_option("-f", "--factory-class",22 action="store",23 type="choice",24 dest="factoryclass",25 help="hibernate.cache.region.factory_class",26 metavar="local|dist",27 choices=["local", "dist"]28 )29optparser.add_option("-n", "--native-client",30 action="store",31 dest="nativeclient",32 help="hibernate.cache.hazelcast.use_native_client",33 type="choice",34 choices=["true", "false"],35 metavar="true|false",36 )37optparser.add_option("-i", "--hosts",38 action="store",39 type="string",40 dest="hosts",41 help="hibernate.cache.hazelcast.native_client_hosts",42 metavar="IP(:PORT)",43 )44optparser.add_option("-g", "--group",45 action="store",46 type="string",47 dest="group",48 help="hibernate.cache.hazelcast.native_client_group",49 )50optparser.add_option("-p", "--password",51 action="store",52 type="string",53 dest="password",54 help="hibernate.cache.hazelcast.native_client_password",55 )56(options, args) = optparser.parse_args()57xmlparser = etree.XMLParser(remove_comments=False, encoding="UTF-8")58tree = etree.parse(CFG_FILE, parser=xmlparser)59root = tree.getroot()60factorynode = root.find("session-factory")61for child in factorynode:62 if not child.attrib or not child.attrib.get("name"):63 pass64 elif child.attrib["name"] == "hibernate.cache.use_query_cache":65 querycache = child66 elif child.attrib["name"] == "hibernate.cache.use_minimal_puts":67 minimalputs = child68 elif child.attrib["name"] == "hibernate.cache.region.factory_class":69 factoryclass = child70 elif child.attrib["name"] == "hibernate.cache.hazelcast.use_native_client":71 nativeclient = child72 elif child.attrib["name"] == "hibernate.cache.hazelcast.native_client_hosts":73 hosts = child74 elif child.attrib["name"] == "hibernate.cache.hazelcast.native_client_group":75 group = child76 elif child.attrib["name"] == "hibernate.cache.hazelcast.native_client_password":77 password = child78if options.querycache:79 querycache.text = options.querycache80if options.minimalputs:81 minimalputs.text = options.minimalputs82if options.factoryclass:83 if options.factoryclass == "dist":84 factoryclass.text = "com.hazelcast.hibernate.HazelcastCacheRegionFactory"85 else:86 factoryclass.text = "com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory"87if options.nativeclient:88 nativeclient.text = options.nativeclient89 if options.nativeclient == "true":90 if options.hosts and options.group and options.password:91 hosts.text = options.hosts92 group.text = options.group93 password.text = options.password94 else:95 print "You haven't stated hosts, group and password"96 exit(1)97if options.hosts:98 hosts.text = options.hosts99if options.group:100 group.text = options.group101if options.password:102 password.text = options.password...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

1import os2import sys3import jynx45__all__ = ["buildSessionFactory", "Serializable", "hn_session", "hn_transact", "bean_property"]67############## logging? ############################################89LOGGING = False1011sys.classpath.append(os.path.join(jynx.orgpath, "slf4j", "slf4j-api-1.5.8.jar"))1213if LOGGING:14 sys.classpath.append(os.path.join(jynx.orgpath, "slf4j", "slf4j-simple-1.5.8.jar"))15else:16 sys.classpath.append(os.path.join(jynx.orgpath, "slf4j", "slf4j-nop-1.5.8.jar"))1718############## define system dependent root paths ##################1920HIBERNATE_PATH = r"c:\lang\Java\hibernate-3.3.2"2122assert os.path.isdir(HIBERNATE_PATH), "Set HIBERNATE_PATH to the root directory of your Hibernate package"2324HIBERNATE_ANNO_PATH = r"c:\lang\Java\hibernate-3.3.2"2526assert os.path.isdir(HIBERNATE_ANNO_PATH), "Set HIBERNATE_ANNO_PATH to the root directory of your Hibernate Annotations package"2728############## define hibernate.cfg.xml ##########################2930hibernate_cfg_xml = os.path.join(jynx.jynxpath, "lib", "hibernate", "hibernate.cfg.xml")3132############## Database Settings ############################3334DB_PATH = r"c:\lang\Java\derby\lib"3536assert os.path.isdir(DB_PATH), "Incorrect path to database packages. Set your own path."3738############## set database class paths ################3940sys.classpath.append(os.path.join(DB_PATH, "derby.jar"))41sys.classpath.append(os.path.join(DB_PATH, "derbytools.jar"))4243############## set hibernate class paths ##########################4445sys.classpath.append(os.path.join(HIBERNATE_PATH, "hibernate3.jar"))46sys.classpath.append(os.path.join(HIBERNATE_PATH, "hibernate-testing.jar"))47sys.classpath.append(os.path.join(HIBERNATE_ANNO_PATH, "hibernate-annotations.jar"))4849sys.classpath.append(os.path.join(HIBERNATE_ANNO_PATH, "lib", "ejb3-persistence.jar"))50sys.classpath.append(os.path.join(HIBERNATE_ANNO_PATH, "lib", "hibernate-commons-annotations.jar"))51sys.classpath.append(os.path.join(HIBERNATE_PATH, "lib", "required", "commons-collections-3.1.jar"))52sys.classpath.append(os.path.join(HIBERNATE_PATH, "lib", "required", "jta-1.1.jar"))53sys.classpath.append(os.path.join(HIBERNATE_PATH, "lib", "required", "antlr-2.7.6.jar"))54sys.classpath.append(os.path.join(HIBERNATE_PATH, "lib", "dom4j.jar"))55sys.classpath.append(os.path.join(HIBERNATE_PATH, "lib", "bytecode", "javassist", "javassist-3.9.0.GA.jar"))5657 ...

Full Screen

Full Screen

test_rhn_hibernate_conf.py

Source:test_rhn_hibernate_conf.py Github

copy

Full Screen

1from insights.tests import context_wrap2from insights.parsers.rhn_hibernate_conf import RHNHibernateConf3conf_content = """4############################################################################5## HIBERNATE CONFIGURATION6##7## This is not the only way to configure hibernate. You can8## create a hibernate.cfg.xml file or you can create your own9## custom file which you parse and create a new Configuration object.10##11## We're using the hibernate.properties file because it's simple.12############################################################################13hibernate.dialect=org.hibernate.dialect.Oracle10gDialect14hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver15hibernate.connection.driver_proto=16hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider17hibernate.use_outer_join=true18hibernate.jdbc.batch_size=019#hibernate.show_sql=true20hibernate.c3p0.min_size=521hibernate.c3p0.max_size=2022hibernate.c3p0.timeout=30023#24# This should always be 0.25#26hibernate.c3p0.max_statements=027# test period value in seconds28hibernate.c3p0.idle_test_period=30029hibernate.c3p0.testConnectionOnCheckout=true30hibernate.c3p0.connectionCustomizerClassName=com.redhat.rhn.common.db.RhnConnectionCustomizer31hibernate.c3p0.preferredTestQuery=select 'c3p0 ping' from dual32hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider33hibernate.cache.use_query_cache=true34hibernate.bytecode.use_reflection_optimizer=false35hibernate.jdbc.batch_size=036""".strip()37def test_rhn_hibernate_conf():38 result = RHNHibernateConf(context_wrap(conf_content))39 assert result.get("hibernate.c3p0.max_statements") == "0"40 assert result.get("hibernate.connection.driver_proto") == ""...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful