@Test
public void testEmbedDataSource() throws Exception
{
final File tmpFile = File.createTempFile("testEmbedDataSource", "txt");
tmpFile.deleteOnExit();
final FileDataSource dataSource = new FileDataSource(tmpFile);
// does embedding a datasource without a name fail?
try
{
this.email.embed(dataSource, "");
fail("embedding with an empty string for a name should fail");
}
catch (final EmailException e)
{
// expected
}
// properly embed the datasource
final String cid = this.email.embed(dataSource, "testname");
// does embedding the same datasource under the same name return
// the original cid?
final String sameCid = this.email.embed(dataSource, "testname");
assertEquals("didn't get same CID for embedding same datasource twice",
cid, sameCid);
// does embedding another datasource under the same name fail?
final File anotherFile = File.createTempFile("testEmbedDataSource2", "txt");
anotherFile.deleteOnExit();
final FileDataSource anotherDS = new FileDataSource(anotherFile);
try
{
this.email.embed(anotherDS, "testname");
}
catch (final EmailException e)