@@ -49,6 +49,10 @@ public class SerializationTest {
49
49
"<!DOCTYPE bookmap PUBLIC \" -//OASIS//DTD DITA BookMap//EN\" \" bookmap.dtd\" >\n " +
50
50
"<bookmap id=\" bookmap-1\" />" ;
51
51
52
+ private static final String XML_WITH_XMLDECL =
53
+ "<?xml version=\" 1.1\" encoding=\" ISO-8859-1\" standalone=\" yes\" ?>\n " +
54
+ "<bookmap id=\" bookmap-2\" />" ;
55
+
52
56
private static String PREV_PROPFIND_METHOD_XML_SIZE = null ;
53
57
54
58
@ ClassRule
@@ -103,4 +107,37 @@ public void getDocTypeDefault() throws IOException, NotAuthorizedException, BadR
103
107
resource .downloadTo (tempRetrieveFile , null );
104
108
assertEquals (XML_WITH_DOCTYPE , new String (Files .readAllBytes (tempRetrieveFile .toPath ()), UTF_8 ));
105
109
}
110
+
111
+ @ Test
112
+ public void getXmlDeclDefault () throws IOException , NotAuthorizedException , BadRequestException , HttpException , ConflictException , NotFoundException {
113
+ final String docName = "test-with-xmldecl.xml" ;
114
+ final HostBuilder builder = new HostBuilder ();
115
+ builder .setServer ("localhost" );
116
+ final int port = EXIST_WEB_SERVER .getPort ();
117
+ builder .setPort (port );
118
+ builder .setRootPath ("webdav/db" );
119
+ final Host host = builder .buildHost ();
120
+
121
+ // workaround pre-emptive auth issues of Milton Client
122
+ final AbstractHttpClient httpClient = (AbstractHttpClient )host .getClient ();
123
+ httpClient .addRequestInterceptor (new AlwaysBasicPreAuth (TestUtils .ADMIN_DB_USER , TestUtils .ADMIN_DB_PWD ));
124
+
125
+ final Folder folder = host .getFolder ("/" );
126
+ assertNotNull (folder );
127
+
128
+ // store document
129
+ final byte data [] = XML_WITH_XMLDECL .getBytes (UTF_8 );
130
+ final java .io .File tmpStoreFile = TEMP_FOLDER .newFile ();
131
+ Files .write (tmpStoreFile .toPath (), data );
132
+ assertNotNull (folder .uploadFile (docName , tmpStoreFile , null ));
133
+
134
+ // retrieve document
135
+ final Resource resource = folder .child (docName );
136
+ assertNotNull (resource );
137
+ assertTrue (resource instanceof File );
138
+ assertEquals ("application/xml" , ((File ) resource ).contentType );
139
+ final java .io .File tempRetrieveFile = TEMP_FOLDER .newFile ();
140
+ resource .downloadTo (tempRetrieveFile , null );
141
+ assertEquals ("<bookmap id=\" bookmap-2\" />" , new String (Files .readAllBytes (tempRetrieveFile .toPath ()), UTF_8 ));
142
+ }
106
143
}
0 commit comments