[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/mgmt ...

Brian Stansberry brian.stansberry at jboss.com
Thu Jul 12 18:36:58 EDT 2007


  User: bstansberry
  Date: 07/07/12 18:36:58

  Added:       tests/functional/org/jboss/cache/mgmt  Tag:
                        Branch_JBossCache_1_4_0
                        ChannelRegistrationTest.java
  Log:
  [JBCACHE-1048] TreeCache registers channel in JMX if it doesn't get it from ChannelFactory
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +140 -0    JBossCache/tests/functional/org/jboss/cache/mgmt/Attic/ChannelRegistrationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ChannelRegistrationTest.java
  ===================================================================
  RCS file: ChannelRegistrationTest.java
  diff -N ChannelRegistrationTest.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ ChannelRegistrationTest.java	12 Jul 2007 22:36:58 -0000	1.1.2.1
  @@ -0,0 +1,140 @@
  +/*
  + * JBoss, Home of Professional Open Source.
  + * Copyright 2006, Red Hat Middleware LLC, and individual contributors
  + * as indicated by the @author tags. See the copyright.txt file in the
  + * distribution for a full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
  +
  +package org.jboss.cache.mgmt;
  +
  +import java.util.Set;
  +
  +import javax.management.MBeanServer;
  +import javax.management.MBeanServerFactory;
  +import javax.management.ObjectName;
  +
  +import org.jboss.cache.PropertyConfigurator;
  +import org.jboss.cache.TreeCache;
  +
  +import junit.framework.Test;
  +import junit.framework.TestCase;
  +import junit.framework.TestSuite;
  +
  +/**
  + * Test for http://jira.jboss.com/jira/browse/JBCACHE-1048
  + * 
  + * @author Brian Stansberry
  + */
  +public class ChannelRegistrationTest extends TestCase
  +{
  +   private static final String CLUSTER_NAME = "JBCACHE-1048";    
  +
  +   private MBeanServer m_server;
  +
  +   TreeCache cache = null;
  +   boolean optimistic = false;
  +   /**
  +    * 
  +    */
  +   public ChannelRegistrationTest()
  +   {
  +      super();
  +   }
  +
  +   /**
  +    * @param arg0
  +    */
  +   public ChannelRegistrationTest(String arg0)
  +   {
  +      super(arg0);
  +   }
  +
  +   public static Test suite()
  +   {
  +      return new TestSuite(ChannelRegistrationTest.class);
  +   }
  +   protected void setUp() throws Exception
  +   {
  +      super.setUp();
  +      m_server = MBeanServerFactory.createMBeanServer();
  +      cache = createCache(CLUSTER_NAME);
  +   }
  +
  +   protected void tearDown() throws Exception
  +   {
  +      m_server = null;
  +      
  +      super.tearDown();
  +      if(cache != null)
  +      {
  +         cache.destroyService();
  +         cache = null;
  +      }
  +   }
  +
  +   private TreeCache createCache(String clusterName) throws Exception
  +   {
  +      TreeCache cache = new TreeCache();
  +      PropertyConfigurator config=new PropertyConfigurator();
  +      config.configure(cache, "META-INF/replSync-service.xml");
  +      cache.setCacheMode(TreeCache.REPL_SYNC);
  +      cache.setClusterName(clusterName);
  +      
  +      return cache;
  +   }
  +   
  +   public void testChannelRegistration() throws Exception
  +   {
  +      m_server.registerMBean(cache, new ObjectName("jboss.cache:test=ChannelRegistrationTest"));
  +      
  +      cache.startService();     
  +      
  +      Set channelMBean = getChannelMBeans();
  +      assertNotNull("Channel mbean registered", channelMBean);
  +      assertEquals("Only one channel mbean", 1, channelMBean.size()); 
  +      
  +      Set protocolMBeans = getProtocolMBeans();
  +      assertNotNull("Protocol mbeans registered", channelMBean);
  +      assertTrue("Multiple protocol mbeans", protocolMBeans.size() > 2);
  +      
  +      cache.stopService();
  +      
  +      channelMBean = getChannelMBeans();
  +      if (channelMBean != null)
  +         assertTrue("Channel mbean undeployed", channelMBean.size() == 0); 
  +      
  +      protocolMBeans = getProtocolMBeans();
  +      if (protocolMBeans != null)
  +         assertTrue("Protocol mbeans undeployed", protocolMBeans.size() == 0); 
  +      
  +      
  +   }
  +   
  +   protected Set getChannelMBeans() throws Exception
  +   {
  +      ObjectName on = new ObjectName("jboss.jgroups:type=channel,cluster=JBCACHE-1048");
  +      return m_server.queryNames(on, null);
  +   }
  +   
  +   protected Set getProtocolMBeans() throws Exception
  +   {
  +      ObjectName on = new ObjectName("jboss.jgroups:*,type=protocol,cluster=JBCACHE-1048");
  +      return m_server.queryNames(on, null);
  +   }
  +
  +}
  
  
  



More information about the jboss-cvs-commits mailing list