common.py revision 8cd42334ba917edcd5f144b2c6b4864b7555c7ce
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at
# trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the fields enclosed
# information:
# Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007-2009 Sun Microsystems, Inc.
# Portions Copyright 2011 ForgeRock AS.
__version__ = "$Revision$"
# $Source$
# public symbols
__all__ = [ "format_testcase",
"directory_server_information",
"test_time",
"report_generation",
"compare_file",
"is_windows_platform",
"create_property_table",
"compare_property_table",
"exception_thrown",
"directory_server",
"test_env",
"staf_service",
"get_test_name",
"parse_stax_result",
"dn2list",
"list2dn",
"dn2rfcmailaddr",
"java_properties",
"xmldoc_service" ,
"xml_create_report" ,
"group_to_run" ,
"get_last_attr_from_entry" ,
"list_matches" ,
"count_attr" ,
"host_is_localhost" ,
"md5_hash" ,
"value_not_string"
]
class format_testcase:
'Format the Test name objects'
class directory_server_information:
'Container for Information about Directory Servers'
self.VersionList=[]
self.SystemList=[]
self.ServerDict={}
self.SystemDict={}
class test_time:
'Simple time related manipulation objects'
class basic_utils:
'Some simple basic utilities'
class report_generation:
'Test Report Generation'
try:
finally:
class exception_thrown:
'User defined exceptions handlers'
class compare_file:
'Compare two files'
try:
ret_str = ""
return ret_str
finally:
def is_windows_platform(host):
if winNdx != -1:
else:
'Create a table from an output'
table = {}
try:
except IndexError:
value = ''
return table
'Compare two tables'
import re
result = ''
else:
return result
class directory_server:
'Container to hold DS instance objects'
return location
return name
return port
return adminport
return dn
return pswd
return sfx
return be
class staf_service:
'Container to hold staf service instance objects'
try:
except STAFException, e:
pass
def get_library(self):
def get_executable(self):
return self.executable
def get_options(self):
def get_params(self):
class test_env:
'Container to hold test environment instance objects'
class staf:
'Container to hold staf objects'
__cmd = 'Version'
def get_version(self):
class stax(staf_service):
'Container to hold stax service objects'
__cmd = 'Version'
def get_version(self):
class event(staf_service):
'Container to hold event service objects'
__cmd = 'Version'
def get_version(self):
class eventmanager(staf_service):
'Container to hold event manager service objects'
__cmd = 'Version'
def get_version(self):
class email(staf_service):
'Container to hold email service objects'
__cmd = 'Version'
def get_version(self):
def get_recipients(self):
return self.recipients
def get_server(self):
class http(staf_service):
'Container to hold http service objects'
def get_version(self):
class dsml(staf_service):
'Container to hold dsml service objects'
def get_version(self):
class source:
'Container to hold source data instance objects'
def get_directory(self):
def get_common(self):
class logs:
'Container to hold test log instance objects'
def get_directory(self):
def get_reports(self):
class data:
'Container to hold local and remote test data instance objects'
def get_directory(self):
def get_testdata(self):
def get_reldatadir(self):
def get_reljavadir(self):
def get_test_name(name):
i=2
__name=''
i=i+1
def parse_stax_result(result):
try:
except AttributeError:
_functionString='Unable to parse result.'
else:
_functionString='Unable to parse result.'
return _functionString
return __list
def dn2rfcmailaddr(dn):
__addr=[]
'Update java.properties file'
import fileinput
import string
import sys
try:
for item in optionList:
else:
return 0
except:
return 1
class xmldoc_service:
def createBlankDocument(self):
try:
return builderFactory.newDocumentBuilder()
except:
try:
except:
try:
except:
try:
except:
try:
except:
i=0
i += 1
# Identification
# Test Results
class group_to_run:
attrVal=''
for changeAttr in changeEntry:
#print changeAttr
#print 'get_last_attr_from_entry: %s' % changeAttr
else:
print 'get_last_attr_from_entry: %s' % lastAttr
return lastAttr
def list_matches(mylist):
mycomp = 'True'
itemnum = 0
if not item:
# TODO: list item is empty do WARNING or ERROR
print "list_matches: WARNING: list item %s is empty." % itemnum
mycomp = 'False'
itemnum += 1
return mycomp
def count_attr(result):
attrnum = 0
if result != None:
print "Hit: attr (%s)" % attr
attrnum += 1
return attrnum
def host_is_localhost(hostname):
from socket import gethostbyname
return 1
else:
return 0
from socket import gethostbyname
return 1
else:
return 0
def md5_hash():
try:
import hashlib
except ImportError:
import md5
return m
def value_not_string(value):
try:
except ImportError:
# Unicode is NOT supported in this version of Jython
print "WARNING: Jython version does not support Unicode."
return 1
else:
return 0
# Unicode is supported in this version of Jython
return 1
else:
return 0