Buggy code:
@ RunWith ( Arquillian . class ) @ RunAsClient public class CommandDispatcherTestCase extends ClusterAbstractTestCase { private static final long VIEW_CHANGE_WAIT = TimeoutUtil . adjust ( 2000 ) ; private static final Logger log = Logger . getLogger ( CommandDispatcherTestCase . class ) ; private static final String MODULE_NAME = "command-dispatcher" ; private static final String CLIENT_PROPERTIES = "cluster//ejb3//stateless//jboss-ejb-client.properties" ; @ Deployment ( name = DEPLOYMENT_1 , managed = false , testable = false ) @ TargetsContainer ( CONTAINER_1 ) public static Archive < ? > createDeploymentForContainer1 ( ) { } @ Deployment ( name = DEPLOYMENT_2 , managed = false , testable = false ) @ TargetsContainer ( CONTAINER_2 ) public static Archive < ? > createDeploymentForContainer2 ( ) { } private static Archive < ? > createDeployment ( ) { } @ Test public void test ( ) throws Exception { <START_BUG> String cluster = "server" ; <END_BUG> String nodeNameFormat = "%s//%s" ; String nodeName1 = String . format ( nodeNameFormat , NODE_1 , cluster ) ; String nodeName2 = String . format ( nodeNameFormat , NODE_2 , cluster ) ; ContextSelector < EJBClientContext > selector = EJBClientContextSelector . setup ( CommandDispatcherTestCase . CLIENT_PROPERTIES ) ; try ( EJBDirectory directory = new RemoteEJBDirectory ( CommandDispatcherTestCase . MODULE_NAME ) ) { ClusterTopologyRetriever bean = directory . lookupStateless ( ClusterTopologyRetrieverBean . class , ClusterTopologyRetriever . class ) ; ClusterTopology topology = bean . getClusterTopology ( ) ; assertEquals ( 2 , topology . getNodes ( ) . size ( ) ) ; assertTrue ( topology . getNodes ( ) . toString ( ) , topology . getNodes ( ) . contains ( nodeName1 ) ) ; assertTrue ( topology . getNodes ( ) . toString ( ) , topology . getNodes ( ) . contains ( nodeName2 ) ) ; assertFalse ( ( ( ( topology . getRemoteNodes ( ) . toString ( ) ) + "<seq2seq4repair_space>should<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>" ) + ( topology . getLocalNode ( ) ) ) , topology . getRemoteNodes ( ) . contains ( topology . getLocalNode ( ) ) ) ; undeploy ( DEPLOYMENT_2 ) ; topology = bean . getClusterTopology ( ) ; assertEquals ( 1 , topology . getNodes ( ) . size ( ) ) ; assertTrue ( topology . getNodes ( ) . contains ( nodeName1 ) ) ; assertEquals ( nodeName1 , topology . getLocalNode ( ) ) ; assertTrue ( topology . getRemoteNodes ( ) . toString ( ) , topology . getRemoteNodes ( ) . isEmpty ( ) ) ; deploy ( DEPLOYMENT_2 ) ; Thread . sleep ( CommandDispatcherTestCase . VIEW_CHANGE_WAIT ) ; topology = bean . getClusterTopology ( ) ; assertEquals ( 2 , topology . getNodes ( ) . size ( ) ) ; assertTrue ( topology . getNodes ( ) . contains ( nodeName1 ) ) ; assertTrue ( topology . getNodes ( ) . contains ( nodeName2 ) ) ; assertFalse ( ( ( ( topology . getRemoteNodes ( ) . toString ( ) ) + "<seq2seq4repair_space>should<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>" ) + ( topology . getLocalNode ( ) ) ) , topology . getRemoteNodes ( ) . contains ( topology . getLocalNode ( ) ) ) ; stop ( CONTAINER_1 ) ; topology = bean . getClusterTopology ( ) ; assertEquals ( 1 , topology . getNodes ( ) . size ( ) ) ; assertTrue ( topology . getNodes ( ) . contains ( nodeName2 ) ) ; assertEquals ( nodeName2 , topology . getLocalNode ( ) ) ; assertTrue ( topology . getRemoteNodes ( ) . toString ( ) , topology . getRemoteNodes ( ) . isEmpty ( ) ) ; start ( CONTAINER_1 ) ; Thread . sleep ( CommandDispatcherTestCase . VIEW_CHANGE_WAIT ) ; topology = bean . getClusterTopology ( ) ; assertEquals ( topology . getNodes ( ) . toString ( ) , 2 , topology . getNodes ( ) . size ( ) ) ; assertTrue ( ( ( ( topology . getNodes ( ) . toString ( ) ) + "<seq2seq4repair_space>should<seq2seq4repair_space>contain<seq2seq4repair_space>" ) + nodeName1 ) , topology . getNodes ( ) . contains ( nodeName1 ) ) ; assertTrue ( ( ( ( topology . getNodes ( ) . toString ( ) ) + "<seq2seq4repair_space>should<seq2seq4repair_space>contain<seq2seq4repair_space>" ) + nodeName2 ) , topology . getNodes ( ) . contains ( nodeName2 ) ) ; assertFalse ( ( ( ( topology . getRemoteNodes ( ) . toString ( ) ) + "<seq2seq4repair_space>should<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>" ) + ( topology . getLocalNode ( ) ) ) , topology . getRemoteNodes ( ) . contains ( topology . getLocalNode ( ) ) ) ; } finally { if ( selector != null ) { EJBClientContext . setSelector ( selector ) ; } } } }

Fix:
String cluster = "ee" ;