Source Code Cross Referenced for BeansObservablesTest.java in  » IDE-Eclipse » jface » org » eclipse » core » tests » databinding » beans » 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 » IDE Eclipse » jface » org.eclipse.core.tests.databinding.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *     Brad Reynolds - bug 164268, 171616
011:         *******************************************************************************/package org.eclipse.core.tests.databinding.beans;
012:
013:        import java.util.Arrays;
014:
015:        import org.eclipse.core.databinding.beans.BeansObservables;
016:        import org.eclipse.core.databinding.beans.IBeanObservable;
017:        import org.eclipse.core.databinding.observable.Realm;
018:        import org.eclipse.core.databinding.observable.list.IObservableList;
019:        import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
020:        import org.eclipse.core.databinding.observable.set.IObservableSet;
021:        import org.eclipse.core.databinding.observable.value.IObservableValue;
022:        import org.eclipse.core.databinding.observable.value.WritableValue;
023:        import org.eclipse.core.internal.databinding.internal.beans.BeanObservableListDecorator;
024:        import org.eclipse.core.internal.databinding.internal.beans.BeanObservableSetDecorator;
025:        import org.eclipse.core.internal.databinding.internal.beans.BeanObservableValueDecorator;
026:        import org.eclipse.core.tests.internal.databinding.internal.beans.Bean;
027:        import org.eclipse.jface.tests.databinding.AbstractDefaultRealmTestCase;
028:
029:        /**
030:         * @since 3.2
031:         */
032:        public class BeansObservablesTest extends AbstractDefaultRealmTestCase {
033:            Bean[] elements = null;
034:            Bean model = null;
035:            Class elementType = null;
036:
037:            protected void setUp() throws Exception {
038:                super .setUp();
039:
040:                elements = new Bean[] { new Bean("1"), new Bean("2"),
041:                        new Bean("3") };
042:                model = new Bean(Arrays.asList(elements));
043:                elementType = Bean.class;
044:            }
045:
046:            public void testObserveListArrayInferredElementType()
047:                    throws Exception {
048:                IObservableList list = BeansObservables.observeList(Realm
049:                        .getDefault(), model, "list", null);
050:                assertEquals("element type", Object.class, list
051:                        .getElementType());
052:            }
053:
054:            public void testObserveListNonInferredElementType()
055:                    throws Exception {
056:                elementType = Object.class;
057:                IObservableList list = BeansObservables.observeList(Realm
058:                        .getDefault(), model, "list", null);
059:                assertEquals("element type", elementType, list.getElementType());
060:            }
061:
062:            public void testListFactory() throws Exception {
063:                IObservableFactory factory = BeansObservables.listFactory(Realm
064:                        .getDefault(), "list", elementType);
065:                IObservableList list = (IObservableList) factory
066:                        .createObservable(model);
067:
068:                assertTrue("elements of the list", Arrays.equals(elements, list
069:                        .toArray(new Bean[list.size()])));
070:                assertEquals("element type", elementType, list.getElementType());
071:            }
072:
073:            public void testObserveDetailListElementType() throws Exception {
074:                WritableValue parent = WritableValue.withValueType(Bean.class);
075:                parent.setValue(model);
076:                IObservableList list = BeansObservables.observeDetailList(Realm
077:                        .getDefault(), parent, "list", elementType);
078:
079:                assertEquals("element type", elementType, list.getElementType());
080:                assertTrue("elements of list", Arrays.equals(elements, list
081:                        .toArray(new Bean[list.size()])));
082:            }
083:
084:            public void testObserveDetailValueIBeanObservable()
085:                    throws Exception {
086:                WritableValue parent = WritableValue.withValueType(Bean.class);
087:                parent.setValue(new Bean());
088:
089:                IObservableValue detailValue = BeansObservables
090:                        .observeDetailValue(Realm.getDefault(), parent,
091:                                "value", String.class);
092:                assertTrue(detailValue instanceof  IBeanObservable);
093:
094:                BeanObservableValueDecorator beanObservable = (BeanObservableValueDecorator) detailValue;
095:                assertEquals("property descriptor", Bean.class.getMethod(
096:                        "getValue", null), beanObservable
097:                        .getPropertyDescriptor().getReadMethod());
098:                assertEquals("observed", parent.getValue(), beanObservable
099:                        .getObserved());
100:                assertTrue("delegate", beanObservable.getDelegate().getClass()
101:                        .getName().endsWith("DetailObservableValue"));
102:            }
103:
104:            public void testObserveDetailValueNullOuterElementType()
105:                    throws Exception {
106:                WritableValue parent = new WritableValue(new Bean(), null);
107:
108:                IObservableValue detailValue = BeansObservables
109:                        .observeDetailValue(Realm.getDefault(), parent,
110:                                "value", String.class);
111:
112:                assertNull("property descriptor",
113:                        ((IBeanObservable) detailValue).getPropertyDescriptor());
114:            }
115:
116:            public void testObservableDetailListIBeanObservable()
117:                    throws Exception {
118:                WritableValue parent = WritableValue.withValueType(Bean.class);
119:                parent.setValue(new Bean());
120:
121:                IObservableList detailList = BeansObservables
122:                        .observeDetailList(Realm.getDefault(), parent, "list",
123:                                Bean.class);
124:                assertTrue("detail is not an IBeanObservable",
125:                        detailList instanceof  IBeanObservable);
126:
127:                BeanObservableListDecorator beanObservable = (BeanObservableListDecorator) detailList;
128:                assertEquals("property descriptor", Bean.class.getMethod(
129:                        "getList", null), beanObservable
130:                        .getPropertyDescriptor().getReadMethod());
131:                assertEquals("observed", parent, beanObservable.getObserved());
132:
133:                // DetailObservableList is package level we can do a straight instanceof
134:                // check
135:                assertTrue("delegate is the observed", beanObservable
136:                        .getDelegate().equals(detailList));
137:            }
138:
139:            public void testObservableDetailListNullOuterElementType()
140:                    throws Exception {
141:                WritableValue parent = new WritableValue(new Bean(), null);
142:
143:                IObservableList detailList = BeansObservables
144:                        .observeDetailList(Realm.getDefault(), parent, "list",
145:                                Bean.class);
146:
147:                assertNull("property descriptor",
148:                        ((IBeanObservable) detailList).getPropertyDescriptor());
149:            }
150:
151:            public void testObservableDetailSetIBeanObservable()
152:                    throws Exception {
153:                WritableValue parent = WritableValue.withValueType(Bean.class);
154:                parent.setValue(new Bean());
155:
156:                IObservableSet detailSet = BeansObservables.observeDetailSet(
157:                        Realm.getDefault(), parent, "set", Bean.class);
158:                assertTrue("detail is not an IBeanObservable",
159:                        detailSet instanceof  IBeanObservable);
160:
161:                BeanObservableSetDecorator beanObservable = (BeanObservableSetDecorator) detailSet;
162:                assertEquals("property descriptor", Bean.class.getMethod(
163:                        "getSet", null), beanObservable.getPropertyDescriptor()
164:                        .getReadMethod());
165:                assertEquals("observed", parent, beanObservable.getObserved());
166:
167:                // DetailObservableSet is package level we can't do a straight
168:                // instanceof check
169:                assertTrue("delegate is the observed", beanObservable
170:                        .getDelegate().equals(detailSet));
171:            }
172:
173:            public void testObservableDetailSetNullOuterElementType()
174:                    throws Exception {
175:                WritableValue parent = new WritableValue(new Bean(), null);
176:
177:                IObservableSet detailSet = BeansObservables.observeDetailSet(
178:                        Realm.getDefault(), parent, "set", Bean.class);
179:
180:                assertNull("property descriptor", ((IBeanObservable) detailSet)
181:                        .getPropertyDescriptor());
182:            }
183:
184:            public void testObserveSetElementType() throws Exception {
185:                Bean bean = new Bean();
186:                IObservableSet observableSet = BeansObservables.observeSet(
187:                        Realm.getDefault(), bean, "set", Bean.class);
188:                assertEquals(Bean.class, observableSet.getElementType());
189:            }
190:
191:            public void testObserveSetNonInferredElementType() throws Exception {
192:                Bean bean = new Bean();
193:                IObservableSet observableSet = BeansObservables.observeSet(
194:                        Realm.getDefault(), bean, "set");
195:                assertEquals(Object.class, observableSet.getElementType());
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.