Skip to content
This repository
Browse code

Indented as required.

  • Loading branch information...
commit 68fc6baf1b6374f206a33b8035815ce2d5c0ea6f 1 parent 425c892
Arun Agrawal arunagw authored

Showing 1 changed file with 77 additions and 77 deletions. Show diff stats Hide diff stats

  1. +77 77 activesupport/test/xml_mini/jdom_engine_test.rb
154 activesupport/test/xml_mini/jdom_engine_test.rb
@@ -4,35 +4,35 @@
4 4 require 'active_support/core_ext/hash/conversions'
5 5
6 6 class JDOMEngineTest < Test::Unit::TestCase
7   - include ActiveSupport
  7 + include ActiveSupport
8 8
9   - def setup
10   - @default_backend = XmlMini.backend
11   - XmlMini.backend = 'JDOM'
12   - end
  9 + def setup
  10 + @default_backend = XmlMini.backend
  11 + XmlMini.backend = 'JDOM'
  12 + end
13 13
14   - def teardown
15   - XmlMini.backend = @default_backend
16   - end
  14 + def teardown
  15 + XmlMini.backend = @default_backend
  16 + end
17 17
18   - def test_file_from_xml
19   - hash = Hash.from_xml(<<-eoxml)
20   - <blog>
21   - <logo type="file" name="logo.png" content_type="image/png">
22   - </logo>
23   - </blog>
24   - eoxml
25   - assert hash.has_key?('blog')
26   - assert hash['blog'].has_key?('logo')
27   -
28   - file = hash['blog']['logo']
29   - assert_equal 'logo.png', file.original_filename
30   - assert_equal 'image/png', file.content_type
31   - end
  18 + def test_file_from_xml
  19 + hash = Hash.from_xml(<<-eoxml)
  20 + <blog>
  21 + <logo type="file" name="logo.png" content_type="image/png">
  22 + </logo>
  23 + </blog>
  24 + eoxml
  25 + assert hash.has_key?('blog')
  26 + assert hash['blog'].has_key?('logo')
  27 +
  28 + file = hash['blog']['logo']
  29 + assert_equal 'logo.png', file.original_filename
  30 + assert_equal 'image/png', file.content_type
  31 + end
32 32
33   - def test_exception_thrown_on_expansion_attack
34   - assert_raise NativeException do
35   - attack_xml = <<-EOT
  33 + def test_exception_thrown_on_expansion_attack
  34 + assert_raise NativeException do
  35 + attack_xml = <<-EOT
