Source Code Cross Referenced for InheritedBindingTest.java in  » Web-Framework » Tapestry » org » apache » tapestry » internal » services » 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 Framework » Tapestry » org.apache.tapestry.internal.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright 2007 The Apache Software Foundation
002:        //
003:        // Licensed under the Apache License, Version 2.0 (the "License");
004:        // you may not use this file except in compliance with the License.
005:        // You may obtain a copy of the License at
006:        //
007:        //     http://www.apache.org/licenses/LICENSE-2.0
008:        //
009:        // Unless required by applicable law or agreed to in writing, software
010:        // distributed under the License is distributed on an "AS IS" BASIS,
011:        // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        // See the License for the specific language governing permissions and
013:        // limitations under the License.
014:
015:        package org.apache.tapestry.internal.services;
016:
017:        import org.apache.tapestry.Binding;
018:        import org.apache.tapestry.annotations.Inject;
019:        import org.apache.tapestry.ioc.Location;
020:        import org.apache.tapestry.ioc.internal.util.TapestryException;
021:        import org.apache.tapestry.test.TapestryTestCase;
022:        import org.testng.annotations.Test;
023:
024:        public class InheritedBindingTest extends TapestryTestCase {
025:            private static final String BINDING_DESCRIPTION = "binding description";
026:
027:            private static final String MESSAGE = "Exception in inner.";
028:
029:            private static final Throwable _exception = new RuntimeException(
030:                    MESSAGE);
031:
032:            @Test
033:            public void to_string_and_location() {
034:                Binding inner = mockBinding();
035:                Location l = mockLocation();
036:
037:                replay();
038:
039:                InheritedBinding binding = new InheritedBinding(
040:                        BINDING_DESCRIPTION, inner, l);
041:
042:                assertSame(binding.toString(), BINDING_DESCRIPTION);
043:                assertSame(binding.getLocation(), l);
044:
045:                verify();
046:            }
047:
048:            @Test
049:            public void get_success() {
050:                Binding inner = mockBinding();
051:                Location l = mockLocation();
052:                Object expected = new Object();
053:
054:                train_get(inner, expected);
055:
056:                replay();
057:
058:                InheritedBinding binding = new InheritedBinding(
059:                        BINDING_DESCRIPTION, inner, l);
060:
061:                assertSame(binding.get(), expected);
062:
063:                verify();
064:            }
065:
066:            @Test
067:            public void get_failure() {
068:                Binding inner = mockBinding();
069:                Location l = mockLocation();
070:
071:                expect(inner.get()).andThrow(_exception);
072:
073:                replay();
074:
075:                InheritedBinding binding = new InheritedBinding(
076:                        BINDING_DESCRIPTION, inner, l);
077:
078:                try {
079:                    binding.get();
080:                    unreachable();
081:                } catch (TapestryException ex) {
082:                    checkException(ex, l);
083:                }
084:
085:                verify();
086:            }
087:
088:            @Test
089:            public void get_binding_type_success() {
090:                Binding inner = mockBinding();
091:                Location l = mockLocation();
092:                Class expected = Runnable.class;
093:
094:                expect(inner.getBindingType()).andReturn(expected);
095:
096:                replay();
097:
098:                InheritedBinding binding = new InheritedBinding(
099:                        BINDING_DESCRIPTION, inner, l);
100:
101:                assertSame(binding.getBindingType(), expected);
102:
103:                verify();
104:            }
105:
106:            @Test
107:            public void get_binding_type_failure() {
108:                Binding inner = mockBinding();
109:                Location l = mockLocation();
110:                String description = BINDING_DESCRIPTION;
111:
112:                expect(inner.getBindingType()).andThrow(_exception);
113:
114:                replay();
115:
116:                InheritedBinding binding = new InheritedBinding(description,
117:                        inner, l);
118:
119:                try {
120:                    binding.getBindingType();
121:                    unreachable();
122:                } catch (TapestryException ex) {
123:                    checkException(ex, l);
124:                }
125:
126:                verify();
127:            }
128:
129:            private void checkException(TapestryException ex, Location l) {
130:                assertEquals(ex.getMessage(), MESSAGE);
131:                assertEquals(ex.getLocation(), l);
132:                assertSame(ex.getCause(), _exception);
133:            }
134:
135:            @Test
136:            public void is_invariant_success() {
137:                Binding inner = mockBinding();
138:                Location l = mockLocation();
139:                boolean expected = true;
140:
141:                expect(inner.isInvariant()).andReturn(expected);
142:
143:                replay();
144:
145:                InheritedBinding binding = new InheritedBinding(
146:                        BINDING_DESCRIPTION, inner, l);
147:
148:                assertEquals(binding.isInvariant(), expected);
149:
150:                verify();
151:            }
152:
153:            @Test
154:            public void is_invariant_failure() {
155:                Binding inner = mockBinding();
156:                Location l = mockLocation();
157:                expect(inner.isInvariant()).andThrow(_exception);
158:
159:                replay();
160:
161:                InheritedBinding binding = new InheritedBinding(
162:                        BINDING_DESCRIPTION, inner, l);
163:
164:                try {
165:                    binding.isInvariant();
166:                    unreachable();
167:                } catch (TapestryException ex) {
168:                    checkException(ex, l);
169:                }
170:
171:                verify();
172:            }
173:
174:            @Test
175:            public void set_success() {
176:                Binding inner = mockBinding();
177:                Location l = mockLocation();
178:                String description = BINDING_DESCRIPTION;
179:                Object parameter = new Object();
180:
181:                inner.set(parameter);
182:
183:                replay();
184:
185:                InheritedBinding binding = new InheritedBinding(description,
186:                        inner, l);
187:
188:                binding.set(parameter);
189:
190:                verify();
191:            }
192:
193:            @Test
194:            public void set_failure() {
195:                Binding inner = mockBinding();
196:                Location l = mockLocation();
197:                Object parameter = new Object();
198:
199:                inner.set(parameter);
200:                getMocksControl().andThrow(_exception);
201:
202:                replay();
203:
204:                InheritedBinding binding = new InheritedBinding(
205:                        BINDING_DESCRIPTION, inner, l);
206:
207:                try {
208:                    binding.set(parameter);
209:                    unreachable();
210:                } catch (TapestryException ex) {
211:                    checkException(ex, l);
212:                }
213:
214:                verify();
215:            }
216:
217:            @Test
218:            public void get_annotation_success() {
219:                Binding inner = mockBinding();
220:                Location l = mockLocation();
221:                Inject inject = newMock(Inject.class);
222:
223:                train_getAnnotation(inner, Inject.class, inject);
224:
225:                replay();
226:
227:                InheritedBinding binding = new InheritedBinding(
228:                        BINDING_DESCRIPTION, inner, l);
229:
230:                assertSame(binding.getAnnotation(Inject.class), inject);
231:
232:                verify();
233:            }
234:
235:            @Test
236:            public void get_annotation_failure() {
237:                Binding inner = mockBinding();
238:                Location l = mockLocation();
239:
240:                expect(inner.getAnnotation(Inject.class)).andThrow(_exception);
241:
242:                replay();
243:
244:                InheritedBinding binding = new InheritedBinding(
245:                        BINDING_DESCRIPTION, inner, l);
246:
247:                try {
248:                    binding.getAnnotation(Inject.class);
249:                    unreachable();
250:                } catch (TapestryException ex) {
251:                    checkException(ex, l);
252:                }
253:
254:                verify();
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.