Source Code Cross Referenced for TestIDSAMEDataServiceStub.java in  » Portal » Open-Portal » com » sun » portal » rproxy » rewriter » services » idsame » test » 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 » Portal » Open Portal » com.sun.portal.rproxy.rewriter.services.idsame.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.rproxy.rewriter.services.idsame.test;
002:
003:        import com.sun.portal.rewriter.test.util.BasicTestCase;
004:        import com.sun.portal.log.common.PortalLogger;
005:        import com.sun.portal.rproxy.rewriter.SRAPRewriterModule;
006:        import com.sun.portal.rproxy.rewriter.services.idsame.IDSAMEDataServiceStub;
007:        import junit.framework.Test;
008:        import junit.framework.TestCase;
009:        import junit.framework.TestSuite;
010:
011:        import java.util.Iterator;
012:        import java.util.Properties;
013:
014:        public class TestIDSAMEDataServiceStub extends TestCase {
015:            private IDSAMEDataServiceStub remoteService;
016:
017:            public TestIDSAMEDataServiceStub(String name) {
018:                super (name);
019:            }//constructor
020:
021:            public void setUp() throws Exception {
022:                remoteService = new IDSAMEDataServiceStub(new Properties());
023:            }//setUp()
024:
025:            public void testRetrieveKeys() throws Exception {
026:                for (Iterator itr = remoteService.retrieveKeys().iterator(); itr
027:                        .hasNext();) {
028:                    String key = (String) itr.next();
029:                    assertTrue("RULESET-ID1".equals(key)
030:                            || "RULESET-ID2".equals(key)
031:                            || "RULESET-ID3".equals(key)
032:                            || "RULESET-ID4".equals(key)
033:                            || "RULESET-ID5".equals(key));
034:                }//for loop
035:            }//testRetrieveKeys()
036:
037:            public void testRetrieveXML() throws Exception {
038:                String value = remoteService.retrieveXML("RULESET-ID1");
039:                assertEquals("RULESET-VALUE1", value);
040:                value = remoteService.retrieveXML("RULESET-ID2");
041:                assertEquals("RULESET-VALUE2", value);
042:                value = remoteService.retrieveXML("RULESET-ID5");
043:                assertEquals("RULESET-VALUE5", value);
044:                value = remoteService.retrieveXML("RULESET-ID4");
045:                assertEquals("RULESET-VALUE4", value);
046:                value = remoteService.retrieveXML("RULESET-ID3");
047:                assertEquals("RULESET-VALUE3", value);
048:            }//testRetrieveXML()
049:
050:            public void testRetrieveXMLException() throws Exception {
051:                try {
052:                    remoteService.retrieveXML(null);
053:                } catch (IllegalArgumentException e) {
054:                    // this is expected.
055:                }
056:                String value = remoteService.retrieveXML("SOME-JUNK-ID");
057:                assertNull(value);
058:            }//testRetrieveXMLException()
059:
060:            public void testStoreXML() throws Exception {
061:                String key = "RULESET-ID6";
062:                String value = "RULESET-VALUE6";
063:                String oldvalue = remoteService.storeXML(key, value);
064:
065:                assertNull(oldvalue);
066:                assertEquals(value, remoteService.retrieveXML(key));
067:
068:                remoteService.deleteKey(key);
069:                assertNull(remoteService.retrieveXML(key));
070:
071:                String id = "RULESET-ID3";
072:                String oldValue = "RULESET-VALUE3";
073:                assertEquals(oldValue, remoteService.retrieveXML(id));
074:
075:                String newValue = " this is the new value";
076:
077:                assertEquals(oldValue, remoteService.storeXML(id, newValue));
078:                assertEquals(newValue, remoteService.retrieveXML(id));
079:
080:                assertEquals(newValue, remoteService.storeXML(id, oldValue));
081:                assertEquals(oldValue, remoteService.retrieveXML(id));
082:            }//testStoreXML()
083:
084:            public void testStoreXMLException() throws Exception {
085:                String[][] lData = { { null, "some junk" },
086:                        { "some key", null }, { "   ", "some value" },
087:                        { "some key", "" }, { "NEW-KEY", "      " }, };
088:
089:                for (int i = 0; i < lData.length; i++) {
090:                    try {
091:                        remoteService.storeXML(lData[i][0], lData[i][1]);
092:                        fail("Accepting invalid Parameter for storeXML");
093:                    } catch (IllegalArgumentException e) {
094:                        assertTrue(true);
095:                        // this is expected ...
096:                    }//try/catch
097:                }
098:            }//testStoreXMLException()
099:
100:            public void testDeleteKey() throws Exception {
101:                String key = "NEW-KEY";
102:                String value = "NEW-VALUE";
103:                String oldvalue = remoteService.storeXML(key, value);
104:                assertNull(oldvalue);
105:                assertEquals(value, remoteService.retrieveXML(key));
106:                assertEquals(value, remoteService.deleteKey(key));
107:                assertNull(value, remoteService.retrieveXML(key));
108:            }//testDeleteKey()
109:
110:            public void testDeleteKeyException() throws Exception {
111:                String[][] lData = { { null }, { "      " }, { "" }, };
112:
113:                for (int i = 0; i < lData.length; i++) {
114:                    try {
115:                        remoteService.deleteKey(lData[i][0]);
116:                        fail("Acceptiong invalid param for delete");
117:                    } catch (IllegalArgumentException e) {
118:                        assertTrue(true);
119:                        // this is expected ...
120:                    }//try/catch
121:                }
122:
123:                remoteService
124:                        .deleteKey("KEY-DOES-NOT-EXIST_no_exception_shoud_be_thrown");
125:            }//testDeleteKeyException()
126:
127:            public void testAddData() {
128:                remoteService.storeXML("RULESET-ID1", "RULESET-VALUE1");
129:                remoteService.storeXML("RULESET-ID2", "RULESET-VALUE2");
130:                remoteService.storeXML("RULESET-ID3", "RULESET-VALUE3");
131:                remoteService.storeXML("RULESET-ID4", "RULESET-VALUE4");
132:                remoteService.storeXML("RULESET-ID5", "RULESET-VALUE5");
133:            }//testAddData()
134:
135:            public void testDeleteData() {
136:                remoteService.deleteKey("RULESET-ID1");
137:                remoteService.deleteKey("RULESET-ID2");
138:                remoteService.deleteKey("RULESET-ID3");
139:                remoteService.deleteKey("RULESET-ID4");
140:                remoteService.deleteKey("RULESET-ID5");
141:            }//testDeleteData()
142:
143:            public static Test suite() {
144:                TestSuite suite = new TestSuite();
145:
146:                // Adding the Sample Data to test - must be the first test
147:                suite.addTest(new TestIDSAMEDataServiceStub("testAddData"));
148:
149:                suite
150:                        .addTest(new TestIDSAMEDataServiceStub(
151:                                "testRetrieveKeys"));
152:                suite.addTest(new TestIDSAMEDataServiceStub("testRetrieveXML"));
153:                suite.addTest(new TestIDSAMEDataServiceStub(
154:                        "testRetrieveXMLException"));
155:                suite.addTest(new TestIDSAMEDataServiceStub("testStoreXML"));
156:                suite.addTest(new TestIDSAMEDataServiceStub("testDeleteKey"));
157:                suite.addTest(new TestIDSAMEDataServiceStub(
158:                        "testStoreXMLException"));
159:                suite.addTest(new TestIDSAMEDataServiceStub(
160:                        "testDeleteKeyException"));
161:
162:                // Deleting the Sample Data created - must be the last test
163:                suite.addTest(new TestIDSAMEDataServiceStub("testDeleteData"));
164:                return suite;
165:            }//suite()
166:
167:            public static void main(String[] args) {
168:                SRAPRewriterModule.initFile();
169:                //BasicTestCase.run( TestIDSAMEDataServiceStub.class );
170:
171:                TestSuite testSuite = new TestSuite();
172:                testSuite
173:                        .addTest(new TestIDSAMEDataServiceStub("testStoreXML"));
174:                BasicTestCase.run(testSuite);
175:            }//main()
176:        }//class TestIDSAMEDataServiceStub
w___ww.__j__a___v___a__2___s__._c__o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.