Methods
D
E
I
P
S
T
X
Instance Public methods
test_ar_struct_return()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 379
def test_ar_struct_return
  [@direct_controller, @delegated_controller].each do |controller|
    result = do_method_call(controller, 'StructReturn')
    assert(result[0].is_a?(DispatcherTest::Node))
    assert(result[1].is_a?(DispatcherTest::Node))
    assert_equal('node1', result[0].name)
    assert_equal('node2', result[1].name)
  end
end
test_casting()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 389
def test_casting
  assert_equal 70, do_method_call(@direct_controller, 'Add', "50", "20")
  assert_equal false, @direct_controller.struct_pass_value
  person = DispatcherTest::Person.new(:id => 1, :name => 'test') 
  result = do_method_call(@direct_controller, 'StructPass', person)
  assert(nil == result || true == result)
  assert_equal person, @direct_controller.struct_pass_value
  assert !person.equal?(@direct_controller.struct_pass_value)
  result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test'})
  case
  when soap?
    assert_equal(person, @direct_controller.struct_pass_value)
    assert !person.equal?(@direct_controller.struct_pass_value)
  when xmlrpc?
    assert_equal(person, @direct_controller.struct_pass_value)
    assert !person.equal?(@direct_controller.struct_pass_value)
  end
  assert_equal person, do_method_call(@direct_controller, 'HashStructReturn')[0]
  result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test', 'nonexistent_attribute' => 'value'})
  case
  when soap?
    assert_equal(person, @direct_controller.struct_pass_value)
    assert !person.equal?(@direct_controller.struct_pass_value)
  when xmlrpc?
    assert_equal(person, @direct_controller.struct_pass_value)
    assert !person.equal?(@direct_controller.struct_pass_value)
  end
end
test_delegated_dispatching()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 334
def test_delegated_dispatching
  assert_equal(130, do_method_call(@delegated_controller, 'Add', 50, 80))
  service = @delegated_controller.web_service_object(:test_service)
  assert_equal(130, service.added)
  @delegated_controller.web_service_exception_reporting = true
  assert(service.intercepted.nil?)
  result = do_method_call(@delegated_controller, 'Interceptee')
  assert(service.intercepted.nil?)
  assert(is_exception?(result))
  assert_match(%rpermission denied/, exception_message(result))
  result = do_method_call(@delegated_controller, 'NonExistentMethod')
  assert(is_exception?(result))
  assert_match(%rNonExistentMethod/, exception_message(result))
  assert(service.void_called == false)
  assert(do_method_call(@delegated_controller, 'Void', 3, 4, 5).nil?)
  assert(service.void_called == [])
end
test_direct_dispatching()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 295
def test_direct_dispatching
  assert_equal(70, do_method_call(@direct_controller, 'Add', 20, 50))
  assert_equal(70, @direct_controller.added)
  assert_equal(50, do_method_call(@direct_controller, 'Add2', 25, 25))
  assert_equal(50, @direct_controller.added2)
  assert(@direct_controller.void_called == false)
  assert(do_method_call(@direct_controller, 'Void', 3, 4, 5).nil?)
  assert(@direct_controller.void_called == [])
  result = do_method_call(@direct_controller, 'BaseStructReturn')
  assert(result[0].is_a?(DispatcherTest::Person))
  assert(result[1].is_a?(DispatcherTest::Person))
  assert_equal("cafe", do_method_call(@direct_controller, 'Hex', "\xca\xfe"))
  assert_equal("\xca\xfe", do_method_call(@direct_controller, 'Unhex', "cafe"))
  time = Time.gm(1998, "Feb", 02, 15, 12, 01)
  assert_equal(time, do_method_call(@direct_controller, 'Time', time))
end
test_direct_entrypoint()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 312
def test_direct_entrypoint
  assert(@direct_controller.respond_to?(:api))
end
test_direct_filtering()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 321
def test_direct_filtering
  assert_equal(false, @direct_controller.before_filter_called)
  assert_equal(false, @direct_controller.before_filter_target_called)
  do_method_call(@direct_controller, 'BeforeFiltered')
  assert_equal(true, @direct_controller.before_filter_called)
  assert_equal(false, @direct_controller.before_filter_target_called)
  assert_equal(false, @direct_controller.after_filter_called)
  assert_equal(false, @direct_controller.after_filter_target_called)
  assert_equal([5, 6, 7], do_method_call(@direct_controller, 'AfterFiltered'))
  assert_equal(true, @direct_controller.after_filter_called)
  assert_equal(true, @direct_controller.after_filter_target_called)
