final WriteableDocumentBundle docBundle = new MemoryDocumentBundle();
// Create a temp file for processing purposes
final File tempFile = File.createTempFile("junit", "tmp");
tempFile.deleteOnExit();
final ResourceKey tempKey = resourceManager.createKey(tempFile);
// Add the temp file to the bundle
final ResourceKey result = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", null);
assertNotNull(result);
assertTrue(result.getIdentifierAsString().startsWith("test/testfile-"));
assertTrue(docBundle.isEntryExists(result.getIdentifierAsString()));
// Add the file again, and set some factory parameters
final Map factoryParameters = new HashMap();
factoryParameters.put("this", "that");
final ResourceKey result2 = WriteableDocumentBundleUtils.embedResource(docBundle, resourceManager, tempKey, "test/testfile-{0}.tmp", "application/data", factoryParameters);
assertNotNull(result2);
assertTrue(result2.getIdentifierAsString().startsWith("test/testfile-"));
assertTrue(docBundle.isEntryExists(result2.getIdentifierAsString()));
assertNotNull(result2.getFactoryParameters());
assertEquals(1, result2.getFactoryParameters().size());
assertTrue(result2.getFactoryParameters().containsKey("this"));
}