Source Code Cross Referenced for BindingServiceUnitTestCase.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » binding » 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 » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.binding 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.test.binding;
023:
024:        import java.util.ArrayList;
025:        import java.util.HashSet;
026:        import java.util.Iterator;
027:        import java.util.Properties;
028:        import java.util.Set;
029:
030:        import javax.management.AttributeNotFoundException;
031:        import javax.management.ObjectName;
032:        import javax.naming.Context;
033:        import javax.naming.InitialContext;
034:
035:        import org.jboss.jmx.adaptor.rmi.RMIAdaptorExt;
036:        import org.jboss.management.j2ee.StateManageable;
037:        import org.jboss.system.BarrierController;
038:        import org.jboss.system.ServiceMBean;
039:        import org.jboss.test.JBossTestCase;
040:
041:        /** Tests of the effect of the binding manager service on a two jboss instances.
042:         * This needs the configurations created by the test-example-binding-manager
043:         * target running to pass.
044:         *
045:         * @author Scott.Stark@jboss.org
046:         * @version $Revision: 57211 $
047:         */
048:        public class BindingServiceUnitTestCase extends JBossTestCase {
049:            static final String SERVER0_JNDI_URL = "jnp://"
050:                    + System.getProperty("jbosstest.server.host", "localhost")
051:                    + ":1199";
052:            static final String SERVER1_JNDI_URL = "jnp://"
053:                    + System.getProperty("jbosstest.server.host", "localhost")
054:                    + ":1299";
055:            static HashSet VALID_STATES = new HashSet();
056:
057:            static {
058:                // JSR-77 running state
059:                VALID_STATES.add("j2ee.state.running");
060:                // JBoss mbean service started state
061:                VALID_STATES.add("Started");
062:            }
063:
064:            public BindingServiceUnitTestCase(String name) {
065:                super (name);
066:            }
067:
068:            /** Query for all mbeans in the jnp://localhost:1199 and jnp://localhost:1299
069:             * servers and assert that every mbean with a State attribute has reached
070:             * the ServiceMBean.STARTED state.
071:             * 
072:             * @throws Exception
073:             */
074:            public void testAvailableServicesServer0() throws Exception {
075:                int count = testAvailableServices(SERVER0_JNDI_URL);
076:                log.info("server0 service count:" + count);
077:            }
078:
079:            public void testAvailableServicesServer1() throws Exception {
080:                int count = testAvailableServices(SERVER1_JNDI_URL);
081:                log.info("server1 service count:" + count);
082:            }
083:
084:            private int testAvailableServices(String jndiURL) throws Exception {
085:                log.info("+++ testAvailableServices, jndiURL=" + jndiURL);
086:
087:                Properties env = new Properties();
088:                env.setProperty(Context.PROVIDER_URL, jndiURL);
089:                InitialContext ctx = new InitialContext(env);
090:                RMIAdaptorExt server = (RMIAdaptorExt) ctx
091:                        .lookup("jmx/invoker/RMIAdaptor");
092:                ObjectName all = new ObjectName("*:*");
093:                Set allNames = server.queryNames(all, null);
094:                ArrayList serverErrors = new ArrayList();
095:                Iterator names = allNames.iterator();
096:                int serviceCount = 0;
097:                while (names.hasNext()) {
098:                    ObjectName name = (ObjectName) names.next();
099:                    try {
100:                        // BarrierController Barriers can be in CREATED or STOPPED state
101:                        // e.g. if the controller's startup notification hasn't been received,
102:                        // so log a message and exclude them from the search.
103:                        boolean isBarrier = server.isInstanceOf(name,
104:                                BarrierController.Barrier.class.getName());
105:                        if (isBarrier) {
106:                            log
107:                                    .debug("Skipping BarrierController.Barrier service: '"
108:                                            + name
109:                                            + "', in state: "
110:                                            + (String) server.getAttribute(
111:                                                    name, "StateString"));
112:                            continue;
113:                        }
114:                        /* If this is a JSR-77 mbean, only the StateManageable types
115:                         have a meaningful state string
116:                         */
117:                        boolean jsr77State = server.isInstanceOf(name,
118:                                StateManageable.class.getName());
119:                        if (jsr77State) {
120:                            // the stateManageable also needs to be true
121:                            Boolean flag = (Boolean) server.getAttribute(name,
122:                                    "stateManageable");
123:                            jsr77State = flag.booleanValue();
124:                        }
125:                        boolean mbeanService = server.isInstanceOf(name,
126:                                ServiceMBean.class.getName());
127:                        if (jsr77State == true || mbeanService == true) {
128:                            serviceCount++;
129:                            String state = (String) server.getAttribute(name,
130:                                    "StateString");
131:                            if (VALID_STATES.contains(state) == false) {
132:                                String msg = name + " is not Started, state="
133:                                        + state;
134:                                log.error(msg);
135:                                serverErrors.add(msg);
136:                            }
137:                        }
138:                    } catch (AttributeNotFoundException e) {
139:                        // Ignore as a non-service
140:                    }
141:                }
142:                assertTrue("All services are started, errors="
143:                        + serverErrors.size(), serverErrors.size() == 0);
144:                return serviceCount;
145:            }
146:
147:            /**
148:             * Override to ignore 
149:             */
150:            public void testServerFound() {
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.