Source Code Cross Referenced for DsoFinalMethodTest.java in  » Net » Terracotta » com » tc » util » 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.util 
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
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.util;
006:
007:        import com.tc.exception.ImplementMe;
008:        import com.tc.net.protocol.tcm.ChannelIDProvider;
009:        import com.tc.net.protocol.tcm.TestChannelIDProvider;
010:        import com.tc.object.BaseDSOTestCase;
011:        import com.tc.object.ClientObjectManagerImpl;
012:        import com.tc.object.MockTCObject;
013:        import com.tc.object.ObjectID;
014:        import com.tc.object.Portability;
015:        import com.tc.object.RemoteObjectManager;
016:        import com.tc.object.TCClassFactory;
017:        import com.tc.object.TCObject;
018:        import com.tc.object.TCObjectFactory;
019:        import com.tc.object.TestClassFactory;
020:        import com.tc.object.TestObjectFactory;
021:        import com.tc.object.TestRemoteObjectManager;
022:        import com.tc.object.bytecode.MockClassProvider;
023:        import com.tc.object.cache.EvictionPolicy;
024:        import com.tc.object.cache.NullCache;
025:        import com.tc.object.config.DSOClientConfigHelper;
026:        import com.tc.object.idprovider.api.ObjectIDProvider;
027:        import com.tc.object.idprovider.impl.ObjectIDProviderImpl;
028:        import com.tc.object.loaders.ClassProvider;
029:        import com.tc.object.logging.NullRuntimeLogger;
030:        import com.tc.object.logging.RuntimeLogger;
031:        import com.tc.object.tx.MockTransactionManager;
032:        import com.tc.util.sequence.SimpleSequence;
033:
034:        /**
035:         * Test to see if an adapted class has all of the adaptations we expect.
036:         */
037:        public class DsoFinalMethodTest extends BaseDSOTestCase {
038:            private String rootName;
039:            private Object rootObject;
040:            private MockClientObjectManagerImpl objectManager;
041:
042:            protected void setUp() throws Exception {
043:                super .setUp();
044:
045:                rootName = "testSyncRoot";
046:                rootObject = new Object();
047:                ObjectID objectID = new ObjectID(1);
048:                TCObject tcObject = new MockTCObject(objectID, rootObject);
049:                TestObjectFactory objectFactory = new TestObjectFactory();
050:                objectFactory.peerObject = rootObject;
051:                objectFactory.tcObject = tcObject;
052:                objectManager = new MockClientObjectManagerImpl(
053:                        new MockRemoteObjectManagerImpl(), configHelper(),
054:                        new ObjectIDProviderImpl(new SimpleSequence()),
055:                        new NullCache(), new NullRuntimeLogger(),
056:                        new TestChannelIDProvider(), new MockClassProvider(),
057:                        new TestClassFactory(), objectFactory);
058:
059:                objectManager
060:                        .setTransactionManager(new MockTransactionManagerImpl());
061:            }
062:
063:            protected void tearDown() throws Exception {
064:                super .tearDown();
065:                this .objectManager = null;
066:                this .rootName = null;
067:                this .rootObject = null;
068:            }
069:
070:            /**
071:             * This test makes sure that method retrieveRootID() of RemoteObjectManager will not be called when dsoFinal is set to
072:             * false when a root is being created.
073:             */
074:            public void testRootCreateOrReplaceWithNonDsoFinal()
075:                    throws Exception {
076:                // If retrieveRootID() of RemoteObjectManager is being called, this call will throw an
077:                // AssertionError.
078:                objectManager.lookupOrCreateRoot(rootName, rootObject, false);
079:            }
080:
081:            public void testRootCreateOrReplaceWithDsoFinal() throws Exception {
082:                try {
083:                    objectManager
084:                            .lookupOrCreateRoot(rootName, rootObject, true);
085:                    throw new AssertionError(
086:                            "should have thrown an AssertionError");
087:                } catch (AssertionError e) {
088:                    // expected.
089:                }
090:            }
091:
092:            private static class MockClientObjectManagerImpl extends
093:                    ClientObjectManagerImpl {
094:                public MockClientObjectManagerImpl(
095:                        RemoteObjectManager remoteObjectManager,
096:                        DSOClientConfigHelper clientConfiguration,
097:                        ObjectIDProvider idProvider, EvictionPolicy cache,
098:                        RuntimeLogger runtimeLogger,
099:                        ChannelIDProvider provider,
100:                        ClassProvider classProvider,
101:                        TCClassFactory classFactory,
102:                        TCObjectFactory objectFactory) {
103:                    super (remoteObjectManager, clientConfiguration, idProvider,
104:                            cache, runtimeLogger, provider, classProvider,
105:                            classFactory, objectFactory, new TestPortability(),
106:                            null);
107:                }
108:
109:                public boolean isPortable(Object obj) {
110:                    return true;
111:                }
112:
113:                public Object lookupObject(ObjectID objectID) {
114:                    return null;
115:                }
116:            }
117:
118:            private static class MockRemoteObjectManagerImpl extends
119:                    TestRemoteObjectManager {
120:
121:                public ObjectID retrieveRootID(String name) {
122:                    throw new AssertionError(
123:                            "retrieveRootID should not be called.");
124:                }
125:            }
126:
127:            private static class MockTransactionManagerImpl extends
128:                    MockTransactionManager {
129:                public void createRoot(String name, ObjectID id) {
130:                    return;
131:                }
132:
133:                public void createObject(TCObject source) {
134:                    return;
135:                }
136:            }
137:
138:            private static class TestPortability implements  Portability {
139:
140:                public boolean allowSubclassOf(Class clazz) {
141:                    return true;
142:                }
143:
144:                public NonPortableReason getNonPortableReason(
145:                        Class topLevelClass) {
146:                    throw new ImplementMe();
147:                }
148:
149:                public boolean isInstrumentationNotNeeded(String name) {
150:                    return false;
151:                }
152:
153:                public boolean isPortableClass(Class clazz) {
154:                    return true;
155:                }
156:
157:                public boolean isClassPhysicallyInstrumented(Class clazz) {
158:                    throw new ImplementMe();
159:                }
160:
161:                public boolean isPortableInstance(Object obj) {
162:                    return true;
163:                }
164:
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.