m_manager.storeAttachment( att, makeAttachmentFile() );
att.setAuthor( "FooBar" );
m_manager.storeAttachment( att, makeAttachmentFile() );
Attachment att2 = m_manager.getAttachmentInfo( new WikiContext(m_engine,
new WikiPage(m_engine, NAME1)),
"test1.txt" );
assertNotNull( "attachment disappeared", att2 );
assertEquals( "name", att.getName(), att2.getName() );
assertEquals( "author", att.getAuthor(), att2.getAuthor() );
assertEquals( "version", 2, att2.getVersion() );
InputStream in = m_manager.getAttachmentStream( att2 );
assertNotNull( "stream", in );
StringWriter sout = new StringWriter();
FileUtil.copyContents( new InputStreamReader(in), sout );
in.close();
sout.close();
assertEquals( "contents", c_fileContents, sout.toString() );
//
// Check that first author did not disappear
//
Attachment att3 = m_manager.getAttachmentInfo( new WikiContext(m_engine,
new WikiPage(m_engine, NAME1)),
"test1.txt",
1 );
assertEquals( "version of v1", 1, att3.getVersion() );
assertEquals( "name of v1", "FirstPost", att3.getAuthor() );