~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/detection/multicast/MulticastDetectorTestCase.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.detection.multicast;
 
2
 
 
3
import java.security.AccessController;
 
4
import java.security.PrivilegedActionException;
 
5
import java.security.PrivilegedExceptionAction;
 
6
 
 
7
import junit.framework.TestCase;
 
8
import org.jboss.remoting.detection.multicast.MulticastDetector;
 
9
import javax.management.MBeanServer;
 
10
import javax.management.MBeanServerFactory;
 
11
import javax.management.ObjectName;
 
12
 
 
13
/**
 
14
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
15
 */
 
16
public class MulticastDetectorTestCase extends TestCase
 
17
{
 
18
 
 
19
   private MBeanServer server;
 
20
 
 
21
   private ObjectName objectName;
 
22
 
 
23
   protected void setUp() throws Exception
 
24
   {
 
25
      super.setUp();
 
26
      
 
27
      try
 
28
      {
 
29
          server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction()
 
30
          {
 
31
             public Object run() throws Exception
 
32
             {
 
33
                 return MBeanServerFactory.createMBeanServer();
 
34
             }
 
35
          });
 
36
      }
 
37
      catch (PrivilegedActionException e)
 
38
      {
 
39
          throw (Exception) e.getCause();
 
40
      }
 
41
      
 
42
      objectName = new ObjectName("remoting:type=MulticastDetector");
 
43
   }
 
44
 
 
45
   protected void tearDown() throws Exception
 
46
   {
 
47
      super.tearDown();
 
48
   }
 
49
 
 
50
   public void testStopWithoutStart() throws Exception
 
51
   {
 
52
      MulticastDetector detector = new MulticastDetector();
 
53
      server.registerMBean(detector, objectName);
 
54
// don't call detector.start();
 
55
      Thread.sleep(1000);
 
56
 
 
57
      server.unregisterMBean(objectName);
 
58
      detector.stop();
 
59
   }
 
60
 
 
61
   public void testCallingStopTwice() throws Exception
 
62
   {
 
63
      MulticastDetector detector = new MulticastDetector();
 
64
      server.registerMBean(detector, objectName);
 
65
      detector.start();
 
66
      Thread.sleep(1000);
 
67
 
 
68
      server.unregisterMBean(objectName);
 
69
      detector.stop();
 
70
      detector.stop();
 
71
   }
 
72
}