@@ -110,7 +110,7 @@ public void shouldAddNamespaceToRootElement() {
110
110
}
111
111
112
112
@ Test
113
- public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespace () {
113
+ public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespaceToRootTag () {
114
114
final Map <String , String > namespaces = new HashMap <String , String >();
115
115
namespaces .put ("" , "http://example.org/ns" );
116
116
simpleXmlEncoder .setNamespaces (namespaces );
@@ -121,6 +121,16 @@ public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespace() {
121
121
getResultXml ());
122
122
}
123
123
124
+ @ Test
125
+ public void shouldAddNamespaceWithEmptyKeyFromPropertiesFileAsDefaultNamespaceToRootTag () {
126
+ simpleXmlEncoder .setNamespaceFile ("org/metafacture/xml/SimpleXmlEncoderTest_namespaces.properties" );
127
+
128
+ emitEmptyRecord ();
129
+
130
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><records xmlns=\" http://example.org/ns\" ><record /></records>" ,
131
+ getResultXml ());
132
+ }
133
+
124
134
@ Test
125
135
public void shouldNotEmitRootTagIfWriteRootTagIsFalse () {
126
136
simpleXmlEncoder .setWriteRootTag (false );
@@ -144,6 +154,30 @@ public void shouldAddNamespacesToRecordTagIfWriteRootTagIsFalse() {
144
154
getResultXml ());
145
155
}
146
156
157
+ @ Test
158
+ public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespaceToRecordTag () {
159
+ final Map <String , String > namespaces = new HashMap <String , String >();
160
+ namespaces .put ("" , "http://example.org/ns" );
161
+ simpleXmlEncoder .setNamespaces (namespaces );
162
+ simpleXmlEncoder .setWriteRootTag (false );
163
+
164
+ emitEmptyRecord ();
165
+
166
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><record xmlns=\" http://example.org/ns\" />" ,
167
+ getResultXml ());
168
+ }
169
+
170
+ @ Test
171
+ public void shouldAddNamespaceWithEmptyKeyFromPropertiesFileAsDefaultNamespaceToRecordTag () {
172
+ simpleXmlEncoder .setNamespaceFile ("org/metafacture/xml/SimpleXmlEncoderTest_namespaces.properties" );
173
+ simpleXmlEncoder .setWriteRootTag (false );
174
+
175
+ emitEmptyRecord ();
176
+
177
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><record xmlns=\" http://example.org/ns\" />" ,
178
+ getResultXml ());
179
+ }
180
+
147
181
private void emitTwoRecords () {
148
182
simpleXmlEncoder .startRecord ("X" );
149
183
simpleXmlEncoder .literal (TAG , VALUE );
0 commit comments