Source Code Cross Referenced for TCObjectImplTest.java in  » Net » Terracotta » com » tc » object » 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 » Net » Terracotta » com.tc.object 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.object;
005:
006:        import com.tc.exception.ImplementMe;
007:        import com.tc.object.bytecode.TransparentAccess;
008:        import com.tc.object.dna.api.DNA;
009:        import com.tc.object.dna.api.DNAWriter;
010:        import com.tc.object.field.TCField;
011:        import com.tc.object.field.TCFieldFactory;
012:        import com.tc.object.tx.optimistic.OptimisticTransactionManager;
013:        import com.tc.objectserver.core.api.TestDNAWriter;
014:
015:        import java.lang.reflect.Constructor;
016:        import java.lang.reflect.Field;
017:        import java.util.Collection;
018:        import java.util.HashMap;
019:        import java.util.Map;
020:
021:        /**
022:         * @author steve
023:         */
024:        public class TCObjectImplTest extends BaseDSOTestCase {
025:
026:            public void tests() throws Exception {
027:                TestClientObjectManager objectManager = new TestClientObjectManager();
028:                TCClass clazz = new TestTCClass(objectManager);
029:                TestObject to1 = new TestObject(null, null);
030:                TestObject to2 = new TestObject("TestObject2", null);
031:                ObjectID id1 = new ObjectID(1);
032:                ObjectID id2 = new ObjectID(2);
033:                objectManager.add(id2, new TCObjectPhysical(objectManager
034:                        .getReferenceQueue(), id2, to2, clazz));
035:
036:                TCObjectImpl tcObj = new TCObjectPhysical(objectManager
037:                        .getReferenceQueue(), id1, to1, clazz);
038:                tcObj.resolveReference(TestObject.class.getName() + ".test1");
039:                tcObj.resolveReference(TestObject.class.getName() + ".test2");
040:                assertTrue(to1.test1 == null);// nothing should happen from that
041:                assertTrue(to1.test2 == null);
042:
043:                tcObj.setReference(TestObject.class.getName() + ".test2",
044:                        new ObjectID(2));
045:
046:                assertTrue(to1.test1 == null);// nothing should happen from that
047:                assertTrue(to1.test2 == null);
048:
049:                tcObj.resolveReference(TestObject.class.getName() + ".test2");
050:                assertTrue(to1.test1 == null);// nothing should happen from that
051:                assertTrue(to1.test2 == to2);
052:
053:                tcObj.dehydrateIfNew(new TestDNAWriter());
054:                tcObj.clearReferences(100);
055:                assertTrue(to1.test2 == null);
056:                tcObj.resolveReference(TestObject.class.getName() + ".test2");
057:                assertTrue(to1.test2 == to2);
058:            }
059:
060:            private static class TestObject implements  TransparentAccess {
061:                public String test1;
062:                public TestObject test2;
063:
064:                public TCObject managed;
065:
066:                public TestObject(String test1, TestObject test2) {
067:                    this .test1 = test1;
068:                    this .test2 = test2;
069:                }
070:
071:                public void __tc_getallfields(Map map) {
072:                    map.put(getClass().getName() + "." + "test1", test1);
073:                    map.put(getClass().getName() + "." + "test2", test2);
074:                }
075:
076:                public void __tc_setfield(String fieldName, Object value) {
077:                    if (fieldName.equals(TestObject.class.getName() + ".test1")) {
078:                        test1 = (String) value;
079:                    }
080:                    if (fieldName.equals(TestObject.class.getName() + ".test2")) {
081:                        test2 = (TestObject) value;
082:                    }
083:                }
084:
085:                public void __tc_managed(TCObject b) {
086:                    this .managed = b;
087:                }
088:
089:                public TCObject __tc_managed() {
090:                    return managed;
091:                }
092:
093:                public Object __tc_getmanagedfield(String name) {
094:                    throw new ImplementMe();
095:                }
096:
097:                public void __tc_setmanagedfield(String name, Object value) {
098:                    throw new ImplementMe();
099:                }
100:
101:            }
102:
103:            public class TestTCClass implements  TCClass {
104:                private TCFieldFactory fieldFactory;
105:                private Map fields = new HashMap();
106:                private final TestClientObjectManager objectManager;
107:
108:                public Field getParentField() {
109:                    return null;
110:                }
111:
112:                public String getParentFieldName() {
113:                    return "className.this$0";
114:                }
115:
116:                public TestTCClass(TestClientObjectManager objectManager)
117:                        throws Exception {
118:                    this .objectManager = objectManager;
119:                    fieldFactory = new TCFieldFactory(configHelper());
120:                    Field[] flds = TestObject.class.getDeclaredFields();
121:                    for (int i = 0; i < flds.length; i++) {
122:                        fields.put(TestObject.class.getName() + "."
123:                                + flds[i].getName(), fieldFactory.getInstance(
124:                                this , flds[i]));
125:                    }
126:                }
127:
128:                public TCField[] getPortableFields() {
129:                    Collection fs = fields.values();
130:                    return (TCField[]) fs.toArray(new TCField[fs.size()]);
131:                }
132:
133:                public Constructor getConstructor() throws SecurityException {
134:                    // TODO Auto-generated method stub
135:                    return null;
136:                }
137:
138:                public TCClass getSuperclass() {
139:                    // TODO Auto-generated method stub
140:                    return null;
141:                }
142:
143:                public boolean isPortable() {
144:                    // TODO Auto-generated method stub
145:                    return false;
146:                }
147:
148:                public TCField getDeclaredField(String name) {
149:                    try {
150:                        return (TCField) fields.get(name);
151:                    } catch (Exception e) {
152:                        throw new RuntimeException(e);
153:                    }
154:                }
155:
156:                public TCField getField(String name) {
157:                    return getDeclaredField(name);
158:                }
159:
160:                public TCField getField(String classname, String fieldname) {
161:                    // TODO Auto-generated method stub
162:                    return null;
163:                }
164:
165:                public TCField getField(Field field) {
166:                    // TODO Auto-generated method stub
167:                    return null;
168:                }
169:
170:                public boolean isIndexed() {
171:                    // TODO Auto-generated method stub
172:                    return false;
173:                }
174:
175:                public void hydrate(TCObject tcObject, DNA dna, Object pojo,
176:                        boolean force) {
177:                    //
178:                }
179:
180:                public void dehydrate(TCObject tcObject, DNAWriter writer,
181:                        Object pojo) {
182:                    //
183:                }
184:
185:                public String getName() {
186:                    return TestObject.class.getName();
187:                }
188:
189:                public Class getComponentType() {
190:                    return null;
191:                }
192:
193:                public TraversedReferences getPortableObjects(Object pojo,
194:                        TraversedReferences addTo) {
195:                    return addTo;
196:                }
197:
198:                public String getDefiningLoaderDescription() {
199:                    throw new ImplementMe();
200:                }
201:
202:                public boolean isNonStaticInner() {
203:                    return false;
204:                }
205:
206:                public boolean isLogical() {
207:                    return false;
208:                }
209:
210:                public TCObject createTCObject(ObjectID id, Object peer) {
211:                    throw new ImplementMe();
212:                }
213:
214:                public boolean hasOnLoadExecuteScript() {
215:                    return false;
216:                }
217:
218:                public String getOnLoadExecuteScript() {
219:
220:                    return null;
221:                }
222:
223:                public boolean hasOnLoadMethod() {
224:                    return false;
225:                }
226:
227:                public String getOnLoadMethod() {
228:                    return null;
229:                }
230:
231:                public boolean isUseNonDefaultConstructor() {
232:                    return false;
233:                }
234:
235:                public Object getNewInstanceFromNonDefaultConstructor(DNA dna) {
236:                    return null;
237:                }
238:
239:                public Class getPeerClass() {
240:                    throw new ImplementMe();
241:                }
242:
243:                public Map connectedCopy(Object source, Object dest,
244:                        Map visited, OptimisticTransactionManager txManager) {
245:                    throw new ImplementMe();
246:                }
247:
248:                public String getFieldNameByOffset(long fieldOffset) {
249:                    throw new ImplementMe();
250:                }
251:
252:                public ClientObjectManager getObjectManager() {
253:                    return objectManager;
254:                }
255:
256:                public boolean isProxyClass() {
257:                    return false;
258:                }
259:
260:                public String getExtendingClassName() {
261:                    return getName();
262:                }
263:
264:                public boolean isEnum() {
265:                    return false;
266:                }
267:
268:                public boolean isPortableField(long fieldOffset) {
269:                    throw new ImplementMe();
270:                }
271:            }
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.