@@ -110,7 +110,7 @@ public void shouldAddNamespaceToRootElement() {
110110 }
111111
112112 @ Test
113- public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespace () {
113+ public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespaceToRootTag () {
114114 final Map <String , String > namespaces = new HashMap <String , String >();
115115 namespaces .put ("" , "http://example.org/ns" );
116116 simpleXmlEncoder .setNamespaces (namespaces );
@@ -121,6 +121,16 @@ public void shouldAddNamespaceWithEmptyKeyAsDefaultNamespace() {
121121 getResultXml ());
122122 }
123123
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+
124134 @ Test
125135 public void shouldNotEmitRootTagIfWriteRootTagIsFalse () {
126136 simpleXmlEncoder .setWriteRootTag (false );
@@ -144,6 +154,30 @@ public void shouldAddNamespacesToRecordTagIfWriteRootTagIsFalse() {
144154 getResultXml ());
145155 }
146156
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+
147181 private void emitTwoRecords () {
148182 simpleXmlEncoder .startRecord ("X" );
149183 simpleXmlEncoder .literal (TAG , VALUE );
0 commit comments