use of org.alfresco.repo.content.filestore.SpoofedTextContentReader in project alfresco-remote-api by Alfresco.
the class RemoteFileFolderLoaderTest method testLoad_15_16bytes.
/**
* Load 15 files; 1K size; 1 document sample; force binary storage
*/
@SuppressWarnings("unchecked")
public void testLoad_15_16bytes() throws Exception {
JSONObject body = new JSONObject();
body.put(FileFolderLoaderPost.KEY_FOLDER_PATH, loadHomePath);
body.put(FileFolderLoaderPost.KEY_MIN_FILE_SIZE, 16L);
body.put(FileFolderLoaderPost.KEY_MAX_FILE_SIZE, 16L);
body.put(FileFolderLoaderPost.KEY_MAX_UNIQUE_DOCUMENTS, 1L);
body.put(FileFolderLoaderPost.KEY_FORCE_BINARY_STORAGE, Boolean.TRUE);
Response response = null;
try {
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser("maggi");
response = sendRequest(new PostRequest(URL, body.toString(), "application/json"), Status.STATUS_OK, "maggi");
} finally {
AuthenticationUtil.popAuthentication();
}
assertEquals("{\"count\":100}", response.getContentAsString());
// Check file(s)
assertEquals(100, nodeService.countChildAssocs(loadHomeNodeRef, true));
// Consistent binary text
String contentUrlCheck = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 16L);
ContentReader readerCheck = new SpoofedTextContentReader(contentUrlCheck);
String textCheck = readerCheck.getContentString();
// Size should be default
List<FileInfo> fileInfos = fileFolderService.list(loadHomeNodeRef);
for (FileInfo fileInfo : fileInfos) {
NodeRef fileNodeRef = fileInfo.getNodeRef();
ContentReader reader = fileFolderService.getReader(fileNodeRef);
// Expect storage in store
assertTrue(reader.getContentUrl().startsWith(FileContentStore.STORE_PROTOCOL));
// Check text
String text = reader.getContentString();
assertEquals("Text not the same.", textCheck, text);
}
}
Aggregations