end
test_exception_marshaling()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 369
def test_exception_marshaling
  @direct_controller.web_service_exception_reporting = true
  result = do_method_call(@direct_controller, 'Thrower')
  assert(is_exception?(result))
  assert_equal("Hi, I'm an exception", exception_message(result))
  @direct_controller.web_service_exception_reporting = false
  result = do_method_call(@direct_controller, 'Thrower')
  assert(exception_message(result) != "Hi, I'm an exception")
end
test_garbage_request()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 352
def test_garbage_request
  [@direct_controller, @delegated_controller].each do |controller|
    controller.class.web_service_exception_reporting = true
    send_garbage_request = lambda do
      service_name = service_name(controller)
      request = protocol.encode_action_pack_request(service_name, 'broken, method, name!', 'broken request body', :request_class => ActionController::TestRequest)
      response = ActionController::TestResponse.new
      controller.process(request, response)
      # puts response.body
      assert(response.headers['Status'] =~ %r^500/)
    end
    send_garbage_request.call
    controller.class.web_service_exception_reporting = false
    send_garbage_request.call
  end
end
test_logging()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 418
def test_logging
  buf = ""
  ActionController::Base.logger = Logger.new(StringIO.new(buf))
  test_casting
  test_garbage_request
  test_exception_marshaling
  ActionController::Base.logger = nil
  assert_match %rWeb Service Response/, buf
  assert_match %rWeb Service Request/, buf
end
test_virtual_dispatching()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 316
def test_virtual_dispatching
  assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualOne'))
  assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualTwo'))
end
Instance Protected methods
do_method_call(container, public_method_name, *params)
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 454
def do_method_call(container, public_method_name, *params)
  request_env = {}
  mode = container.web_service_dispatching_mode
  case mode
  when :direct
    service_name = service_name(container)
    api = container.class.web_service_api
    method = api.public_api_method_instance(public_method_name)
  when :delegated
    service_name = service_name(container)
    api = container.web_service_object(service_name).class.web_service_api
    method = api.public_api_method_instance(public_method_name)
  when :layered
    service_name = nil
    real_method_name = nil
    if public_method_name =~ %r^([^\.]+)\.(.*)$/
      service_name = $1
      real_method_name = $2
    end
    if soap?
      public_method_name = real_method_name
      request_env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{real_method_name}"
    end
    api = container.web_service_object(service_name.to_sym).class.web_service_api rescue nil
    method = api.public_api_method_instance(real_method_name) rescue nil
    service_name = self.service_name(container)
  end
  protocol.register_api(api)
  virtual = false
  unless method
    virtual = true
    method ||= ActionWebService::API::Method.new(public_method_name.underscore.to_sym, public_method_name, nil, nil)
  end
  body = protocol.encode_request(public_method_name, params.dup, method.expects)
  # puts body
  ap_request = protocol.encode_action_pack_request(service_name, public_method_name, body, :request_class => ActionController::TestRequest)
  ap_request.env.update(request_env)
  ap_response = ActionController::TestResponse.new
  container.process(ap_request, ap_response)
  # puts ap_response.body
  @response_body = ap_response.body
  public_method_name, return_value = protocol.decode_response(ap_response.body)
  unless is_exception?(return_value) || virtual
    return_value = method.cast_returns(return_value)
  end
  if soap?
    # http://dev.rubyonrails.com/changeset/920
    assert_match(%rResponse$/, public_method_name) unless public_method_name == "fault"
  end
  return_value
end
exception_message(obj)
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 434
def exception_message(obj)
  raise NotImplementedError
end
is_exception?(obj)
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 438
def is_exception?(obj)
  raise NotImplementedError
end
protocol()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 442
def protocol
  @protocol
end
service_name(container)
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 430
def service_name(container)
  raise NotImplementedError
end
soap?()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 446
def soap?
  protocol.is_a? ActionWebService::Protocol::Soap::SoapProtocol
end
xmlrpc?()
# File rails/actionwebservice/test/abstract_dispatcher.rb, line 450
def xmlrpc?
  protocol.is_a? ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
end