-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.rb
96 lines (82 loc) · 2.64 KB
/
client.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require "test/unit"
require "rest_client"
require "json"
class TestRESTClient < Test::Unit::TestCase
def setup
@connString = "http://localhost:4567" #Input file variables.
puts "\nUsing: #{@connString}"
end
def teardown
## Nothing really
end
#Assert types for unit tests:
#http://en.wikibooks.org/wiki/Ruby_Programming/Unit_testin
def test_toolSilkRespFieldsSpecific
response = RestClient.get "#{@connString}/tool/silk-agrovoc/response-fields/response1"
puts response.body
assert( response.body,"Failed test opening a response field of a tool.\n" )
end
def test_toolSilkRespFields
response = RestClient.get "#{@connString}/tool/silk-agrovoc/response-fields"
puts response.body
assert( response.body,"Failed test opening specific tool's response fields\n" )
end
def test_toolSilk
response = RestClient.get "#{@connString}/tool/silk-agrovoc"
puts response.body
assert( response.body,"Failed test opening specific tool\n" )
end
def test_toolKea
response = RestClient.get "#{@connString}/tool/kea-agrovoc"
puts response.body
assert( response.body,"Failed test opening specific tool\n" )
end
def test_toolList
response = RestClient.get "#{@connString}/tool/list"
puts response.body
assert( response.body,"Failed test listing tools \n" )
end
def test_supportedInput
response = RestClient.get "#{@connString}/input/text/plain"
puts response.body
assert( response.body,"Failed test supported specific input.\n" )
end
def test_supportedInputs
response = RestClient.get "#{@connString}/input/supported"
puts response.body
assert( response.body,"Failed test supported inputs.\n" )
end
def test_fromtext
data = ""
File.open("testFiles/exampleText", "r").each_line do |line|
data+=line
end
post = RestClient.post "#{@connString}/fromtext/links/", {
"tool" => "silk-agrovoc",
"text" => data,
"limit" => "10"
}
puts post.body
assert( post.body,"Failed test supported inputs.\n" )
end
def test_fromurisilk
data = "http://textuploader.com/d8t9/raw"
post = RestClient.post "#{@connString}/text/links/", {
"tool" => "silk-agrovoc",
"text" => data,
"limit" => "10"
}
puts post.body
assert( post.body,"Failed test supported inputs.\n" )
end
def test_fromuri
data = "http://textuploader.com/d8t9/raw"
post = RestClient.post "#{@connString}/text/links/", {
"tool" => "kea-agrovoc",
"text" => data,
"limit" => "10"
}
puts post.body
assert( post.body,"Failed test supported inputs.\n" )
end
end