01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.jbossmx.compliance.server;
23:
24: import org.jboss.test.jbossmx.compliance.TestCase;
25:
26: import javax.management.MBeanServer;
27: import javax.management.MBeanServerFactory;
28: import java.util.List;
29:
30: public class MBeanServerFactoryTestCase extends TestCase {
31: public MBeanServerFactoryTestCase(String s) {
32: super (s);
33: }
34:
35: public void testFindNonCreated() {
36: MBeanServer server = MBeanServerFactory.newMBeanServer();
37: List mbsList = MBeanServerFactory.findMBeanServer(null);
38: assertEquals(0, mbsList.size());
39: }
40:
41: public void testCreateFindAndRelease() {
42: MBeanServer server = null;
43: List mbsList = null;
44:
45: try {
46: server = MBeanServerFactory.createMBeanServer();
47: mbsList = MBeanServerFactory.findMBeanServer(null);
48: assertEquals(1, mbsList.size());
49: } finally {
50: if (null != server) {
51: MBeanServerFactory.releaseMBeanServer(server);
52: }
53: }
54:
55: mbsList = MBeanServerFactory.findMBeanServer(null);
56: assertEquals(0, mbsList.size());
57: }
58:
59: public void testRemoveNonCreated() {
60: try {
61: MBeanServer server = MBeanServerFactory.newMBeanServer();
62: MBeanServerFactory.releaseMBeanServer(server);
63: fail("expected an IllegalArgumentException");
64: } catch (IllegalArgumentException e) {
65: } catch (Exception e) {
66: fail("expected an IllegalArgumentException but got: "
67: + e.getMessage());
68: }
69: }
70:
71: public void testDomainCreated() {
72: String domain = "dOmAiN";
73: MBeanServer server = null;
74: try {
75: server = MBeanServerFactory.createMBeanServer(domain);
76: assertEquals(domain, server.getDefaultDomain());
77: List mbsList = MBeanServerFactory.findMBeanServer(null);
78: assertEquals(server, mbsList.get(0));
79: assertTrue("expected server reference equality", mbsList
80: .get(0) == server);
81: } finally {
82: if (null != server) {
83: MBeanServerFactory.releaseMBeanServer(server);
84: }
85: }
86: }
87:
88: public void testDomainNonCreated() {
89: String domain = "dOmAiN";
90: MBeanServer server = MBeanServerFactory.newMBeanServer(domain);
91: assertEquals(domain, server.getDefaultDomain());
92: }
93:
94: public void testFindByAgentID() {
95: // FIXME THS - flesh this out
96: }
97:
98: }
|