alfresco-community-repo/source/java/org/alfresco/repo/jgroups/AlfrescoJGroupsChannelFactoryTest.java
Derek Hulley b6b4ffda44 Merged V3.2 to HEAD
15590: Merged V3.1 to V3.2 (JGroups)
      15110: Upgraded JGroups (potential fix for ETHREEOH-1497: JGroups UDP stack is not working)
      15141: Close existing Channel before starting a new one
      15142: Reduced pings' num_initial_members to 2
      15143: More succint logging to make DEBUG more useful
      15144: Fixed JGroups jar path in classpath
      15150: Fixed SDK classpath
      15174: JGroups default configuration changes: FD_SIMPLE
      15205: Minor JGroups-EHCache tweaks (Real dummy channel, etc)
   15592: Merged V3.1 to V3.2
      15591: Use Channel.connect without state transfer
   15747: (record only) Added beta warning in footer
   15786: (record ony) Merge 3.1 to 3.2:
   15861: Merged V3.1 to V3.2
      15858: (record-only) Fix for ETHREEOH-2698: CLONE -Enterprise 3.x / Searching with Speech Marks ("") for a User ID causes an Error
   15881: (record only) ALFCOM-3300: Document move when already exists makes alfresco enter an infinite loop
   15889: Cleanup of old static declarations
   15890: (record only) Undid accidental offshort commit
   15951: (record only) Removed mobile.war from war bundles.  Added oracle & mssql config.
   15968: (record only) Updated readme
   16241: (record only) Fix typos in installer
___________________________________________________________________
Modified: svn:mergeinfo
   Reverse-merged /alfresco/BRANCHES/V3.2:r15888
   Merged /alfresco/BRANCHES/V3.1:r15110,15141-15144,15150,15174,15205,15591,15779,15858
   Merged /alfresco/BRANCHES/V3.2:r15590,15592,15747,15780,15786,15861,15881,15889-15890,15951,15968,16241


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16866 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2009-10-13 13:39:08 +00:00

96 lines
3.3 KiB
Java

/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.jgroups;
import org.jgroups.Channel;
import org.jgroups.Message;
import junit.framework.TestCase;
/**
* @see AlfrescoJGroupsChannelFactory
*
* @author Derek Hulley
* @since 2.1.3
*/
public class AlfrescoJGroupsChannelFactoryTest extends TestCase
{
private static byte[] bytes = new byte[65536];
static
{
for (int i = 0; i < bytes.length; i++)
{
bytes[i] = 1;
}
}
private String appRegion;
@Override
protected void setUp() throws Exception
{
appRegion = getName();
}
/**
* Check that the channel is behaving
*/
private void stressChannel(Channel channel) throws Exception
{
System.out.println("Test: " + getName());
System.out.println(" Channel: " + channel);
System.out.println(" Cluster: " + channel.getClusterName());
channel.send(null, null, Boolean.TRUE);
channel.send(new Message(null, null, bytes));
}
public void testNoCluster() throws Exception
{
Channel channel = AlfrescoJGroupsChannelFactory.getChannel(appRegion);
stressChannel(channel);
}
public void testBasicCluster() throws Exception
{
AlfrescoJGroupsChannelFactory.changeClusterNamePrefix("blah");
AlfrescoJGroupsChannelFactory.rebuildChannels();
Channel channel = AlfrescoJGroupsChannelFactory.getChannel(appRegion);
stressChannel(channel);
}
public void testHotSwapCluster() throws Exception
{
AlfrescoJGroupsChannelFactory.changeClusterNamePrefix("ONE");
AlfrescoJGroupsChannelFactory.rebuildChannels();
Channel channel1 = AlfrescoJGroupsChannelFactory.getChannel(appRegion);
stressChannel(channel1);
AlfrescoJGroupsChannelFactory.changeClusterNamePrefix("TWO");
AlfrescoJGroupsChannelFactory.rebuildChannels();
Channel channel2 = AlfrescoJGroupsChannelFactory.getChannel(appRegion);
stressChannel(channel1);
assertTrue("Channel reference must be the same", channel1 == channel2);
}
}