Source Code Cross Referenced for BlogTest.java in  » Content-Management-System » openedit » com » openedit » blog » 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 » Content Management System » openedit » com.openedit.blog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 18, 2005
003:         */
004:        package com.openedit.blog;
005:
006:        import java.io.StringWriter;
007:        import java.io.Writer;
008:        import java.text.SimpleDateFormat;
009:        import java.util.ArrayList;
010:        import java.util.List;
011:
012:        import org.openedit.blog.modules.BlogModule;
013:
014:        import com.openedit.BaseTestCase;
015:        import com.openedit.WebPageRequest;
016:        import com.openedit.modules.admin.users.Question;
017:        import com.openedit.users.User;
018:        import com.sun.syndication.feed.synd.SyndContent;
019:        import com.sun.syndication.feed.synd.SyndContentImpl;
020:        import com.sun.syndication.feed.synd.SyndEntry;
021:        import com.sun.syndication.feed.synd.SyndEntryImpl;
022:        import com.sun.syndication.feed.synd.SyndFeed;
023:        import com.sun.syndication.feed.synd.SyndFeedImpl;
024:        import com.sun.syndication.io.SyndFeedOutput;
025:
026:        /**
027:         * @author cburkey
028:         *
029:         */
030:        public class BlogTest extends BaseTestCase {
031:            /**
032:             * 
033:             */
034:            public BlogTest(String inName) {
035:                super (inName);
036:            }
037:
038:            public void testReadExistingBlog() throws Exception {
039:                BlogModule blogmodule = (BlogModule) getBean("BlogModule");
040:                //list last five entries
041:                //System.out.println(SimpleDateFormat.getDateTimeInstance().format(new Date()));
042:                WebPageRequest req = getFixture().createPageRequest(
043:                        "/yetanotherblog/index.html");
044:                blogmodule.getBlog(req);
045:                Blog blog = (Blog) req.getPageValue("blog");
046:                List recent = blog.getRecentEntries(5);
047:                assertTrue(recent.size() > 0);
048:                BlogEntry entry = (BlogEntry) recent.get(0);
049:                // FIXME: Actually test something here.
050:                //assertEquals("A blog entry",entry.getTitle());
051:
052:                //assertEquals(1,entry.getCategories().size() );
053:
054:                /* 		assertTrue(entry.getDescription().getValue().length() > 100);
055:                 assertEquals(entry.getLink(),"http://localhost:8080/yetanotherblog/permalink/2005/2/17/112302.html");
056:                 assertEquals(entry.getPath(),"/yetanotherblog/2005/2/17/112302.html");
057:                 assertEquals(entry.getId(),"yetanotherblog2005217112302");
058:                
059:                 int count = entry.countComments();
060:                 assertEquals(1,count);
061:                 */
062:            }
063:
064:            public void testPermalink() throws Exception {
065:                BlogModule blogmodule = (BlogModule) getBean("BlogModule");
066:                WebPageRequest req = getFixture().createPageRequest(
067:                        "/yetanotherblog/permalink/2005/2/17/112302.html");
068:                blogmodule.loadPermalink(req);
069:                BlogEntry entry = (BlogEntry) req.getPageValue("entry");
070:                assertNotNull(entry);
071:            }
072:
073:            public void testAtomFeed() throws Exception {
074:                //this makes a blog
075:                SyndFeed feed = new SyndFeedImpl();
076:                feed.setFeedType("atom_0.3");
077:                feed.setTitle("Sample Feed (created with Rome)");
078:                feed.setLink("http://rome.dev.java.net");
079:                feed
080:                        .setDescription("This feed has been created using Rome (Java syndication utilities");
081:
082:                List entries = new ArrayList();
083:                SyndEntry entry;
084:                SyndContent description;
085:
086:                entry = new SyndEntryImpl();
087:                entry.setTitle("Rome v1.0");
088:                entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome01");
089:                entry.setPublishedDate(new SimpleDateFormat("MM/dd/yyyy")
090:                        .parse("1/1/2004"));
091:                description = new SyndContentImpl();
092:                description.setType("text/plain");
093:                description.setValue("Initial release of Rome");
094:                entry.setDescription(description);
095:                entries.add(entry);
096:
097:                entry = new BlogEntry();
098:                entry.setTitle("Rome v3.0");
099:                entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome03");
100:                entry.setPublishedDate(new SimpleDateFormat("MM/dd/yyyy")
101:                        .parse("1/1/2004"));
102:                description = new SyndContentImpl();
103:                description.setType("text/html");
104:                String content = "<p>More Bug fixes, mor API changes, some new &nbsp; features and some Unit testing</p>"
105:                        + "<p>For details chec the <a href=\"http://wiki.java.net/bin/view/Javawsxml/RomeChangesLog#RomeV03\">Changes Log</a></p>";
106:                //content = content.replaceAll("&nbsp;","&#160;");
107:
108:                description.setValue(content);
109:                entry.setDescription(description);
110:                entries.add(entry);
111:
112:                feed.setEntries(entries);
113:                //blog.setFeed(feed);
114:
115:                Writer writer = new StringWriter();
116:                SyndFeedOutput output = new SyndFeedOutput();
117:                output.output(feed, writer);
118:                writer.close();
119:                assertTrue(writer.toString().length() > 200);
120:            }
121:
122:            public void testEditing() throws Exception {
123:                BlogModule blogmodule = (BlogModule) getBean("BlogModule");
124:                //list last five entries
125:                //System.out.println(SimpleDateFormat.getDateTimeInstance().format(new Date()));
126:                WebPageRequest req = getFixture().createPageRequest(
127:                        "/yetanotherblog/comments.html");
128:
129:                req.setRequestParameter("username", "admin");
130:                req.setRequestParameter("password", "admin");
131:                User admin = (User) req.getPageValue("user");
132:                req.setUser(admin);
133:                getFixture().getEngine().executePageActions(req);
134:                //add entry
135:                blogmodule.addNewEntry(req);
136:                BlogEntry entry = (BlogEntry) req.getPageValue("entry");
137:                assertNotNull(entry);
138:
139:                //test new entry
140:                req.setRequestParameter("title", "New Entry");
141:                req.setRequestParameter("author", "New Entry");
142:
143:                blogmodule.saveEntry(req);
144:                req.setRequestParameter("entryId", entry.getId());
145:                blogmodule.getEntry(req);
146:                BlogEntry blogentry = (BlogEntry) req.getPageValue("entry");
147:                assertNotNull(blogentry);
148:                assertEquals("New Entry", blogentry.getTitle());
149:
150:                Blog blog = blogmodule.getBlog(req);
151:                Question q = new Question();//blog.getQuestion("1");
152:                q.setId("1");
153:                q.setAnswer("9");
154:                req.putSessionValue("question", q);
155:
156:                //add comments
157:                req.setRequestParameter("entryId", entry.getId());
158:                req.setRequestParameter("author", "jimbob");
159:                req.setRequestParameter("content", "This is a comment");
160:
161:                req.setRequestParameter("questionid", "1");
162:                req.setRequestParameter("answerid", "9");
163:
164:                blogmodule.addNewComment(req);
165:                req.setRequestParameter("entryId", entry.getId());
166:                blogmodule.getEntry(req);
167:                blogentry = (BlogEntry) req.getPageValue("entry");
168:                assertEquals(1, blogentry.getComments().size());
169:                Comment comment = (Comment) blogentry.getComments().get(0);
170:                assertTrue(comment.isVisible());
171:
172:                req.setRequestParameter("entryId", entry.getId());
173:                req.setRequestParameter("commentId", comment.getId());
174:                req.setRequestParameter("actiontext", "flip");
175:                blogmodule.changeCommentVisibility(req);
176:
177:                Comment blogcomment = (Comment) blogentry.getComments().get(0);
178:                assertFalse(blogcomment.isVisible());
179:
180:                assertFalse(entry.isVisible());
181:                req.setRequestParameter("entryId", entry.getId());
182:                blogmodule.changeEntryVisibility(req);
183:
184:                req.setRequestParameter("entryId", entry.getId());
185:                blogmodule.getEntry(req);
186:                blogentry = (BlogEntry) req.getPageValue("entry");
187:
188:                assertTrue(blogentry.isVisible());
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.