def generate_test(write_to_file=false, dir = nil)
@str = "$:.unshift File.join(ENV['SIPPER_HOME'],'sipper_test')\n"
@str << "require \'driven_sip_test_case\'\n\n"
@str << sprintf("class %s < DrivenSipTestCase \n\n", @gen_class_name)
@str << " def self.description\n"
@str << " \"Callflow is #{@flow_str}\" \n"
@str << " end\n\n"
@str << " def setup\n"
@str << " super\n"
@str << " SipperConfigurator[:SessionRecord]='msg-info'\n"
@str << " SipperConfigurator[:WaitSecondsForTestCompletion] = 180\n"
controller_code = Generators::GenController.new(@gen_class_name+"Controller", @flow_str, "SIP::SipTestDriverController").generate_controller(false)
@str << " str = <<-EOF\n"
@str << controller_code
@str << " EOF\n"
@str << " define_controller_from(str)\n"
@str << " set_controller('#{@gen_class_name}"+"Controller"+"')\n"
@str << " end\n\n"
@str << " def test_case_1\n"
@str << " self.expected_flow = "
@str << SipperUtil.print_arr(@flow_msg_only) + "\n"
@str << " start_controller\n"
@str << " verify_call_flow(:" + @direction +")\n"
@str << " end\n"
@str << "end\n"
if write_to_file
if dir
f = File.join(dir, @gen_file_name)
else
f = @gen_file_name
end
cfile = File.new(f, "w")
cfile << @str
cfile.close
end
@str
end