Source Code Cross Referenced for CachingProviderTest.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » providers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.providers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package com.ecyrd.jspwiki.providers;
02:
03:        import junit.framework.*;
04:
05:        import java.io.FileWriter;
06:        import java.io.PrintWriter;
07:        import java.io.File;
08:        import java.io.StringReader;
09:        import java.util.*;
10:
11:        import org.apache.log4j.*;
12:
13:        import com.ecyrd.jspwiki.*;
14:
15:        public class CachingProviderTest extends TestCase {
16:            public CachingProviderTest(String s) {
17:                super (s);
18:            }
19:
20:            public void setUp() throws Exception {
21:                TestEngine.emptyWorkDir();
22:
23:                Properties props2 = new Properties();
24:
25:                props2.load(TestEngine.findTestProperties());
26:                PropertyConfigurator.configure(props2);
27:            }
28:
29:            public void tearDown() {
30:                TestEngine.emptyWorkDir();
31:                TestEngine.deleteTestPage("Testi");
32:            }
33:
34:            /**
35:             *  Checks that at startup we call the provider once, and once only.
36:             */
37:            public void testInitialization() throws Exception {
38:                Properties props = new Properties();
39:                props.load(TestEngine.findTestProperties());
40:
41:                props.setProperty("jspwiki.usePageCache", "true");
42:                props.setProperty("jspwiki.pageProvider",
43:                        "com.ecyrd.jspwiki.providers.CounterProvider");
44:                props.setProperty("jspwiki.cachingProvider.capacity", "100");
45:
46:                TestEngine engine = new TestEngine(props);
47:
48:                CounterProvider p = (CounterProvider) ((CachingProvider) engine
49:                        .getPageManager().getProvider()).getRealProvider();
50:
51:                assertEquals("init", 1, p.m_initCalls);
52:                assertEquals("getAllPages", 1, p.m_getAllPagesCalls);
53:                assertEquals("pageExists", 0, p.m_pageExistsCalls);
54:                assertEquals("getPage", 2, p.m_getPageCalls); // These two are for non-existant pages (with and without s)
55:                assertEquals("getPageText", 4, p.m_getPageTextCalls);
56:
57:                engine.getPage("Foo");
58:
59:                assertEquals("pageExists2", 0, p.m_pageExistsCalls);
60:                assertEquals("getPage2", 2, p.m_getPageCalls);
61:            }
62:
63:            public void testSneakyAdd() throws Exception {
64:                Properties props = new Properties();
65:                props.load(TestEngine.findTestProperties());
66:
67:                props.setProperty("jspwiki.cachingProvider.cacheCheckInterval",
68:                        "2");
69:
70:                TestEngine engine = new TestEngine(props);
71:
72:                String dir = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
73:
74:                File f = new File(dir, "Testi.txt");
75:                String content = "[fuufaa]";
76:
77:                PrintWriter out = new PrintWriter(new FileWriter(f));
78:                FileUtil.copyContents(new StringReader(content), out);
79:                out.close();
80:
81:                Thread.sleep(4000L); // Make sure we wait long enough
82:
83:                WikiPage p = engine.getPage("Testi");
84:                assertNotNull("page did not exist?", p);
85:
86:                String text = engine.getText("Testi");
87:                assertEquals("text", "[fuufaa]", text);
88:
89:                // TODO: ReferenceManager check as well
90:            }
91:
92:            public static Test suite() {
93:                return new TestSuite(CachingProviderTest.class);
94:            }
95:
96:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.