PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Ice/AMIS6.0/test_SNMEX.rb

http://rubyforjason.googlecode.com/
Ruby | 408 lines | 298 code | 79 blank | 31 comment | 0 complexity | fe89a752eccd32a5b51558a0cb6bd38c MD5 | raw file
  1. require 'SNMEX.rb'
  2. require 'test/unit'
  3. class Test_SNMEX < Test::Unit::TestCase
  4. def setup
  5. puts "========================Setup===================================================="
  6. @client = Snm.new()
  7. @map = {
  8. "maintitle"=>"????",
  9. "subtitle"=>"???????",
  10. "sendtime"=>"20101231235959",
  11. "displaymode"=>"1",
  12. "message"=>"<html><head><title>asdfas</title></head><body><h1>???????</h1></body></html>"
  13. }
  14. end
  15. def teardown
  16. puts "========================Teardown===================================================="
  17. end
  18. ## strCaller is null
  19. def test_case1
  20. @client.strCaller = ""
  21. @client.strServiceType = "strType"
  22. @client.strToId = "cntaobao??"
  23. @client.strMessage = '20100104102600||titile||message'
  24. @client.saveType = 1
  25. @client.htmlMsg = @map
  26. puts rsp = @client.main(ARGV)
  27. assert_equal(20201,rsp[0])
  28. assert_equal("caller length error[9,64]",rsp[1])
  29. end
  30. ## strServiceType is null
  31. def test_case2
  32. @client.strCaller = "cnalichnsaintester"
  33. @client.strServiceType = ""
  34. @client.strToId = "cntaobao??"
  35. @client.strMessage = '20100104102600||titile||message'
  36. @client.saveType = 1
  37. @client.htmlMsg = @map
  38. puts rsp = @client.main(ARGV)
  39. assert_equal(20202,rsp[0])
  40. assert_equal("service type length error[9,64]",rsp[1])
  41. end
  42. ## strToId is null
  43. def test_case3
  44. @client.strCaller = "cnalichnsaintester"
  45. @client.strServiceType = "strType"
  46. @client.strToId = ""
  47. @client.strMessage = '20100104102600||titile||message'
  48. @client.saveType = 1
  49. @client.htmlMsg = @map
  50. puts rsp = @client.main(ARGV)
  51. assert_equal(20101,rsp[0])
  52. assert_equal("longId length error[9,128]",rsp[1])
  53. end
  54. ## strMessage is null
  55. def test_case4
  56. @client.strCaller = "cnalichnsaintester"
  57. @client.strServiceType = "strType"
  58. @client.strToId = "cntaobao??"
  59. @client.strMessage = ''
  60. @client.saveType = 1
  61. @client.htmlMsg = @map
  62. puts rsp = @client.main(ARGV)
  63. assert_equal(20000,rsp[0])
  64. assert_equal("normal parameter error",rsp[1])
  65. end
  66. ## htmlMsg is null
  67. def test_case5
  68. nullmap = {}
  69. @client.strCaller = "cnalichnsaintester"
  70. @client.strServiceType = "strType"
  71. @client.strToId = "cntaobao??"
  72. @client.strMessage = '20100104102600||titile||message'
  73. @client.saveType = 1
  74. @client.htmlMsg = nullmap
  75. puts rsp = @client.main(ARGV)
  76. assert_equal(20000,rsp[0])
  77. assert_equal("normal parameter error",rsp[1])
  78. end
  79. ## strCaller length = 8
  80. def test_case6
  81. @client.strCaller = "12345678"
  82. @client.strServiceType = "strType"
  83. @client.strToId = "cntaobao??"
  84. @client.strMessage = '20100104102600||titile||message'
  85. @client.saveType = 1
  86. @client.htmlMsg = @map
  87. puts rsp = @client.main(ARGV)
  88. assert_equal(20201,rsp[0])
  89. assert_equal("caller length error[9,64]",rsp[1])
  90. end
  91. ## strCaller length = 9
  92. def test_case7
  93. @client.strCaller = "123456789"
  94. @client.strServiceType = "strType"
  95. @client.strToId = "cntaobao??"
  96. @client.strMessage = '20100104102600||titile||message'
  97. @client.saveType = 1
  98. @client.htmlMsg = @map
  99. puts rsp = @client.main(ARGV)
  100. assert_equal(10000,rsp[0])
  101. assert_equal("successfully",rsp[1])
  102. end
  103. ## strCaller length = 64
  104. def test_case8
  105. @client.strCaller = "0123456789012345678901234567890123456789012345678901234567890123"
  106. @client.strServiceType = "strType"
  107. @client.strToId = "cntaobao??"
  108. @client.strMessage = '20100104102600||titile||message'
  109. @client.saveType = 1
  110. @client.htmlMsg = @map
  111. puts rsp = @client.main(ARGV)
  112. assert_equal(10000,rsp[0])
  113. assert_equal("successfully",rsp[1])
  114. end
  115. ## strCaller length = 65
  116. def test_case9
  117. @client.strCaller = "01234567890123456789012345678901234567890123456789012345678901234"
  118. @client.strServiceType = "strType"
  119. @client.strToId = "cntaobao??"
  120. @client.strMessage = '20100104102600||titile||message'
  121. @client.saveType = 1
  122. @client.htmlMsg = @map
  123. puts rsp = @client.main(ARGV)
  124. assert_equal(20201,rsp[0])
  125. assert_equal("caller length error[9,64]",rsp[1])
  126. end
  127. ## strServiceType length = 3
  128. def test_case10
  129. map = {
  130. "maintitle"=>"????",
  131. "subtitle"=>"???????",
  132. "sendtime"=>"20101231235959",
  133. "displaymode"=>"1",
  134. "message"=>"<html><head><title>asdfas</title></head><body><h1>???????</h1></body></html>"
  135. }
  136. @client.strCaller = "cnalichnsaintester"
  137. @client.strServiceType = "012"
  138. @client.strToId = "cntaobao??"
  139. @client.strMessage = '20100104102600||titile||message'
  140. @client.saveType = 1
  141. @client.htmlMsg = map
  142. puts rsp = @client.main(ARGV)
  143. assert_equal(20202,rsp[0])
  144. assert_equal("service type length error[9,64]",rsp[1])
  145. end
  146. ## strServiceType length = 4 ??????????[4,64] ???????? ????[9,64]
  147. def test_case11
  148. @client.strCaller = "cnalichnsaintester"
  149. @client.strServiceType = "0123"
  150. @client.strToId = "cntaobao??"
  151. @client.strMessage = '20100104102600||titile||message'
  152. @client.saveType = 1
  153. @client.htmlMsg = @map
  154. puts rsp = @client.main(ARGV)
  155. assert_equal(10000,rsp[0])
  156. assert_equal("successfully",rsp[1])
  157. end
  158. ## strServiceType length = 64
  159. def test_case12
  160. @client.strCaller = "cnalichnsaintester"
  161. @client.strServiceType = "0123456789012345678901234567890123456789012345678901234567890123"
  162. @client.strToId = "cntaobao??"
  163. @client.strMessage = '20100104102600||titile||message'
  164. @client.saveType = 1
  165. @client.htmlMsg = @map
  166. puts rsp = @client.main(ARGV)
  167. assert_equal(10000,rsp[0])
  168. assert_equal("successfully",rsp[1])
  169. end
  170. ## strServiceType length = 65
  171. def test_case13
  172. @client.strCaller = "cnalichnsaintester"
  173. @client.strServiceType = "01234567890123456789012345678901234567890123456789012345678901234"
  174. @client.strToId = "cntaobao??"
  175. @client.strMessage = '20100104102600||titile||message'
  176. @client.saveType = 1
  177. @client.htmlMsg = @map
  178. puts rsp = @client.main(ARGV)
  179. assert_equal(20202,rsp[0])
  180. assert_equal("service type length error[9,64]",rsp[1])
  181. end
  182. ## strToId length = 8
  183. def test_case14
  184. @client.strCaller = "cnalichnsaintester"
  185. @client.strServiceType = "strType"
  186. @client.strToId = "cntaobao"
  187. @client.strMessage = '20100104102600||titile||message'
  188. @client.saveType = 1
  189. @client.htmlMsg = @map
  190. puts rsp = @client.main(ARGV)
  191. assert_equal(20101,rsp[0])
  192. assert_equal("longId length error[9,128]",rsp[1])
  193. end
  194. ## strToId length = 9
  195. def test_case15
  196. @client.strCaller = "cnalichnsaintester"
  197. @client.strServiceType = "strType"
  198. @client.strToId = "cntaobao1"
  199. @client.strMessage = '20100104102600||titile||message'
  200. @client.saveType = 1
  201. @client.htmlMsg = @map
  202. puts rsp = @client.main(ARGV)
  203. assert_equal(10000,rsp[0])
  204. assert_equal("successfully",rsp[1])
  205. end
  206. ## strToId length = 128
  207. def test_case16
  208. @client.strCaller = "cnalichnsaintester"
  209. @client.strServiceType = "strType"
  210. @client.strToId = "cntaobao012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
  211. @client.strMessage = '20100104102600||titile||message'
  212. @client.saveType = 1
  213. @client.htmlMsg = @map
  214. puts rsp = @client.main(ARGV)
  215. assert_equal(10000,rsp[0])
  216. assert_equal("successfully",rsp[1])
  217. end
  218. ## strToId length = 129
  219. def test_case17
  220. @client.strCaller = "cnalichnsaintester"
  221. @client.strServiceType = "strType"
  222. @client.strToId = "cntaobao0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
  223. @client.strMessage = '20100104102600||titile||message'
  224. @client.saveType = 1
  225. @client.htmlMsg = @map
  226. puts rsp = @client.main(ARGV)
  227. assert_equal(20101,rsp[0])
  228. assert_equal("longId length error[9,128]",rsp[1])
  229. end
  230. ## strMessage length = 17
  231. def test_case18
  232. @client.strCaller = "cnalichnsaintester"
  233. @client.strServiceType = "strType"
  234. @client.strToId = "cntaobao??"
  235. @client.strMessage = '20100104102600|||'
  236. @client.saveType = 1
  237. @client.htmlMsg = @map
  238. puts rsp = @client.main(ARGV)
  239. assert_equal(20000,rsp[0])
  240. assert_equal("normal parameter error",rsp[1])
  241. end
  242. ## strMessage length = 18
  243. def test_case19
  244. @client.strCaller = "cnalichnsaintester"
  245. @client.strServiceType = "strType"
  246. @client.strToId = "cntaobao??"
  247. @client.strMessage = '20100104102600||||'
  248. @client.saveType = 1
  249. @client.htmlMsg = @map
  250. puts rsp = @client.main(ARGV)
  251. assert_equal(10000,rsp[0])
  252. assert_equal("successfully",rsp[1])
  253. end
  254. ## saveType = 0 ----do not save offline message
  255. def test_case20
  256. @client.strCaller = "cnalichnsaintester"
  257. @client.strServiceType = "strType"
  258. @client.strToId = "cntaobao??"
  259. @client.strMessage = '20100104102600||titile||message'
  260. @client.saveType = 0
  261. @client.htmlMsg = @map
  262. puts rsp = @client.main(ARGV)
  263. assert_equal(10000,rsp[0])
  264. assert_equal("successfully",rsp[1])
  265. end
  266. ## saveType = 1 ----save offline message
  267. def test_case21
  268. @client.strCaller = "cnalichnsaintester"
  269. @client.strServiceType = "strType"
  270. @client.strToId = "cntaobao??"
  271. @client.strMessage = '20100104102600||titile||message'
  272. @client.saveType = 1
  273. @client.htmlMsg = @map
  274. puts rsp = @client.main(ARGV)
  275. assert_equal(10000,rsp[0])
  276. assert_equal("successfully",rsp[1])
  277. end
  278. ## saveType = 3 ----save offline message
  279. def test_case22
  280. @client.strCaller = "cnalichnsaintester"
  281. @client.strServiceType = "strType"
  282. @client.strToId = "cntaobao??"
  283. @client.strMessage = '20100104102600||titile||message'
  284. @client.saveType = 3
  285. @client.htmlMsg = @map
  286. puts rsp = @client.main(ARGV)
  287. assert_equal(10000,rsp[0])
  288. assert_equal("successfully",rsp[1])
  289. end
  290. ## htmlMsg size=2K
  291. def test_case23
  292. map = {
  293. "01234567890123456789aaaa" =>"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
  294. "01234567890123456789bbbb" =>"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
  295. }
  296. @client.strCaller = "cnalichnsaintester"
  297. @client.strServiceType = "strType"
  298. @client.strToId = "cntaobao??"
  299. @client.strMessage = '20100104102600||titile||message'
  300. @client.saveType = 1
  301. @client.htmlMsg = map
  302. puts rsp = @client.main(ARGV)
  303. assert_equal(10000,rsp[0])
  304. assert_equal("successfully",rsp[1])
  305. end
  306. ## htmlMsg size>2K
  307. def test_case24
  308. map = {
  309. "01234567890123456789aaaa" =>"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
  310. "01234567890123456789bbbbc" =>"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
  311. }
  312. @client.strCaller = "cnalichnsaintester"
  313. @client.strServiceType = "strType"
  314. @client.strToId = "cntaobao??"
  315. @client.strMessage = '20100104102600||titile||message'
  316. @client.saveType = 1
  317. @client.htmlMsg = map
  318. puts rsp = @client.main(ARGV)
  319. assert_equal(20000,rsp[0])
  320. assert_equal("normal parameter error",rsp[1])
  321. end
  322. end
  323. #~ @client.strCaller = "cnalichnsaintester"
  324. #~ @client.strServiceType = "strType"
  325. #~ @client.strToId = "cntaobao??"
  326. #~ @client.strMessage = '20100104102600||titile||message'
  327. #~ @client.saveType = 1
  328. #~ @client.htmlMsg = @map
  329. #~ puts rsp = @client.main(ARGV)