Source Code Cross Referenced for WikiPagePropertiesTest.java in  » Testing » StoryTestIQ » fitnesse » wiki » 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 » Testing » StoryTestIQ » fitnesse.wiki 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.wiki;
004:
005:        import java.io.*;
006:        import java.util.*;
007:        import fitnesse.testutil.AbstractRegex;
008:
009:        public class WikiPagePropertiesTest extends AbstractRegex {
010:            private InputStream sampleInputStream;
011:
012:            private WikiPageProperties properties;
013:
014:            static String endl = System.getProperty("line.separator");
015:
016:            static String sampleXml = "<?xml version=\"1.0\"?>" + endl
017:                    + "<properties>" + endl + "\t<Edit/>" + endl + "\t<Test/>"
018:                    + endl + "\t<VirtualWiki>http://someurl</VirtualWiki>"
019:                    + endl + "</properties>" + endl;
020:
021:            public void setUp() throws Exception {
022:                sampleInputStream = new ByteArrayInputStream(sampleXml
023:                        .getBytes());
024:                properties = new WikiPageProperties(sampleInputStream);
025:            }
026:
027:            public void tearDown() throws Exception {
028:            }
029:
030:            public void testLoading() throws Exception {
031:                assertTrue(properties.has(WikiPage.ACTION_EDIT));
032:                assertTrue(properties.has(WikiPage.ACTION_TEST));
033:                assertFalse(properties.has(WikiPage.ACTION_SUITE));
034:                assertEquals("http://someurl", properties.get("VirtualWiki"));
035:            }
036:
037:            public void testSave() throws Exception {
038:                ByteArrayOutputStream os = new ByteArrayOutputStream(1000);
039:                properties.save(os);
040:
041:                String xml = os.toString();
042:                assertEquals(sampleXml, xml);
043:            }
044:
045:            public void testSetProperty() throws Exception {
046:                properties = new WikiPageProperties();
047:                properties.set("newProperty1");
048:                assertEquals(true, properties.has("newProperty1"));
049:                assertEquals("true", properties.get("newProperty1"));
050:
051:                properties.set("newProperty2", "some value");
052:                assertEquals("some value", properties.get("newProperty2"));
053:            }
054:
055:            public void testRemoveProperty() throws Exception {
056:                properties = new WikiPageProperties();
057:                properties.set("newProperty", "blah");
058:                properties.remove("newProperty");
059:                assertEquals(false, properties.has("newProperty"));
060:            }
061:
062:            public void testKeySet() throws Exception {
063:                properties = new WikiPageProperties();
064:                properties.set("one");
065:                properties.set("two");
066:                properties.set("three");
067:                Set keys = properties.keySet();
068:
069:                assertTrue(keys.contains("one"));
070:                assertTrue(keys.contains("two"));
071:                assertTrue(keys.contains("three"));
072:                assertFalse(keys.contains("four"));
073:            }
074:
075:            public void testIsSerializable() throws Exception {
076:                try {
077:                    new ObjectOutputStream(new ByteArrayOutputStream())
078:                            .writeObject(properties);
079:                } catch (NotSerializableException e) {
080:                    fail("its not serializabl: " + e);
081:                }
082:            }
083:
084:            public void testHas() throws Exception {
085:                properties.set("true", "true");
086:                properties.set("false", "false");
087:
088:                assertTrue(properties.has("true"));
089:                assertTrue(properties.has("false"));
090:            }
091:
092:            public void testConstructorTakingAMap() throws Exception {
093:                HashMap map = new HashMap();
094:                map.put("key1", "value1");
095:                map.put("key2", "value2");
096:                map.put("key3", "false");
097:                properties = new WikiPageProperties(map);
098:                assertEquals("value1", properties.get("key1"));
099:                assertEquals(true, properties.has("key2"));
100:                assertFalse(properties.has("key3"));
101:            }
102:
103:            public void testSymbolicLinks() throws Exception {
104:                properties.addSymbolicLink("LinkName", PathParser
105:                        .parse("PatH.ToThe.PagE"));
106:                assertTrue(properties.hasSymbolicLink("LinkName"));
107:                assertFalse(properties.hasSymbolicLink("SomeOtherLink"));
108:
109:                assertEquals(PathParser.parse("PatH.ToThe.PagE"), properties
110:                        .getSymbolicLink("LinkName"));
111:                assertEquals(null, properties.getSymbolicLink("SomeOtherLink"));
112:
113:                Set linkNames = properties.getSymbolicLinkNames();
114:                assertEquals(1, linkNames.size());
115:                assertEquals("LinkName", linkNames.iterator().next());
116:
117:                properties.removeSymbolicLink("LinkName");
118:                assertFalse(properties.hasSymbolicLink("LinkName"));
119:            }
120:
121:            public void testSymbolicLinksSave() throws Exception {
122:                ByteArrayOutputStream output = saveSomeSymbolicLinks();
123:                String xml = output.toString();
124:
125:                assertHasRegexp(
126:                        "<symbolicLink>\\s*<name>LinkOne</name>\\s*<path>PatH.OnE</path>\\s*</symbolicLink>",
127:                        xml);
128:                assertHasRegexp(
129:                        "<symbolicLink>\\s*<name>LinkTwo</name>\\s*<path>PatH.TwO</path>\\s*</symbolicLink>",
130:                        xml);
131:            }
132:
133:            private ByteArrayOutputStream saveSomeSymbolicLinks()
134:                    throws Exception {
135:                properties.addSymbolicLink("LinkOne", PathParser
136:                        .parse("PatH.OnE"));
137:                properties.addSymbolicLink("LinkTwo", PathParser
138:                        .parse("PatH.TwO"));
139:                ByteArrayOutputStream output = new ByteArrayOutputStream();
140:                properties.save(output);
141:                return output;
142:            }
143:
144:            public void testSymbolicLinksLoading() throws Exception {
145:                ByteArrayOutputStream output = saveSomeSymbolicLinks();
146:                ByteArrayInputStream input = new ByteArrayInputStream(output
147:                        .toByteArray());
148:                WikiPageProperties newProperties = new WikiPageProperties(input);
149:
150:                assertTrue(newProperties.hasSymbolicLink("LinkOne"));
151:                assertEquals(PathParser.parse("PatH.OnE"), newProperties
152:                        .getSymbolicLink("LinkOne"));
153:                assertTrue(newProperties.hasSymbolicLink("LinkTwo"));
154:                assertEquals(PathParser.parse("PatH.TwO"), newProperties
155:                        .getSymbolicLink("LinkTwo"));
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.