Source Code Cross Referenced for LifeCycleTest.java in  » Net » Terracotta » com » tctest » spring » integrationtests » 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 » Net » Terracotta » com.tctest.spring.integrationtests.tests 
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.tctest.spring.integrationtests.tests;
005:
006:        import com.tc.test.server.appserver.deployment.AbstractTwoServerDeploymentTest;
007:        import com.tc.test.server.appserver.deployment.DeploymentBuilder;
008:        import com.tctest.spring.bean.ILifeCycle;
009:        import com.tctest.spring.integrationtests.SpringTwoServerTestSetup;
010:
011:        import java.util.List;
012:
013:        import junit.framework.Test;
014:
015:        /**
016:         * Test the clustered bean behavior with those life cycle methods 1. setBeanName 2. setApplicationContext 3.
017:         * afterPropertiesSet 4. destroy
018:         * 
019:         * @author Liyu Yi
020:         */
021:        public class LifeCycleTest extends AbstractTwoServerDeploymentTest {
022:
023:            private static final String REMOTE_SERVICE_NAME = "LifeCycle";
024:            private static final String BEAN_DEFINITION_FILE_FOR_TEST = "classpath:/com/tctest/spring/beanfactory.xml";
025:            private static final String CONFIG_FILE_FOR_TEST = "/tc-config-files/lifecycle-tc-config.xml";
026:
027:            private ILifeCycle mLifeCycleBean1;
028:            private ILifeCycle mLifeCycleBean2;
029:
030:            protected void setUp() throws Exception {
031:                super .setUp();
032:
033:                mLifeCycleBean1 = (ILifeCycle) server0.getProxy(
034:                        ILifeCycle.class, REMOTE_SERVICE_NAME);
035:                mLifeCycleBean2 = (ILifeCycle) server1.getProxy(
036:                        ILifeCycle.class, REMOTE_SERVICE_NAME);
037:            }
038:
039:            public void test() throws Exception {
040:                logger.debug("testing bean life cycle");
041:
042:                long systemId1 = mLifeCycleBean1.getSystemId();
043:                long systemId2 = mLifeCycleBean2.getSystemId();
044:
045:                assertTrue("Transient properties also share the same value.",
046:                        systemId1 != systemId2);
047:
048:                List prop1 = mLifeCycleBean1.getProp();
049:                List prop2 = mLifeCycleBean2.getProp();
050:
051:                // property might be referenced by other beans
052:                assertEquals(prop1, prop2);
053:                assertTrue(prop1.contains("" + systemId1));
054:                assertTrue(prop1.contains("" + systemId2));
055:
056:                List records1 = mLifeCycleBean1.getInvocationRecords();
057:                List records2 = mLifeCycleBean2.getInvocationRecords();
058:
059:                // check regular contract
060:                assertTrue("Bean1 afterPropertiesSet not invoked: " + records1,
061:                        records1.contains("afterPropertiesSet-" + systemId1));
062:                assertTrue("Bean2 afterPropertiesSet not invoked: " + records2,
063:                        records2.contains("afterPropertiesSet-" + systemId2));
064:
065:                assertTrue("Bean1 setBeanName not invoked: " + records1,
066:                        records1.contains("setBeanName-" + systemId1));
067:                assertTrue("Bean2 setBeanName not invoked: " + records2,
068:                        records2.contains("setBeanName-" + systemId2));
069:
070:                assertTrue("Bean1 setApplicationContext not invoked: "
071:                        + records1, records1.contains("setApplicationContext-"
072:                        + systemId1));
073:                assertTrue("Bean2 setApplicationContext not invoked: "
074:                        + records2, records2.contains("setApplicationContext-"
075:                        + systemId2));
076:
077:                // check distributed behavior
078:                assertTrue("Replication failure: " + records1, records1
079:                        .contains("afterPropertiesSet-" + systemId2));
080:                assertTrue("Replication failure: " + records2, records2
081:                        .contains("afterPropertiesSet-" + systemId1));
082:
083:                assertTrue("Replication failure: " + records1, records1
084:                        .contains("setBeanName-" + systemId2));
085:                assertTrue("Replication failure: " + records2, records2
086:                        .contains("setBeanName-" + systemId1));
087:
088:                assertTrue("Replication failure: " + records1, records1
089:                        .contains("setApplicationContext-" + systemId2));
090:                assertTrue("Replication failure: " + records2, records2
091:                        .contains("setApplicationContext-" + systemId1));
092:
093:                mLifeCycleBean1.closeAppCtx();
094:                mLifeCycleBean2.closeAppCtx();
095:
096:                records1 = mLifeCycleBean1.getInvocationRecords();
097:                records2 = mLifeCycleBean2.getInvocationRecords();
098:
099:                assertTrue("Bean1 destroy not invoked: " + records1, records1
100:                        .contains("destroy-" + systemId1));
101:                assertTrue("Bean2 destroy not invoked: " + records2, records2
102:                        .contains("destroy-" + systemId2));
103:
104:                assertTrue("Replication failure: " + records1, records1
105:                        .contains("destroy-" + systemId2));
106:                assertTrue("Replication failure: " + records2, records2
107:                        .contains("destroy-" + systemId1));
108:
109:                logger.debug("!!!! Asserts passed !!!");
110:            }
111:
112:            private static class LifeCycleTestSetup extends
113:                    SpringTwoServerTestSetup {
114:                private LifeCycleTestSetup() {
115:                    super (LifeCycleTest.class, CONFIG_FILE_FOR_TEST,
116:                            "test-lifecycle");
117:                }
118:
119:                protected void configureWar(DeploymentBuilder builder) {
120:                    builder
121:                            .addBeanDefinitionFile(BEAN_DEFINITION_FILE_FOR_TEST);
122:
123:                    builder.addRemoteService(RmiServiceExporter.class,
124:                            "LifeCycle", "lifeCycleBean", ILifeCycle.class);
125:
126:                    builder
127:                            .addRemoteServiceBlock("<bean id=\"lifeCycleBean\" class=\"com.tctest.spring.bean.LifeCycleBean\">"
128:                                    + "\n"
129:                                    + "<property name=\"prop\" ref=\"recorder\"/>"
130:                                    + "\n" + "</bean>");
131:
132:                }
133:            }
134:
135:            private static class RmiServiceExporter extends
136:                    org.springframework.remoting.rmi.RmiServiceExporter {
137:                public void destroy() {
138:                    logger
139:                            .info("destroy method override in RmiServiceExporter.");
140:                }
141:            }
142:
143:            public static Test suite() {
144:                return new LifeCycleTestSetup();
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.