KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > kernel > jmx > StopJMXServerThreadTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: StopJMXServerThreadTest.java 5:18:36 PM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.kernel.jmx;
23
24 import javax.management.remote.JMXConnectorServer JavaDoc;
25 import javax.management.remote.JMXServiceURL JavaDoc;
26
27 import junit.framework.TestCase;
28
29 import org.easymock.classextension.EasyMock;
30 import org.objectweb.petals.util.LoggingUtil;
31
32 /**
33  * Test of the StopJMXServerThread
34  *
35  * @author ddesjardins - eBMWebsourcing
36  */

37 public class StopJMXServerThreadTest extends TestCase {
38
39     public void testRun() throws Throwable JavaDoc {
40         LoggingUtil log = EasyMock.createMock(LoggingUtil.class);
41         JMXConnectorServer JavaDoc connectorServer = EasyMock
42             .createMock(JMXConnectorServer JavaDoc.class);
43         String JavaDoc sJmxURL = "service:jmx:rmi:///jndi/rmi://127.0.0.1:8081/management/rmi-jmx-connector";
44         JMXServiceURL JavaDoc jmxUrl = new JMXServiceURL JavaDoc(sJmxURL);
45         StopJMXServerThread stopJMXServerThread = new StopJMXServerThread(
46             connectorServer, log);
47
48         log.debug("JMX server at " + sJmxURL + " stopped");
49         connectorServer.stop();
50         EasyMock.expect(connectorServer.getAddress()).andReturn(jmxUrl);
51
52         EasyMock.replay(log);
53         EasyMock.replay(connectorServer);
54
55         stopJMXServerThread.log = log;
56
57         stopJMXServerThread.run();
58     }
59 }
60
Popular Tags