iudex-http-test 1.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/History.rdoc +2 -0
- data/Manifest.txt +16 -0
- data/README.rdoc +25 -0
- data/Rakefile +36 -0
- data/bin/iudex-http-test-fg +50 -0
- data/lib/iudex-http-test.rb +19 -0
- data/lib/iudex-http-test/base.rb +23 -0
- data/lib/iudex-http-test/broken_server.rb +50 -0
- data/lib/iudex-http-test/helper.rb +78 -0
- data/lib/iudex-http-test/server.rb +40 -0
- data/lib/iudex-http-test/test_app.rb +194 -0
- data/public/atom.xml +1230 -0
- data/test/setup.rb +28 -0
- data/test/test_broken_server.rb +62 -0
- data/test/test_server.rb +53 -0
- data/test/test_test_app.rb +104 -0
- metadata +144 -0
data/test/setup.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You
|
6
|
+
# may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
#### General test setup: LOAD_PATH, logging, console output ####
|
18
|
+
|
19
|
+
ldir = File.join( File.dirname( __FILE__ ), "..", "lib" )
|
20
|
+
$LOAD_PATH.unshift( ldir ) unless $LOAD_PATH.include?( ldir )
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'rjack-logback'
|
24
|
+
RJack::Logback.config_console( :stderr => true )
|
25
|
+
RJack::Logback.root.level = RJack::Logback::DEBUG if ARGV.include?( '-v' )
|
26
|
+
|
27
|
+
require 'minitest/unit'
|
28
|
+
require 'minitest/autorun'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
#.hashdot.profile += jruby-shortlived
|
3
|
+
|
4
|
+
#--
|
5
|
+
# Copyright (c) 2011 David Kellum
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
8
|
+
# may not use this file except in compliance with the License. You
|
9
|
+
# may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied. See the License for the specific language governing
|
17
|
+
# permissions and limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
require File.join( File.dirname( __FILE__ ), "setup" )
|
21
|
+
|
22
|
+
require 'iudex-http-test/broken_server'
|
23
|
+
require 'net/http'
|
24
|
+
require 'thread'
|
25
|
+
|
26
|
+
class TestBrokenServer < MiniTest::Unit::TestCase
|
27
|
+
include Iudex::HTTP::Test
|
28
|
+
|
29
|
+
def test_start_stop
|
30
|
+
bs = BrokenServer.new
|
31
|
+
bs.start
|
32
|
+
bs.stop
|
33
|
+
pass
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_fake_http
|
37
|
+
bs = BrokenServer.new
|
38
|
+
bs.start
|
39
|
+
sthread = Thread.new do
|
40
|
+
bs.accept do |sock|
|
41
|
+
content = "body"
|
42
|
+
|
43
|
+
sock.write "HTTP/1.0 200 OK\r\n"
|
44
|
+
sock.write "Content-Length: #{ content.length }\r\n"
|
45
|
+
sock.write "Connection: close\r\n"
|
46
|
+
sock.write "\r\n"
|
47
|
+
sock.write content
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
res = Net::HTTP.start( 'localhost', bs.port ) do |http|
|
52
|
+
http.get( '/' )
|
53
|
+
end
|
54
|
+
|
55
|
+
sthread.join
|
56
|
+
|
57
|
+
assert_instance_of( Net::HTTPOK, res )
|
58
|
+
ensure
|
59
|
+
bs.stop if bs
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/test/test_server.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
#.hashdot.profile += jruby-shortlived
|
3
|
+
|
4
|
+
#--
|
5
|
+
# Copyright (c) 2011 David Kellum
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
8
|
+
# may not use this file except in compliance with the License. You
|
9
|
+
# may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied. See the License for the specific language governing
|
17
|
+
# permissions and limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
require File.join( File.dirname( __FILE__ ), "setup" )
|
21
|
+
|
22
|
+
require 'iudex-http-test/helper'
|
23
|
+
require 'net/http'
|
24
|
+
|
25
|
+
class TestServer < MiniTest::Unit::TestCase
|
26
|
+
include Iudex::HTTP::Test
|
27
|
+
include Helper
|
28
|
+
CustomUnit.register
|
29
|
+
|
30
|
+
def test_byte_array_new
|
31
|
+
# Fishwife uses this.
|
32
|
+
# Seeing NPE on:
|
33
|
+
# jruby 1.5.6 (ruby 1.8.7 patchlevel 249) (2010-12-03 9cf97c3)
|
34
|
+
# (OpenJDK Client VM 1.6.0_20) [i386-java]
|
35
|
+
# (Java HotSpot(TM) Client VM 1.6.0_26) [i386-java]
|
36
|
+
# (Java HotSpot(TM) Client VM 1.7.0) [i386-java]
|
37
|
+
# But not jruby 1.6.2, or either with Server VM
|
38
|
+
Java::byte[4096].new
|
39
|
+
pass
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_port
|
43
|
+
assert server.port > 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_index
|
47
|
+
res = Net::HTTP.start( 'localhost', server.port ) do |http|
|
48
|
+
http.get( '/index' )
|
49
|
+
end
|
50
|
+
assert_instance_of( Net::HTTPOK, res )
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
#.hashdot.profile += jruby-shortlived
|
3
|
+
|
4
|
+
#--
|
5
|
+
# Copyright (c) 2011 David Kellum
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
8
|
+
# may not use this file except in compliance with the License. You
|
9
|
+
# may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied. See the License for the specific language governing
|
17
|
+
# permissions and limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
require File.join( File.dirname( __FILE__ ), "setup" )
|
21
|
+
|
22
|
+
require 'rack/test'
|
23
|
+
|
24
|
+
require 'iudex-http-test/test_app'
|
25
|
+
|
26
|
+
class TestTestApp < MiniTest::Unit::TestCase
|
27
|
+
include Iudex::HTTP::Test
|
28
|
+
include Rack::Test::Methods
|
29
|
+
|
30
|
+
def app
|
31
|
+
TestApp.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_root
|
35
|
+
get '/'
|
36
|
+
assert_equal( 302, last_response.status )
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_301
|
40
|
+
get '/301'
|
41
|
+
assert_equal( 301, last_response.status )
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_304
|
45
|
+
get '/304'
|
46
|
+
assert_equal( 304, last_response.status )
|
47
|
+
assert_equal( "", last_response.body )
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_redirect
|
51
|
+
get '/redirect?loc=http://foo.com/bar'
|
52
|
+
assert_equal( 'http://foo.com/bar', last_response.headers[ 'Location' ] )
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_redirects
|
56
|
+
get '/redirects/multi/2'
|
57
|
+
assert_equal( 302, last_response.status )
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_redirects_code
|
61
|
+
get '/redirects/multi/2?code=301'
|
62
|
+
assert_equal( 301, last_response.status )
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_redirects_complete
|
66
|
+
get '/redirects/multi/1'
|
67
|
+
assert_equal( 200, last_response.status )
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_concurrency_counter
|
71
|
+
get '/index?con=1'
|
72
|
+
assert_equal( 200, last_response.status )
|
73
|
+
|
74
|
+
get '/concount?con=1'
|
75
|
+
assert_equal( 200, last_response.status )
|
76
|
+
assert_equal( 1, last_response.body.to_i )
|
77
|
+
|
78
|
+
get '/concount?con=1'
|
79
|
+
assert_equal( 200, last_response.status )
|
80
|
+
assert_equal( 1, last_response.body.to_i )
|
81
|
+
|
82
|
+
get '/concount'
|
83
|
+
assert_equal( 200, last_response.status )
|
84
|
+
assert_equal( 0, last_response.body.to_i )
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_index
|
88
|
+
get '/index'
|
89
|
+
assert_equal( 200, last_response.status )
|
90
|
+
assert_match( %r{^text/html(;.*)?}, last_response.content_type )
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_atom
|
94
|
+
get '/atom.xml'
|
95
|
+
assert_equal( 200, last_response.status )
|
96
|
+
assert_match( %r{^application/atom\+xml(;.*)?}, last_response.content_type )
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_echo_header
|
100
|
+
get( '/echo/header/Accept', {}, { 'HTTP_ACCEPT' => 'text/plain' } )
|
101
|
+
assert_equal( 'text/plain', last_response.body )
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iudex-http-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.1.0
|
6
|
+
platform: java
|
7
|
+
authors:
|
8
|
+
- David Kellum
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-11-13 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fishwife
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.1.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: sinatra
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.3.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: markaby
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.7.1
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: minitest
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "2.3"
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rack-test
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.6.0
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rjack-tarpit
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.4.0
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id006
|
81
|
+
description: |-
|
82
|
+
Iudex is a general purpose web crawler and feed processor in
|
83
|
+
ruby/java. The iudex-http-test gem contains a HTTP test server for
|
84
|
+
testing HTTP client implementations.
|
85
|
+
email:
|
86
|
+
- dek-oss@gravitext.com
|
87
|
+
executables:
|
88
|
+
- iudex-http-test-fg
|
89
|
+
extensions: []
|
90
|
+
|
91
|
+
extra_rdoc_files:
|
92
|
+
- Manifest.txt
|
93
|
+
- History.rdoc
|
94
|
+
- README.rdoc
|
95
|
+
files:
|
96
|
+
- History.rdoc
|
97
|
+
- Manifest.txt
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- bin/iudex-http-test-fg
|
101
|
+
- lib/iudex-http-test/base.rb
|
102
|
+
- lib/iudex-http-test.rb
|
103
|
+
- lib/iudex-http-test/broken_server.rb
|
104
|
+
- lib/iudex-http-test/helper.rb
|
105
|
+
- lib/iudex-http-test/server.rb
|
106
|
+
- lib/iudex-http-test/test_app.rb
|
107
|
+
- public/atom.xml
|
108
|
+
- test/setup.rb
|
109
|
+
- test/test_broken_server.rb
|
110
|
+
- test/test_server.rb
|
111
|
+
- test/test_test_app.rb
|
112
|
+
- .gemtest
|
113
|
+
homepage: http://github.com/dekellum/iudex
|
114
|
+
licenses: []
|
115
|
+
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options:
|
118
|
+
- --main
|
119
|
+
- README.rdoc
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: "0"
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project: iudex-http-test
|
137
|
+
rubygems_version: 1.8.9
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: Iudex is a general purpose web crawler and feed processor in ruby/java
|
141
|
+
test_files:
|
142
|
+
- test/test_broken_server.rb
|
143
|
+
- test/test_server.rb
|
144
|
+
- test/test_test_app.rb
|