36 36 <?xml version="1.0" encoding="UTF-8"?>
37 37 <!DOCTYPE member [
38 38 <!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
@@ -46,91 +46,91 @@ def test_exception_thrown_on_expansion_attack
46 46 <member>
47 47 &a;
48 48 </member>
49   - EOT
50   - Hash.from_xml(attack_xml)
  49 + EOT
  50 + Hash.from_xml(attack_xml)
  51 + end
51 52 end
52   - end
53 53
54   - def test_setting_JDOM_as_backend
55   - XmlMini.backend = 'JDOM'
56   - assert_equal XmlMini_JDOM, XmlMini.backend
57   - end
  54 + def test_setting_JDOM_as_backend
  55 + XmlMini.backend = 'JDOM'
  56 + assert_equal XmlMini_JDOM, XmlMini.backend
  57 + end
58 58
59   - def test_blank_returns_empty_hash
60   - assert_equal({}, XmlMini.parse(nil))
61   - assert_equal({}, XmlMini.parse(''))
62   - end
  59 + def test_blank_returns_empty_hash
  60 + assert_equal({}, XmlMini.parse(nil))
  61 + assert_equal({}, XmlMini.parse(''))
  62 + end
63 63
64   - def test_array_type_makes_an_array
65   - assert_equal_rexml(<<-eoxml)
  64 + def test_array_type_makes_an_array
  65 + assert_equal_rexml(<<-eoxml)
66 66 <blog>
67 67 <posts type="array">
68 68 <post>a post</post>
69 69 <post>another post</post>
70 70 </posts>
71 71 </blog>
72   - eoxml
73   - end
  72 + eoxml
  73 + end
74 74
75   - def test_one_node_document_as_hash
76   - assert_equal_rexml(<<-eoxml)
  75 + def test_one_node_document_as_hash
  76 + assert_equal_rexml(<<-eoxml)
77 77 <products/>
78   - eoxml
79   - end
  78 + eoxml
  79 + end
80 80
81   - def test_one_node_with_attributes_document_as_hash
82   - assert_equal_rexml(<<-eoxml)
  81 + def test_one_node_with_attributes_document_as_hash
  82 + assert_equal_rexml(<<-eoxml)
83 83 <products foo="bar"/>
84   - eoxml
85   - end
  84 + eoxml
  85 + end
86 86
87   - def test_products_node_with_book_node_as_hash
88   - assert_equal_rexml(<<-eoxml)
  87 + def test_products_node_with_book_node_as_hash
  88 + assert_equal_rexml(<<-eoxml)
89 89 <products>
90 90 <book name="awesome" id="12345" />
91 91 </products>
92   - eoxml
93   - end
  92 + eoxml
  93 + end
94 94
95   - def test_products_node_with_two_book_nodes_as_hash
96   - assert_equal_rexml(<<-eoxml)
  95 + def test_products_node_with_two_book_nodes_as_hash
  96 + assert_equal_rexml(<<-eoxml)
97 97 <products>
98 98 <book name="awesome" id="12345" />
99 99 <book name="america" id="67890" />
100 100 </products>
101   - eoxml
102   - end
  101 + eoxml
  102 + end
103 103
104   - def test_single_node_with_content_as_hash
105   - assert_equal_rexml(<<-eoxml)
  104 + def test_single_node_with_content_as_hash
  105 + assert_equal_rexml(<<-eoxml)
106 106 <products>
107 107 hello world
108 108 </products>
109   - eoxml
110   - end
  109 + eoxml
  110 + end
111 111
112   - def test_children_with_children
113   - assert_equal_rexml(<<-eoxml)
  112 + def test_children_with_children
  113 + assert_equal_rexml(<<-eoxml)
114 114 <root>
115 115 <products>
116 116 <book name="america" id="67890" />
117 117 </products>
118 118 </root>
119   - eoxml
120   - end
  119 + eoxml
  120 + end
121 121
122   - def test_children_with_text
123   - assert_equal_rexml(<<-eoxml)
  122 + def test_children_with_text
  123 + assert_equal_rexml(<<-eoxml)
124 124 <root>
125 125 <products>
126 126 hello everyone
127 127 </products>
128 128 </root>
129   - eoxml
130   - end
  129 + eoxml
  130 + end
131 131
132   - def test_children_with_non_adjacent_text
133   - assert_equal_rexml(<<-eoxml)
  132 + def test_children_with_non_adjacent_text
  133 + assert_equal_rexml(<<-eoxml)
134 134 <root>
135 135 good
136 136 <products>
@@ -138,15 +138,15 @@ def test_children_with_non_adjacent_text
138 138 </products>
139 139 morning
140 140 </root>
141   - eoxml
142   - end
  141 + eoxml
  142 + end
143 143
144   - private
145   - def assert_equal_rexml(xml)
146   - hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
147   - assert_equal(hash, XmlMini.parse(xml))
  144 + private
  145 + def assert_equal_rexml(xml)
  146 + hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
  147 + assert_equal(hash, XmlMini.parse(xml))
  148 + end
148 149 end
149   -end
150 150
151 151 else
152 152 # don't run these test because we aren't running in JRuby

0 comments on commit 68fc6ba

Please sign in to comment.
Something went wrong with that request. Please try again.