use of org.apache.wiki.api.core.Attachment in project jspwiki by apache.
the class DefaultPageManagerTest method testDeletePageAndAttachments.
@Test
public void testDeletePageAndAttachments() throws Exception {
engine.saveText(NAME1, "Test");
final Attachment att = Wiki.contents().attachment(engine, NAME1, "TestAtt.txt");
att.setAuthor("FirstPost");
engine.getManager(AttachmentManager.class).storeAttachment(att, engine.makeAttachmentFile());
final String files = engine.getWikiProperties().getProperty(FileSystemProvider.PROP_PAGEDIR);
final File saved = new File(files, NAME1 + FileSystemProvider.FILE_EXT);
final String atts = engine.getWikiProperties().getProperty(AttachmentProvider.PROP_STORAGEDIR);
final File attfile = new File(atts, NAME1 + "-att/TestAtt.txt-dir");
Assertions.assertTrue(saved.exists(), "Didn't create it!");
Assertions.assertTrue(attfile.exists(), "Attachment dir does not exist");
final Page page = engine.getManager(PageManager.class).getPage(NAME1, WikiProvider.LATEST_VERSION);
engine.getManager(PageManager.class).deletePage(page.getName());
Assertions.assertFalse(saved.exists(), "Page has not been removed!");
Assertions.assertFalse(attfile.exists(), "Attachment has not been removed");
}
use of org.apache.wiki.api.core.Attachment in project jspwiki by apache.
the class JSPWikiMarkupParserTest method testAttachmentLink3.
/**
* Are attachments parsed correctly also when using gappy text?
*/
@Test
public void testAttachmentLink3() throws Exception {
final TestEngine testEngine2 = TestEngine.build();
testEngine2.saveText("TestPage", "foo ");
created.addElement("TestPage");
final Attachment att = Wiki.contents().attachment(testEngine2, "TestPage", "TestAtt.txt");
att.setAuthor("FirstPost");
testEngine2.getManager(AttachmentManager.class).storeAttachment(att, testEngine.makeAttachmentFile());
final String src = "[Test page/TestAtt.txt]";
Assertions.assertEquals("<a class=\"attachment\" href=\"/test/attach/TestPage/TestAtt.txt\">Test page/TestAtt.txt</a>" + "<a href=\"/test/PageInfo.jsp?page=TestPage/TestAtt.txt\" class=\"infolink\"><img src=\"/test/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>", translate(testEngine2, src));
}
use of org.apache.wiki.api.core.Attachment in project jspwiki by apache.
the class JSPWikiMarkupParserTest method testAttachmentLink2.
@Test
public void testAttachmentLink2() throws Exception {
final TestEngine testEngine2 = TestEngine.build(with("jspwiki.encoding", StandardCharsets.ISO_8859_1.name()));
testEngine2.saveText("Test", "foo ");
created.addElement("Test");
final Attachment att = Wiki.contents().attachment(testEngine2, "Test", "TestAtt.txt");
att.setAuthor("FirstPost");
testEngine2.getManager(AttachmentManager.class).storeAttachment(att, testEngine.makeAttachmentFile());
final String src = "This should be an [attachment link|Test/TestAtt.txt]";
Assertions.assertEquals("This should be an <a class=\"attachment\" href=\"/test/attach/Test/TestAtt.txt\">attachment link</a>" + "<a href=\"/test/PageInfo.jsp?page=Test/TestAtt.txt\" class=\"infolink\"><img src=\"/test/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>", translate(testEngine2, src));
}
use of org.apache.wiki.api.core.Attachment in project jspwiki by apache.
the class JSPWikiMarkupParserTest method testAttachmentLink4.
@Test
public void testAttachmentLink4() throws Exception {
final TestEngine testEngine2 = TestEngine.build();
testEngine2.saveText("TestPage", "foo ");
created.addElement("TestPage");
final Attachment att = Wiki.contents().attachment(testEngine2, "TestPage", "TestAtt.txt");
att.setAuthor("FirstPost");
testEngine2.getManager(AttachmentManager.class).storeAttachment(att, testEngine.makeAttachmentFile());
final String src = "[" + testEngine2.getManager(RenderingManager.class).beautifyTitle("TestPage/TestAtt.txt") + "]";
Assertions.assertEquals("<a class=\"attachment\" href=\"/test/attach/TestPage/TestAtt.txt\">Test Page/TestAtt.txt</a>" + "<a href=\"/test/PageInfo.jsp?page=TestPage/TestAtt.txt\" class=\"infolink\"><img src=\"/test/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>", translate(testEngine2, src));
}
use of org.apache.wiki.api.core.Attachment in project jspwiki by apache.
the class BasicAttachmentProviderTest method testPutAttachmentUTF8.
/**
* Can we save attachments with names in UTF-8 range?
*/
@Test
public void testPutAttachmentUTF8() throws Exception {
final File in = makeAttachmentFile();
final Attachment att = Wiki.contents().attachment(m_engine, NAME1, "\u3072\u3048\u308b\u00e5\u00e4\u00f6test.f\u00fc\u00fc");
m_provider.putAttachmentData(att, new FileInputStream(in));
final List<Attachment> res = m_provider.listAllChanged(new Date(0L));
final Attachment a0 = res.get(0);
Assertions.assertEquals(att.getName(), a0.getName(), "name");
}
Aggregations