def test_filter_setup_error
@properties['documents'] = [
{ 'document' => 'Page',
'arguments' => [
"Hello world.\n",
'text/html'
],
'mount_path' => '/',
'mount_mask' => nil,
'virtual_host' => nil
},
{ 'document' => 'Page',
'arguments' => [
"Hello virtual world.\n",
'text/html'
],
'mount_path' => '/',
'mount_mask' => nil,
'virtual_host' => 'baz'
}
]
page = Object.new
class << page
include RUNIT::Assert
def doc_name
'Page'
end
def doc_args
[ [ 'content', :text, nil ],
[ 'content-type', :string, 'text/html' ]
]
end
def new(content, content_type)
assert(content == "Hello world.\n" ||
content == "Hello virtual world.\n")
assert_equal('text/html', content_type)
:dummy_page_document
end
end
@factory.add_document(page)
error = Object.new
def error.filter_name
'TestError'
end
def error.filter_args
[]
end
def error.new
raise 'exception on creating a filter.'
end
@factory.add_filter(error)
@properties['filters'] = [
{ 'filter' => 'TestError',
'arguments' => [],
'attach_path' => '/error',
'attach_mask' => nil,
'virtual_host' => 'foo'
}
]
build_control
@control.server_setup(self)
assert_equal(1, @attach_call)
assert_equal(0, @virtual_attach_call)
assert_equal(1, @control.filter_errors.length)
assert_equal('TestError', @control.filter_errors[0][:filter])
assert_equal([], @control.filter_errors[0][:arguments])
assert_equal('/error', @control.filter_errors[0][:attach_path])
assert_nil(@control.filter_errors[0][:attach_mask])
assert_equal('foo', @control.filter_errors[0][:virtual_host])
assert_instance_of(RuntimeError, @control.filter_errors[0][:exception])
assert_equal('exception on creating a filter.', @control.filter_errors[0][:exception].message)
end