testEngine.saveText( PAGE_NAME, "content" );
Attachment att = new Attachment( testEngine, PAGE_NAME, "TestAtt.txt" );
att.setAuthor( "FirstPost" );
testEngine.getAttachmentManager().storeAttachment( att, testEngine.makeAttachmentFile() );
LinkCollector coll = new LinkCollector();
LinkCollector coll_others = new LinkCollector();
String src = "[TestAtt.txt]";
WikiContext context = new WikiContext( testEngine,
new WikiPage(testEngine,PAGE_NAME) );
MarkupParser p = new JSPWikiMarkupParser( context,
new BufferedReader( new StringReader(src)) );
p.addLocalLinkHook( coll_others );
p.addExternalLinkHook( coll_others );
p.addAttachmentLinkHook( coll );
p.parse();
Collection< String > links = coll.getLinks();
assertEquals( "no links found", 1, links.size() );
assertEquals( "wrong link", PAGE_NAME+"/TestAtt.txt",
links.iterator().next() );
assertEquals( "wrong links found", 0, coll_others.getLinks().size() );
}
finally
{
String files = testEngine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
File storagedir = new File( files, PAGE_NAME+BasicAttachmentProvider.DIR_EXTENSION );