01: package com.ecyrd.jspwiki.dav;
02:
03: import java.util.Properties;
04:
05: import com.ecyrd.jspwiki.TestEngine;
06: import com.ecyrd.jspwiki.attachment.Attachment;
07: import com.ecyrd.jspwiki.dav.items.DavItem;
08: import com.ecyrd.jspwiki.dav.items.DirectoryItem;
09:
10: import junit.framework.Test;
11: import junit.framework.TestCase;
12: import junit.framework.TestSuite;
13:
14: public class AttachmentDavProviderTest extends TestCase {
15: Properties props = new Properties();
16:
17: TestEngine engine;
18:
19: AttachmentDavProvider m_provider;
20:
21: protected void setUp() throws Exception {
22: props.load(TestEngine.findTestProperties());
23:
24: engine = new TestEngine(props);
25:
26: m_provider = new AttachmentDavProvider(engine);
27: }
28:
29: protected void tearDown() throws Exception {
30: engine.deleteAttachments("TestPage");
31: TestEngine.deleteTestPage("TestPage");
32: }
33:
34: public void testGetPageURL() throws Exception {
35: engine.saveText("TestPage", "foobar");
36: Attachment att = new Attachment(engine, "TestPage",
37: "deceit of the tribbles.txt");
38:
39: engine.getAttachmentManager().storeAttachment(att,
40: engine.makeAttachmentFile());
41:
42: DavItem di = m_provider.getItem(new DavPath(
43: "TestPage/deceit of the tribbles.txt"));
44:
45: assertNotNull("No di", di);
46: assertEquals(
47: "URL",
48: "http://localhost/attach/TestPage/deceit+of+the+tribbles.txt",
49: di.getHref());
50: }
51:
52: public void testDirURL() throws Exception {
53: engine.saveText("TestPage", "foobar");
54:
55: DavItem di = m_provider.getItem(new DavPath(""));
56:
57: assertNotNull("No di", di);
58: assertTrue("DI is of wrong type", di instanceof DirectoryItem);
59: assertEquals("URL", "http://localhost/attach/", di.getHref());
60: }
61:
62: public void testDirURL2() throws Exception {
63: engine.saveText("TestPage", "foobar");
64:
65: DavItem di = m_provider.getItem(new DavPath("TestPage/"));
66:
67: assertNotNull("No di", di);
68: assertTrue("DI is of wrong type", di instanceof DirectoryItem);
69: assertEquals("URL", "http://localhost/attach/TestPage/", di
70: .getHref());
71: }
72:
73: public static Test suite() {
74: return new TestSuite(RawPagesDavProviderTest.class);
75: }
76:
77: }
|