test/test_jetty.rb in jetty-6.1.18.1 vs test/test_jetty.rb in jetty-6.1.19.1
- old
+ new
@@ -24,11 +24,11 @@
# Disable jetty logging if slf4j is available
begin
gem( 'slf4j', '~> 1.5' )
require 'slf4j'
- require 'slf4j/nop'
+ require 'slf4j/nop'
rescue Gem::LoadError
end
require 'jetty'
require 'jetty/test-servlets'
@@ -66,11 +66,10 @@
test_text = Net::HTTP.get( 'localhost', '/test.txt', port )
assert_equal( File.read( File.join( TEST_DIR, 'test.txt' ) ), test_text )
server.stop
end
-
import 'org.mortbay.jetty.handler.AbstractHandler'
class TestHandler < AbstractHandler
TEST_TEXT = 'test handler text'
def handle( target, request, response, dispatch )
@@ -78,25 +77,23 @@
response.writer.write( TEST_TEXT )
request.handled = true
end
end
-
def test_custom_handler
factory = default_factory
def factory.create_pre_handlers
super << TestHandler.new
end
server = factory.create
server.start
port = server.connectors[0].local_port
- assert_equal( TestHandler::TEST_TEXT,
+ assert_equal( TestHandler::TEST_TEXT,
Net::HTTP.get( 'localhost', '/whatever', port ) )
server.stop
end
-
import 'javax.servlet.http.HttpServlet'
class TestServlet < HttpServlet
def initialize( text )
super()
@text = text
@@ -108,29 +105,29 @@
end
end
def test_servlet_handler
factory = default_factory
- factory.set_context_servlets( '/some',
+ factory.set_context_servlets( '/some',
{ '/test' => TestServlet.new( 'resp-test' ),
'/other' => TestServlet.new( 'resp-other' ) } )
- factory.set_context_servlets( '/',
+ factory.set_context_servlets( '/',
{ '/one' => TestServlet.new( 'resp-one' ),
'/snoop' => Jetty::TestServlets::SnoopServlet.new } )
server = factory.create
server.start
port = server.connectors[0].local_port
assert_equal( 'resp-test',
Net::HTTP.get( 'localhost', '/some/test', port ) )
- assert_equal( 'resp-other',
+ assert_equal( 'resp-other',
Net::HTTP.get( 'localhost', '/some/other', port ) )
assert_equal( 'resp-one',
Net::HTTP.get( 'localhost', '/one', port ) )
-
+
response = Net::HTTP.get_response( 'localhost', '/', port )
assert( response.is_a?( Net::HTTPNotFound ) )
response = Net::HTTP.get_response( 'localhost', '/snoop', port )
assert( response.is_a?( Net::HTTPSuccess ) )
@@ -138,10 +135,10 @@
server.stop
end
def test_webapp
factory = default_factory
- index_html = File.read(
+ index_html = File.read(
File.join( Jetty::TestServlets::WEBAPP_TEST_EXPANDED, 'index.html' ) )
factory.webapp_contexts[ '/test' ] = Jetty::TestServlets::WEBAPP_TEST_WAR
factory.webapp_contexts[ '/expanded' ] = Jetty::TestServlets::WEBAPP_TEST_EXPANDED