Skip to content

Commit 9074751

Browse files
committed
moved and fixed tests around so that they are usable (during development) once again
1 parent 17bd887 commit 9074751

12 files changed

+267
-238
lines changed

test/java/test_java_attribute.rb renamed to src/test/ruby/pkcs7/test_attribute.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
require File.expand_path('../pkcs7_helper', File.dirname(__FILE__))
2+
13
module PKCS7Test
2-
class TestJavaAttribute < Test::Unit::TestCase
4+
class TestAttribute < Test::Unit::TestCase
35
def test_attributes
46
val = ASN1::OctetString.new("foo".to_java_bytes)
57
val2 = ASN1::OctetString.new("bar".to_java_bytes)
68
attr = Attribute.create(123, 444, val)
7-
assert_raise NoMethodError do
9+
assert_raise NoMethodError do
810
attr.type = 12
911
end
10-
assert_raise NoMethodError do
12+
assert_raise NoMethodError do
1113
attr.value = val2
1214
end
1315

1416
assert_equal 123, attr.type
1517
assert_equal val, attr.set.get(0)
1618

1719
attr2 = Attribute.create(123, 444, val)
18-
20+
1921
assert_equal attr, attr2
20-
22+
2123
assert_not_equal Attribute.create(124, 444, val), attr
2224
assert_not_equal Attribute.create(123, 444, val2), attr
2325
end

test/java/test_java_bio.rb renamed to src/test/ruby/pkcs7/test_bio.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
require File.expand_path('../pkcs7_helper', File.dirname(__FILE__))
2+
13
module PKCS7Test
2-
class TestJavaBIO < Test::Unit::TestCase
4+
class TestBIO < Test::Unit::TestCase
35
def test_string_bio_simple
46
bio = BIO::from_string("abc")
57
arr = Java::byte[20].new
@@ -26,7 +28,7 @@ def test_string_bio_simple_with_newline_and_more_data
2628
read = bio.gets(arr, 10)
2729
assert_equal 4, read
2830
assert_equal "foo\n".to_java_bytes.to_a, arr.to_a[0...read]
29-
31+
3032
read = bio.gets(arr, 10)
3133
assert_equal 1, read
3234
assert_equal "\n".to_java_bytes.to_a, arr.to_a[0...read]

test/java/test_java_mime.rb renamed to src/test/ruby/pkcs7/test_mime.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
require File.expand_path('../pkcs7_helper', File.dirname(__FILE__))
2+
13
module PKCS7Test
2-
class TestJavaMime < Test::Unit::TestCase
4+
class TestMIME < Test::Unit::TestCase
35
def test_find_header_returns_null_on_nonexisting_header
46
headers = []
57
assert_nil Mime::DEFAULT.find_header(headers, "foo")
@@ -23,7 +25,7 @@ def test_find_param_returns_the_param_with_the_same_name
2325
hdr = MimeHeader.new("one", "two", [par])
2426
assert_equal par, Mime::DEFAULT.find_param(hdr, "hox")
2527
end
26-
28+
2729
def test_simple_parse_headers
2830
bio = BIO::from_string("Foo: bar")
2931
result = Mime::DEFAULT.parse_headers(bio)
@@ -106,7 +108,7 @@ def test_parse_headers_with_param
106108
header = result[0]
107109
assert_equal "content-type", header.name
108110
assert_equal "multipart/related", header.value
109-
assert_equal [MimeParam.new("boundary","MIME_boundary"),
111+
assert_equal [MimeParam.new("boundary","MIME_boundary"),
110112
MimeParam.new("type","text/xml")], header.params.to_a
111113
end
112114

@@ -117,7 +119,7 @@ def test_parse_headers_with_param_newline
117119
header = result[0]
118120
assert_equal "content-type", header.name
119121
assert_equal "multipart/related", header.value
120-
assert_equal [MimeParam.new("boundary","MIME_boundary"),
122+
assert_equal [MimeParam.new("boundary","MIME_boundary"),
121123
MimeParam.new("type","text/xml")], header.params.to_a
122124
end
123125

@@ -128,17 +130,17 @@ def test_parse_headers_with_param_newline_and_semicolon
128130
header = result[0]
129131
assert_equal "content-type", header.name
130132
assert_equal "multipart/related", header.value
131-
assert_equal [MimeParam.new("boundary","MIME_boundary"),
133+
assert_equal [MimeParam.new("boundary","MIME_boundary"),
132134
MimeParam.new("type","text/xml")], header.params.to_a
133135
end
134136

135137
def test_advanced_mime_message
136138
bio = BIO::from_string(MultipartSignedString)
137139
result = Mime::DEFAULT.parse_headers(bio)
138-
140+
139141
assert_equal "mime-version", result[0].name
140142
assert_equal "1.0", result[0].value
141-
143+
142144
assert_equal "to", result[1].name
143145
assert_equal "[email protected]", result[1].value
144146

@@ -153,10 +155,10 @@ def test_advanced_mime_message
153155

154156
assert_equal "date", result[5].name
155157
assert_equal "fri, 06 sep 2002 00:25:21 -0300", result[5].value
156-
158+
157159
assert_equal "content-type", result[6].name
158160
assert_equal "multipart/signed", result[6].value
159-
161+
160162
assert_equal "micalg", result[6].params[0].param_name
161163
assert_equal "SHA1", result[6].params[0].param_value
162164

@@ -165,7 +167,7 @@ def test_advanced_mime_message
165167

166168
assert_equal "protocol", result[6].params[2].param_name
167169
assert_equal "application/pkcs7-signature", result[6].params[2].param_value
168-
170+
169171
assert_equal 3, result[6].params.length
170172
assert_equal 7, result.length
171173
end

0 commit comments

Comments
 (0)