xmlconv 1.0.1 → 1.0.2
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.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/History.txt +8 -0
- data/README.txt +0 -4
- data/Rakefile +16 -32
- data/bin/migrate_xmlconv_to_utf_8 +235 -0
- data/bin/{admin → xmlconv_admin} +0 -0
- data/bin/xmlconvd +3 -1
- data/converter_scripts/convert.rb +23 -0
- data/{xmlconv_convert.rb → converter_scripts/xmlconv_convert.rb} +0 -0
- data/lib/xmlconv/config.rb +6 -0
- data/lib/xmlconv/custom/lookandfeel.rb +1 -1
- data/lib/xmlconv/i2/header.rb +5 -3
- data/lib/xmlconv/i2/position.rb +3 -2
- data/lib/xmlconv/util/application.rb +9 -6
- data/lib/xmlconv/util/destination.rb +11 -6
- data/lib/xmlconv/util/mail.rb +26 -14
- data/lib/xmlconv/util/transaction.rb +3 -1
- data/lib/xmlconv/version.rb +3 -0
- data/readme.md +46 -0
- data/test/data/polling.yaml +10 -0
- data/test/test_i2/address.rb +2 -2
- data/test/test_i2/date.rb +2 -2
- data/test/test_i2/document.rb +12 -22
- data/test/test_i2/header.rb +2 -2
- data/test/test_i2/order.rb +18 -32
- data/test/test_i2/parser.rb +4 -3
- data/test/test_i2/position.rb +9 -23
- data/test/test_model/address.rb +2 -2
- data/test/test_model/agreement.rb +2 -2
- data/test/test_model/bdd.rb +8 -9
- data/test/test_model/bsr.rb +6 -7
- data/test/test_model/delivery.rb +11 -15
- data/test/test_model/delivery_item.rb +5 -5
- data/test/test_model/freetext_container.rb +3 -3
- data/test/test_model/invoice.rb +8 -11
- data/test/test_model/invoice_item.rb +5 -4
- data/test/test_model/name.rb +2 -2
- data/test/test_model/part_info.rb +2 -2
- data/test/test_model/party.rb +16 -22
- data/test/test_model/price.rb +2 -2
- data/test/test_util/application.rb +36 -86
- data/test/test_util/destination.rb +11 -19
- data/test/test_util/invoicer.rb +3 -3
- data/test/test_util/polling_manager.rb +11 -11
- data/test/test_util/transaction.rb +31 -55
- data/xmlconv.gemspec +45 -0
- metadata +378 -78
- data/.gemtest +0 -0
- data/lib/xmlconv/i2/parser.rb +0 -23
- data/lib/xmlconv.rb +0 -3
- data/test/mock.rb +0 -149
data/test/test_model/party.rb
CHANGED
@@ -4,18 +4,13 @@
|
|
4
4
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
5
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require 'test/unit'
|
8
7
|
require 'xmlconv/model/party'
|
9
|
-
require
|
8
|
+
require "minitest/autorun"
|
9
|
+
require 'flexmock/minitest'
|
10
10
|
|
11
11
|
module XmlConv
|
12
12
|
module Model
|
13
|
-
class TestParty < Test
|
14
|
-
class ToSMock < Mock
|
15
|
-
def to_s
|
16
|
-
true
|
17
|
-
end
|
18
|
-
end
|
13
|
+
class TestParty < Minitest::Test
|
19
14
|
def setup
|
20
15
|
@party = Party.new
|
21
16
|
end
|
@@ -40,19 +35,19 @@ module XmlConv
|
|
40
35
|
assert_equal('id_string', @party.acc_id)
|
41
36
|
end
|
42
37
|
def test_add_party
|
43
|
-
employee =
|
44
|
-
employee.
|
38
|
+
employee = flexmock('Employee')
|
39
|
+
employee.should_receive(:role).at_least.once.and_return('Employee')
|
45
40
|
@party.add_party(employee)
|
46
41
|
assert_equal(employee, @party.employee)
|
47
42
|
assert_equal([employee], @party.parties)
|
48
|
-
ship_to =
|
49
|
-
ship_to.
|
43
|
+
ship_to = flexmock('ShipTo')
|
44
|
+
ship_to.should_receive(:role).at_least.once.and_return('ShipTo')
|
50
45
|
@party.add_party(ship_to)
|
51
46
|
assert_equal(employee, @party.employee)
|
52
47
|
assert_equal(ship_to, @party.ship_to)
|
53
48
|
assert_equal([employee, ship_to], @party.parties)
|
54
|
-
bill_to =
|
55
|
-
bill_to.
|
49
|
+
bill_to = flexmock('BillTo')
|
50
|
+
bill_to.should_receive(:role).at_least.once.and_return('BillTo')
|
56
51
|
@party.add_party(bill_to)
|
57
52
|
assert_equal(employee, @party.employee)
|
58
53
|
assert_equal(bill_to, @party.bill_to)
|
@@ -67,25 +62,24 @@ module XmlConv
|
|
67
62
|
assert_nil(@party.name)
|
68
63
|
@party.name = 'a_string'
|
69
64
|
assert_equal('a_string', @party.name)
|
70
|
-
name =
|
65
|
+
name = flexmock('Name')
|
71
66
|
@party.name = name
|
72
67
|
assert_equal(name, @party.name)
|
73
|
-
name.__verify
|
74
68
|
end
|
75
69
|
def test_employee
|
76
|
-
employee =
|
77
|
-
employee.
|
70
|
+
employee = flexmock('Employee')
|
71
|
+
employee.should_receive(:role).at_least.once.and_return('Employee')
|
78
72
|
@party.add_party(employee)
|
79
73
|
assert_equal(employee, @party.employee)
|
80
74
|
assert_equal([employee], @party.parties)
|
81
|
-
ship_to =
|
82
|
-
ship_to.
|
75
|
+
ship_to = flexmock('ShipTo')
|
76
|
+
ship_to.should_receive(:role).at_least.once.and_return('ShipTo')
|
83
77
|
@party.add_party(ship_to)
|
84
78
|
assert_equal(employee, @party.employee)
|
85
79
|
assert_equal(ship_to, @party.ship_to)
|
86
80
|
assert_equal([employee, ship_to], @party.parties)
|
87
|
-
bill_to =
|
88
|
-
bill_to.
|
81
|
+
bill_to = flexmock('BillTo')
|
82
|
+
bill_to.should_receive(:role).at_least.once.and_return('BillTo')
|
89
83
|
@party.add_party(bill_to)
|
90
84
|
assert_equal(employee, @party.employee)
|
91
85
|
assert_equal(bill_to, @party.bill_to)
|
data/test/test_model/price.rb
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
$: << File.dirname(__FILE__)
|
5
5
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'minitest/autorun'
|
8
8
|
require 'xmlconv/model/price'
|
9
9
|
|
10
10
|
module XmlConv
|
11
11
|
module Model
|
12
|
-
class TestPrice <
|
12
|
+
class TestPrice < ::Minitest::Test
|
13
13
|
def setup
|
14
14
|
@price = Price.new
|
15
15
|
end
|
@@ -6,15 +6,14 @@ $: << File.dirname(__FILE__)
|
|
6
6
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
7
7
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
8
8
|
|
9
|
-
require 'test/unit'
|
10
9
|
require 'xmlconv/util/application'
|
11
|
-
require '
|
12
|
-
require 'flexmock'
|
10
|
+
require 'minitest/autorun'
|
11
|
+
require 'flexmock/minitest'
|
13
12
|
|
14
13
|
module XmlConv
|
15
14
|
module Conversion
|
16
15
|
def const_get(symbol)
|
17
|
-
if(symbol.is_a?(
|
16
|
+
if(symbol.is_a?(FlexMock))
|
18
17
|
symbol
|
19
18
|
else
|
20
19
|
super
|
@@ -23,8 +22,7 @@ module XmlConv
|
|
23
22
|
module_function :const_get
|
24
23
|
end
|
25
24
|
module Util
|
26
|
-
class TestApplication <
|
27
|
-
include FlexMock::TestCase
|
25
|
+
class TestApplication < ::Minitest::Test
|
28
26
|
def setup
|
29
27
|
@app = Util::Application.new
|
30
28
|
@app.init
|
@@ -34,100 +32,69 @@ module XmlConv
|
|
34
32
|
assert_respond_to(@app, :failed_transactions)
|
35
33
|
end
|
36
34
|
def test_execute
|
37
|
-
transaction =
|
38
|
-
cache =
|
39
|
-
|
40
|
-
|
41
|
-
}
|
42
|
-
cache.__next(:store) { |transactions|
|
43
|
-
assert_equal(@app.transactions, transactions)
|
44
|
-
}
|
35
|
+
transaction = flexmock('Transaction')
|
36
|
+
cache = flexmock('Cache')
|
37
|
+
cache.should_receive(:transaction).with(Proc).once.and_return{ |block| block.call }
|
38
|
+
cache.should_receive(:store).with(@app.transactions)
|
45
39
|
ODBA.cache = cache
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
transaction.__next(:execute) { }
|
50
|
-
transaction.__next(:notify) { }
|
40
|
+
transaction.should_receive(:transaction_id=).with(1)
|
41
|
+
transaction.should_receive(:execute).once.and_return(transaction)
|
42
|
+
transaction.should_receive(:notify).once
|
51
43
|
assert_equal([], @app.transactions)
|
52
44
|
assert_equal(0, @app.transactions.size)
|
53
45
|
@app.execute(transaction)
|
54
46
|
assert_equal([transaction], @app.transactions)
|
55
|
-
transaction.__verify
|
56
|
-
cache.__verify
|
57
47
|
ensure
|
58
48
|
ODBA.cache = nil
|
59
49
|
end
|
60
50
|
def test_execute__survive_notification_failure
|
61
|
-
transaction =
|
62
|
-
cache =
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
cache.__next(:store) { |transactions|
|
67
|
-
assert_equal(@app.transactions, transactions)
|
68
|
-
}
|
51
|
+
transaction = flexmock('Transaction')
|
52
|
+
cache = flexmock('Cache')
|
53
|
+
cache.should_receive(:transaction).with(Proc).once.and_return{ |block| block.call }
|
54
|
+
cache.should_receive(:store).with(@app.transactions)
|
69
55
|
ODBA.cache = cache
|
70
|
-
|
71
|
-
|
72
|
-
}
|
73
|
-
transaction.__next(:execute) { }
|
74
|
-
transaction.__next(:notify) {
|
75
|
-
raise Net::SMTPFatalError, 'could not send email'
|
76
|
-
}
|
56
|
+
transaction.should_receive(:transaction_id=).with(1)
|
57
|
+
transaction.should_receive(:execute).once.and_raise(Net::SMTPFatalError, 'could not send email')
|
77
58
|
assert_equal([], @app.transactions)
|
78
59
|
assert_equal(0, @app.transactions.size)
|
79
60
|
@app.execute(transaction)
|
80
61
|
assert_equal([transaction], @app.transactions)
|
81
|
-
transaction.__verify
|
82
|
-
cache.__verify
|
83
62
|
ensure
|
84
63
|
ODBA.cache = nil
|
85
64
|
end
|
86
65
|
def test_execute__notify_errors
|
87
|
-
transaction =
|
88
|
-
cache =
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
cache.__next(:store) { |transactions|
|
93
|
-
assert_equal(@app.transactions, transactions)
|
94
|
-
}
|
66
|
+
transaction = flexmock('Transaction')
|
67
|
+
cache = flexmock('Cache')
|
68
|
+
cache.should_receive(:transaction).with(Proc).once.and_return{ |block| block.call }
|
69
|
+
cache.should_receive(:store).with(@app.transactions)
|
95
70
|
ODBA.cache = cache
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
raise 'oops, something went wrong'
|
101
|
-
}
|
102
|
-
transaction.__next(:error=) { }
|
103
|
-
transaction.__next(:notify) { }
|
71
|
+
transaction.should_receive(:transaction_id=).with(1)
|
72
|
+
transaction.should_receive(:execute).and_raise 'oops, something went wrong'
|
73
|
+
transaction.should_receive(:error=)
|
74
|
+
transaction.should_receive(:notify)
|
104
75
|
assert_equal([], @app.transactions)
|
105
76
|
assert_equal(0, @app.transactions.size)
|
106
77
|
@app.execute(transaction)
|
107
78
|
assert_equal([transaction], @app.transactions)
|
108
|
-
transaction.__verify
|
109
|
-
cache.__verify
|
110
79
|
ensure
|
111
80
|
ODBA.cache = nil
|
112
81
|
end
|
113
82
|
def test_dumpable
|
114
|
-
|
83
|
+
Marshal.dump(@app)
|
115
84
|
end
|
116
85
|
def test_next_transaction_id
|
117
86
|
assert_equal([], @app.transactions)
|
118
87
|
assert_equal(1, @app.next_transaction_id)
|
119
88
|
assert_equal(2, @app.next_transaction_id)
|
120
89
|
assert_equal(3, @app.next_transaction_id)
|
121
|
-
trans1 =
|
122
|
-
trans2 =
|
90
|
+
trans1 = flexmock('Transaction1')
|
91
|
+
trans2 = flexmock('Transaction2')
|
92
|
+
trans1.should_receive(:transaction_id).and_return(6)
|
93
|
+
trans2.should_receive(:transaction_id).and_return(3)
|
123
94
|
@app.transactions.push(trans1)
|
124
95
|
@app.transactions.push(trans2)
|
125
96
|
@app.instance_variable_set('@next_transaction_id', nil)
|
126
|
-
trans1.__next(:transaction_id) { 6 }
|
127
|
-
trans2.__next(:transaction_id) { 3 }
|
128
97
|
assert_equal(7, @app.next_transaction_id)
|
129
|
-
trans1.__verify
|
130
|
-
trans2.__verify
|
131
98
|
end
|
132
99
|
def test_odba_exclude_vars
|
133
100
|
@app.instance_variable_set('@next_transaction_id', 10)
|
@@ -135,36 +102,19 @@ module XmlConv
|
|
135
102
|
assert_nil(@app.instance_variable_get('@next_transaction_id'))
|
136
103
|
end
|
137
104
|
def test_transaction
|
138
|
-
trans1 =
|
139
|
-
trans2 =
|
140
|
-
trans3 =
|
105
|
+
trans1 = flexmock('Transaction1')
|
106
|
+
trans2 = flexmock('Transaction2')
|
107
|
+
trans3 = flexmock('Transaction2')
|
108
|
+
trans1.should_receive(:transaction_id).and_return(1).at_least.once
|
109
|
+
trans2.should_receive(:transaction_id).and_return(2).at_least.once
|
110
|
+
trans3.should_receive(:transaction_id).and_return(5).at_least.once
|
141
111
|
@app.transactions.push(trans1)
|
142
112
|
@app.transactions.push(trans2)
|
143
|
-
trans2.__next(:transaction_id) { 2 }
|
144
|
-
trans1.__next(:transaction_id) { 1 }
|
145
113
|
assert_equal(trans1, @app.transaction(1))
|
146
|
-
trans1.__verify
|
147
|
-
trans2.__verify
|
148
114
|
@app.transactions.push(trans3)
|
149
|
-
trans3.__next(:transaction_id) { 5 }
|
150
|
-
trans1.__next(:transaction_id) { 1 }
|
151
|
-
trans2.__next(:transaction_id) { 2 }
|
152
115
|
assert_equal(trans2, @app.transaction(2))
|
153
|
-
trans1.__verify
|
154
|
-
trans2.__verify
|
155
|
-
trans3.__verify
|
156
|
-
trans3.__next(:transaction_id) { 5 }
|
157
|
-
trans3.__next(:transaction_id) { 5 }
|
158
116
|
assert_equal(trans3, @app.transaction(5))
|
159
|
-
trans1.__verify
|
160
|
-
trans2.__verify
|
161
|
-
trans3.__verify
|
162
|
-
trans3.__next(:transaction_id) { 5 }
|
163
|
-
trans3.__next(:transaction_id) { 5 }
|
164
117
|
assert_equal(trans3, @app.transaction('5'))
|
165
|
-
trans1.__verify
|
166
|
-
trans2.__verify
|
167
|
-
trans3.__verify
|
168
118
|
end
|
169
119
|
def test_exprort_orders
|
170
120
|
transaction = flexmock('transaction') do |trans|
|
@@ -5,15 +5,14 @@ $: << File.dirname(__FILE__)
|
|
5
5
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
6
6
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
7
7
|
|
8
|
-
require 'test/unit'
|
9
8
|
require 'xmlconv/util/destination'
|
10
|
-
require 'flexmock'
|
11
9
|
require 'xmlconv/config'
|
10
|
+
require 'minitest/autorun'
|
11
|
+
require 'flexmock/minitest'
|
12
12
|
|
13
13
|
module XmlConv
|
14
14
|
module Util
|
15
|
-
class TestDestination <
|
16
|
-
include FlexMock::TestCase
|
15
|
+
class TestDestination < ::Minitest::Test
|
17
16
|
def setup
|
18
17
|
@destination = Destination.new
|
19
18
|
super
|
@@ -44,8 +43,7 @@ module XmlConv
|
|
44
43
|
Destination.book('ftp://www.example.com'))
|
45
44
|
end
|
46
45
|
end
|
47
|
-
class TestDestinationDir <
|
48
|
-
include FlexMock::TestCase
|
46
|
+
class TestDestinationDir < ::Minitest::Test
|
49
47
|
def setup
|
50
48
|
@destination = DestinationDir.new
|
51
49
|
@target_dir = File.expand_path('data/destination',
|
@@ -129,8 +127,7 @@ module XmlConv
|
|
129
127
|
assert_equal(20, @destination.status_comparable)
|
130
128
|
end
|
131
129
|
end
|
132
|
-
class TestRemoteDestination <
|
133
|
-
include FlexMock::TestCase
|
130
|
+
class TestRemoteDestination < ::Minitest::Test
|
134
131
|
def setup
|
135
132
|
@destination = RemoteDestination.new
|
136
133
|
super
|
@@ -144,8 +141,7 @@ module XmlConv
|
|
144
141
|
assert_respond_to(@destination, :host=)
|
145
142
|
end
|
146
143
|
end
|
147
|
-
class TestDestinationHttp <
|
148
|
-
include FlexMock::TestCase
|
144
|
+
class TestDestinationHttp < ::Minitest::Test
|
149
145
|
def setup
|
150
146
|
@destination = DestinationHttp.new
|
151
147
|
@destination.transport = @transport = flexmock('DestinationHttp::HTTP_CLASS')
|
@@ -201,8 +197,7 @@ module XmlConv
|
|
201
197
|
assert_equal('http://xmlconv.ywesee.com:12345/test.rbx', uri.to_s)
|
202
198
|
end
|
203
199
|
end
|
204
|
-
class TestDestinationFtp <
|
205
|
-
include FlexMock::TestCase
|
200
|
+
class TestDestinationFtp < ::Minitest::Test
|
206
201
|
def setup
|
207
202
|
@destination = DestinationFtp.new
|
208
203
|
@destination.transport = @transport = flexmock('DestinationFtp::FTP_CLASS')
|
@@ -265,7 +260,7 @@ module XmlConv
|
|
265
260
|
delivery.should_receive(:to_s).and_return { 'The Delivery' }
|
266
261
|
delivery.should_receive(:filename).and_return { 'test.dat' }
|
267
262
|
ftp_session.should_receive(:chdir).and_return { |path|
|
268
|
-
assert_equal('
|
263
|
+
assert_equal('foo/bar/', path)
|
269
264
|
}
|
270
265
|
expecteds = %w{000_test.dat 001_test.dat}
|
271
266
|
ftp_session.should_receive(:puttextfile).times(2)\
|
@@ -289,16 +284,14 @@ module XmlConv
|
|
289
284
|
end
|
290
285
|
def test_deliver_tmp
|
291
286
|
path = 'ftp://testaccount:password@xmlconv.ywesee.com/foo/bar/'
|
292
|
-
tmp = '/foo/tmp'
|
287
|
+
tmp = '/foo/tmp/'
|
293
288
|
@destination = Destination.book(path, tmp)
|
294
289
|
@destination.transport = @transport = flexmock('DestinationHttp::FTP_CLASS')
|
295
290
|
ftp_session = flexmock('FtpSession')
|
296
291
|
delivery = flexmock('Delivery')
|
297
292
|
delivery.should_receive(:to_s).and_return { 'The Delivery' }
|
298
293
|
delivery.should_receive(:filename).and_return { 'test.dat' }
|
299
|
-
ftp_session.should_receive(:chdir).
|
300
|
-
assert_equal('/foo/bar/', path)
|
301
|
-
}
|
294
|
+
ftp_session.should_receive(:chdir).with('foo/bar/')
|
302
295
|
ftp_session.should_receive(:puttextfile).and_return { |local, remote|
|
303
296
|
assert_equal("The Delivery\n", File.read(local))
|
304
297
|
assert_equal('/foo/tmp/test.dat', remote)
|
@@ -320,8 +313,7 @@ module XmlConv
|
|
320
313
|
end
|
321
314
|
end
|
322
315
|
=begin
|
323
|
-
class TestDestinationSftp <
|
324
|
-
include FlexMock::TestCase
|
316
|
+
class TestDestinationSftp < ::Minitest::Test
|
325
317
|
def setup
|
326
318
|
@destination = DestinationSftp.new
|
327
319
|
@destination.transport = @transport = flexmock('DestinationSftp::SFTP_CLASS')
|
data/test/test_util/invoicer.rb
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
$: << File.dirname(__FILE__)
|
5
5
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require 'test/unit'
|
8
7
|
require 'xmlconv/util/invoicer'
|
9
|
-
require '
|
8
|
+
require 'minitest/autorun'
|
9
|
+
require 'flexmock/minitest'
|
10
10
|
|
11
11
|
module XmlConv
|
12
12
|
module Util
|
13
|
-
class TestInvoicer <
|
13
|
+
class TestInvoicer < ::Minitest::Test
|
14
14
|
def setup
|
15
15
|
@invoicer = Invoicer
|
16
16
|
end
|
@@ -4,19 +4,20 @@
|
|
4
4
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
5
5
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require 'test/unit'
|
8
7
|
require 'xmlconv/util/polling_manager'
|
9
|
-
require 'mock'
|
10
|
-
require 'flexmock'
|
11
8
|
require 'rexml/document'
|
12
9
|
require 'config'
|
10
|
+
require 'mail'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require 'flexmock/minitest'
|
13
|
+
|
14
|
+
Mail.defaults do
|
15
|
+
delivery_method :test
|
16
|
+
end
|
13
17
|
|
14
18
|
module XmlConv
|
15
19
|
module Util
|
16
|
-
|
17
|
-
SMTP_HANDLER = FlexMock.new('SMTP-Handler')
|
18
|
-
end
|
19
|
-
class TestPollingMission < Test::Unit::TestCase
|
20
|
+
class TestPollingMission < ::Minitest::Test
|
20
21
|
def setup
|
21
22
|
@mission = PollingMission.new
|
22
23
|
@dir = File.expand_path('data/i2',
|
@@ -99,7 +100,7 @@ module XmlConv
|
|
99
100
|
}
|
100
101
|
end
|
101
102
|
end
|
102
|
-
class TestPopMission <
|
103
|
+
class TestPopMission < ::Minitest::Test
|
103
104
|
def setup
|
104
105
|
@popserver = TCPServer.new('127.0.0.1', 0)
|
105
106
|
addr = @popserver.addr
|
@@ -194,10 +195,9 @@ module XmlConv
|
|
194
195
|
@popserver.close
|
195
196
|
end
|
196
197
|
end
|
197
|
-
class TestPollingManager <
|
198
|
-
include FlexMock::TestCase
|
198
|
+
class TestPollingManager < ::Minitest::Test
|
199
199
|
def setup
|
200
|
-
@sys =
|
200
|
+
@sys = flexmock('System')
|
201
201
|
@polling = PollingManager.new(@sys)
|
202
202
|
@dir = File.expand_path('data/i2',
|
203
203
|
File.dirname(__FILE__))
|
@@ -5,14 +5,19 @@ $: << File.dirname(__FILE__)
|
|
5
5
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
6
6
|
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
7
7
|
|
8
|
-
require 'test/unit'
|
9
8
|
require 'xmlconv/util/transaction'
|
10
|
-
require '
|
9
|
+
require 'mail'
|
10
|
+
require 'minitest/autorun'
|
11
|
+
require 'flexmock/minitest'
|
12
|
+
|
13
|
+
Mail.defaults do
|
14
|
+
delivery_method :test
|
15
|
+
end
|
11
16
|
|
12
17
|
module XmlConv
|
13
18
|
module Conversion
|
14
19
|
def const_get(symbol)
|
15
|
-
if(symbol.is_a?(
|
20
|
+
if(symbol.is_a?(FlexMock))
|
16
21
|
symbol
|
17
22
|
else
|
18
23
|
super
|
@@ -21,10 +26,7 @@ module XmlConv
|
|
21
26
|
module_function :const_get
|
22
27
|
end
|
23
28
|
module Util
|
24
|
-
|
25
|
-
SMTP_HANDLER = Mock.new('SMTP-Handler')
|
26
|
-
end
|
27
|
-
class TestTransaction < Test::Unit::TestCase
|
29
|
+
class TestTransaction < ::Minitest::Test
|
28
30
|
def setup
|
29
31
|
@transaction = Util::Transaction.new
|
30
32
|
end
|
@@ -47,33 +49,22 @@ module XmlConv
|
|
47
49
|
assert_respond_to(@transaction, :commit_time)
|
48
50
|
end
|
49
51
|
def test_execute
|
50
|
-
src =
|
51
|
-
input =
|
52
|
-
reader =
|
53
|
-
model =
|
54
|
-
writer =
|
55
|
-
output =
|
56
|
-
destination =
|
52
|
+
src = flexmock('source')
|
53
|
+
input = flexmock('input')
|
54
|
+
reader = flexmock('reader')
|
55
|
+
model = flexmock('model')
|
56
|
+
writer = flexmock('writer')
|
57
|
+
output = flexmock('output')
|
58
|
+
destination = flexmock('destination')
|
57
59
|
@transaction.input = src
|
58
60
|
@transaction.reader = reader
|
59
61
|
@transaction.writer = writer
|
60
62
|
@transaction.destination = destination
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
assert_equal(input, read_input)
|
67
|
-
model
|
68
|
-
}
|
69
|
-
writer.__next(:convert) { |write_input|
|
70
|
-
assert_equal(model, write_input)
|
71
|
-
output
|
72
|
-
}
|
73
|
-
destination.__next(:deliver) { |delivery|
|
74
|
-
assert_equal(output, delivery)
|
75
|
-
}
|
76
|
-
destination.__next(:forget_credentials!) { }
|
63
|
+
reader.should_receive(:parse).with(src).once.and_return(input)
|
64
|
+
reader.should_receive(:convert).with(input).once.and_return(model)
|
65
|
+
writer.should_receive(:convert).with(model).once.and_return(output)
|
66
|
+
destination.should_receive(:deliver).with(output).once
|
67
|
+
destination.should_receive(:forget_credentials!).once
|
77
68
|
time1 = Time.now
|
78
69
|
result = @transaction.execute
|
79
70
|
time2 = Time.now
|
@@ -85,45 +76,30 @@ module XmlConv
|
|
85
76
|
assert_equal(output.to_s, result)
|
86
77
|
assert_in_delta(time1, @transaction.start_time, 0.001)
|
87
78
|
assert_in_delta(time2, @transaction.commit_time, 0.001)
|
88
|
-
input.__verify
|
89
|
-
reader.__verify
|
90
|
-
model.__verify
|
91
|
-
writer.__verify
|
92
|
-
output.__verify
|
93
|
-
destination.__verify
|
94
79
|
end
|
95
80
|
def test_persistable
|
96
81
|
assert_kind_of(ODBA::Persistable, @transaction)
|
97
82
|
end
|
98
83
|
def test_dumpable
|
99
|
-
|
84
|
+
Marshal.dump(@transaction)
|
100
85
|
end
|
101
86
|
def test_notify
|
87
|
+
::Mail::TestMailer.deliveries.clear
|
88
|
+
::Mail.defaults do
|
89
|
+
delivery_method :test
|
90
|
+
end
|
102
91
|
@transaction.instance_variable_set('@start_time', Time.now)
|
103
92
|
@transaction.error_recipients = ['bar']
|
104
|
-
smtp = Mail::SMTP_HANDLER
|
105
93
|
@transaction.notify
|
94
|
+
assert_equal(0, ::Mail::TestMailer.deliveries.size)
|
106
95
|
@transaction.debug_recipients = ['foo']
|
107
|
-
mail = Mock.new('MailSession')
|
108
|
-
mail.__next(:sendmail) { |encoded, from, recipients|
|
109
|
-
assert_equal(['foo'], recipients)
|
110
|
-
|
111
|
-
}
|
112
|
-
smtp.__next(:start) { |block, server|
|
113
|
-
block.call(mail)
|
114
|
-
}
|
115
96
|
@transaction.notify
|
97
|
+
assert_equal(1, ::Mail::TestMailer.deliveries.size)
|
98
|
+
assert_equal(['foo'], ::Mail::TestMailer.deliveries.last.to)
|
116
99
|
@transaction.error = 'error!'
|
117
|
-
mail.__next(:sendmail) { |encoded, from, recipients|
|
118
|
-
assert_equal(['foo', 'bar'], recipients)
|
119
|
-
|
120
|
-
}
|
121
|
-
smtp.__next(:start) { |block, server|
|
122
|
-
block.call(mail)
|
123
|
-
}
|
124
100
|
@transaction.notify
|
125
|
-
|
126
|
-
|
101
|
+
assert_equal(2, ::Mail::TestMailer.deliveries.size)
|
102
|
+
assert_equal(['foo', 'bar'], ::Mail::TestMailer.deliveries.last.to)
|
127
103
|
end
|
128
104
|
end
|
129
105
|
end
|
data/xmlconv.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xmlconv/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xmlconv"
|
8
|
+
spec.version = XmlConv::VERSION
|
9
|
+
spec.author = "Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger"
|
10
|
+
spec.email = "mhatakeyama@ywesee.com, zdavatz@ywesee.com, ngiger@ywesee.com"
|
11
|
+
spec.description = "xmlconverter, convert XML to flat files. A Ruby gem"
|
12
|
+
spec.summary = "xmlconverter, convert XML to flat files"
|
13
|
+
spec.homepage = "https://github.com/zdavatz/xmlconv"
|
14
|
+
spec.license = "GPL-v2"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "odba", '>= 1.1.2'
|
21
|
+
spec.add_dependency "ydbd-pg", '>= 0.5.1'
|
22
|
+
spec.add_dependency "ydbi", '>= 0.5.1'
|
23
|
+
spec.add_dependency "json"
|
24
|
+
spec.add_dependency "sbsm"
|
25
|
+
spec.add_dependency "htmlgrid"
|
26
|
+
spec.add_dependency "ydim", '>= 0.5.1'
|
27
|
+
spec.add_dependency "syck"
|
28
|
+
spec.add_dependency "mail"
|
29
|
+
spec.add_dependency "rclconf"
|
30
|
+
spec.add_dependency "needle"
|
31
|
+
spec.add_dependency "ypdf-writer"
|
32
|
+
spec.add_dependency "hpricot"
|
33
|
+
spec.add_runtime_dependency 'deprecated', '= 2.0.1'
|
34
|
+
|
35
|
+
spec.add_runtime_dependency "yus"
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "simplecov"
|
39
|
+
spec.add_development_dependency "rake"
|
40
|
+
spec.add_development_dependency "flexmock"
|
41
|
+
spec.add_development_dependency "minitest"
|
42
|
+
spec.add_development_dependency "minitest-should_syntax"
|
43
|
+
spec.add_development_dependency "rspec"
|
44
|
+
end
|
45
|
+
|