Source Code Cross Referenced for MyFunctionTests.java in  » Web-Services » xins » com » mycompany » myproject » tests » 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 » Web Services » xins » com.mycompany.myproject.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id$
003:         */
004:        package com.mycompany.myproject.tests;
005:
006:        import junit.framework.Test;
007:        import junit.framework.TestCase;
008:        import junit.framework.TestSuite;
009:        import junit.textui.TestRunner;
010:
011:        import org.xins.client.UnsuccessfulXINSCallException;
012:        import org.xins.client.XINSCallRequest;
013:        import org.xins.client.XINSCallResult;
014:        import org.xins.client.XINSServiceCaller;
015:
016:        import org.xins.common.service.TargetDescriptor;
017:        import org.xins.common.xml.Element;
018:        import org.xins.common.xml.ElementBuilder;
019:
020:        /**
021:         * Implementation of the <code>MyFunction</code> tests.
022:         *
023:         * @version $Revision$ $Date$
024:         */
025:        public class MyFunctionTests extends TestCase {
026:
027:            /**
028:             * The XINServiceCaller of the API.
029:             */
030:            private XINSServiceCaller caller;
031:
032:            /**
033:             * The URL of the tested API.
034:             */
035:            private String target;
036:
037:            /**
038:             * Constructs a new <code>MyFunctionTests</code> test suite with
039:             * the specified name. The name will be passed to the superconstructor.
040:             *
041:             * @param name
042:             *     the name for this test suite.
043:             */
044:            public MyFunctionTests(String name) {
045:                super (name);
046:            }
047:
048:            /**
049:             * Returns a test suite with all test cases defined by this class.
050:             *
051:             * @return
052:             *     the test suite, never <code>null</code>.
053:             */
054:            public static Test suite() {
055:                return new TestSuite(MyFunctionTests.class);
056:            }
057:
058:            /**
059:             * Executes just this test.
060:             */
061:            public static void main(String args[]) {
062:                TestRunner.run(suite());
063:            }
064:
065:            protected void setUp() throws Exception {
066:                target = System.getProperty("test.environment");
067:                if (target == null || target.trim().equals("")) {
068:                    target = "http://localhost:8080/myproject/";
069:                }
070:                caller = new XINSServiceCaller(new TargetDescriptor(target));
071:            }
072:
073:            protected void tearDown() throws Exception {
074:            }
075:
076:            /**
077:             * Tests the MyFunction function by executing the example 1.
078:             *
079:             * Description: Missing parameter : lastName
080:             *
081:             * @throws Exception
082:             *    if an unexpected error occurs.
083:             */
084:            public void testMyFunctionExample1() throws Exception {
085:                XINSCallRequest request = new XINSCallRequest("MyFunction");
086:                request.setParameter("personLastName", "Bond 007");
087:                try {
088:                    XINSCallResult result = caller.call(request);
089:                    fail("An error code \"_InvalidRequest\" was expected but did not occur.");
090:                } catch (UnsuccessfulXINSCallException uxcex) {
091:                    assertEquals("Incorrect error code received: "
092:                            + uxcex.getErrorCode(), "_InvalidRequest", uxcex
093:                            .getErrorCode());
094:                    Element missing_param1 = (Element) uxcex.getDataElement()
095:                            .getChildElements().get(0);
096:                    assertEquals("Incorrect element.", "missing-param",
097:                            missing_param1.getLocalName());
098:                    assertEquals(
099:                            "The returned attribute \"param\" is incorrect.",
100:                            "gender", missing_param1.getAttribute("param"));
101:                    Element invalid_value_for_type2 = (Element) uxcex
102:                            .getDataElement().getChildElements().get(1);
103:                    assertEquals("Incorrect element.",
104:                            "invalid-value-for-type", invalid_value_for_type2
105:                                    .getLocalName());
106:                    assertEquals(
107:                            "The returned attribute \"type\" is incorrect.",
108:                            "LastName", invalid_value_for_type2
109:                                    .getAttribute("type"));
110:                    assertEquals(
111:                            "The returned attribute \"param\" is incorrect.",
112:                            "personLastName", invalid_value_for_type2
113:                                    .getAttribute("param"));
114:                }
115:            }
116:
117:            /**
118:             * Tests the MyFunction function by executing the example 2.
119:             *
120:             * Description: The name does not contain any vowels.
121:             *
122:             * @throws Exception
123:             *    if an unexpected error occurs.
124:             */
125:            public void testMyFunctionExample2() throws Exception {
126:                XINSCallRequest request = new XINSCallRequest("MyFunction");
127:                request.setParameter("gender", "f");
128:                request.setParameter("personLastName", "cqfd");
129:                try {
130:                    XINSCallResult result = caller.call(request);
131:                    fail("An error code \"NoVowel\" was expected but did not occur.");
132:                } catch (UnsuccessfulXINSCallException uxcex) {
133:                    assertEquals("Incorrect error code received: "
134:                            + uxcex.getErrorCode(), "NoVowel", uxcex
135:                            .getErrorCode());
136:                }
137:            }
138:
139:            /**
140:             * Tests the MyFunction function by executing the example 3.
141:             *
142:             * Description: Message returned.
143:             *
144:             * @throws Exception
145:             *    if an unexpected error occurs.
146:             */
147:            public void testMyFunctionExample3() throws Exception {
148:                XINSCallRequest request = new XINSCallRequest("MyFunction");
149:                request.setParameter("gender", "f");
150:                request.setParameter("personLastName", "Lee");
151:                XINSCallResult result = caller.call(request);
152:                assertEquals(
153:                        "The returned parameter \"message\" is incorrect.",
154:                        "Hello Miss Lee", result.getParameter("message"));
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.