Buggy code:
private static final int LDAP_PORT = 10389 ; private static final String DEP1 = "DEP1" ; private static final String DEP2 = "DEP2" ; private static final String DEP3 = "DEP3" ; private static final String DEP4 = "DEP4" ; private static final String [ ] ROLE_NAMES = new String [ ] { "TheDuke" , "Echo" , "TheDuke2" , "Echo2" , "JBossAdmin" , "jduke" , "jduke2" , "RG1" , "RG2" , "RG3" , "R1" , "R2" , "R3" , "R4" , "R5" , "Roles" } ; private static final String QUERY_ROLES ; @ ArquillianResource ManagementClient mgmtClient ; @ Deployment ( name = AdvancedLdapLoginModuleTestCase . DEP1 , testable = false ) public static WebArchive deployment1 ( ) { } @ Deployment ( name = AdvancedLdapLoginModuleTestCase . DEP2 , testable = false ) public static WebArchive deployment2 ( ) { } @ Deployment ( name = AdvancedLdapLoginModuleTestCase . DEP3 , testable = false ) public static WebArchive deployment3 ( ) { } @ Deployment ( name = AdvancedLdapLoginModuleTestCase . DEP4 , testable = false ) public static WebArchive deployment4 ( ) { } @ Test @ OperateOnDeployment ( AdvancedLdapLoginModuleTestCase . DEP1 ) public void test1 ( @ ArquillianResource URL webAppURL ) throws Exception { } @ Test @ OperateOnDeployment ( AdvancedLdapLoginModuleTestCase . DEP2 ) public void test2 ( @ ArquillianResource URL webAppURL ) throws Exception { } @ Test @ OperateOnDeployment ( AdvancedLdapLoginModuleTestCase . DEP3 ) public void test3 ( @ ArquillianResource URL webAppURL ) throws Exception { } @ Test @ OperateOnDeployment ( AdvancedLdapLoginModuleTestCase . DEP4 ) public void test4 ( @ ArquillianResource URL webAppURL ) throws Exception { } private static WebArchive createWar ( final String deploymentName ) { } private void testDeployment ( URL webAppURL , String ... assignedRoles ) throws IOException , MalformedURLException , URISyntaxException , PrivilegedActionException , LoginException , ClientProtocolException { } private URI getServletURI ( final URL webAppURL , final String servletPath ) throws URISyntaxException { } private void assertInRole ( final String rolePrintResponse , String role ) { } private void assertNotInRole ( final String rolePrintResponse , String role ) { } @ CreateDS ( name = "JBossDS" , factory = InMemoryDirectoryServiceFactory . class , partitions = { @ CreatePartition ( name = "jboss" , suffix = "dc=jboss,dc=org" , contextEntry = @ ContextEntry ( entryLdif = "dn:<seq2seq4repair_space>dc=jboss,dc=org\n" + ( ( "dc:<seq2seq4repair_space>jboss\n" + "objectClass:<seq2seq4repair_space>top\n" ) + "objectClass:<seq2seq4repair_space>domain\n\n" ) ) , indexes = { @ CreateIndex ( attribute = "objectClass" ) , @ CreateIndex ( attribute = "dc" ) , @ CreateIndex ( attribute = "ou" ) } ) } , additionalInterceptors = { KeyDerivationInterceptor . class } ) @ CreateLdapServer ( transports = { @ CreateTransport ( protocol = "LDAP" , port = AdvancedLdapLoginModuleTestCase . LDAP_PORT ) } , saslHost = "localhost" , saslPrincipal = "ldap//localhost@JBOSS.ORG" , saslMechanisms = { @ SaslMechanism ( name = SupportedSaslMechanisms . PLAIN , implClass = PlainMechanismHandler . class ) , @ SaslMechanism ( name = SupportedSaslMechanisms . CRAM_MD5 , implClass = CramMd5MechanismHandler . class ) , @ SaslMechanism ( name = SupportedSaslMechanisms . DIGEST_MD5 , implClass = DigestMd5MechanismHandler . class ) , @ SaslMechanism ( name = SupportedSaslMechanisms . GSSAPI , implClass = GssapiMechanismHandler . class ) , @ SaslMechanism ( name = SupportedSaslMechanisms . NTLM , implClass = NtlmMechanismHandler . class ) , @ SaslMechanism ( name = SupportedSaslMechanisms . GSS_SPNEGO , implClass = NtlmMechanismHandler . class ) } ) @ CreateKdcServer ( primaryRealm = "JBOSS.ORG" , kdcPrincipal = "krbtgt//JBOSS.ORG@JBOSS.ORG" , searchBaseDn = "dc=jboss,dc=org" , transports = { @ CreateTransport ( protocol = "UDP" , port = 6088 ) } ) static class DirectoryServerSetupTask implements ServerSetupTask { private DirectoryService directoryService ; private KdcServer kdcServer ; private LdapServer ldapServer ; private boolean removeBouncyCastle = false ; public void setup ( ManagementClient managementClient , String containerId ) throws Exception { try { if ( ( Security . getProvider ( PROVIDER_NAME ) ) == null ) { Security . addProvider ( new BouncyCastleProvider ( ) ) ; removeBouncyCastle = true ; } } catch ( SecurityException ex ) { AdvancedLdapLoginModuleTestCase . LOGGER . warn ( "Cannot<seq2seq4repair_space>register<seq2seq4repair_space>BouncyCastleProvider" , ex ) ; } directoryService = DSAnnotationProcessor . getDirectoryService ( ) ; final String hostname = Utils . getCannonicalHost ( managementClient ) ; final Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( "hostname" , NetworkUtils . formatPossibleIpv6Address ( hostname ) ) ; <START_BUG> final String secondaryTestAddress = NetworkUtils . canonize ( Utils . getSecondaryTestAddress ( managementClient , true ) ) ; <END_BUG> map . put ( "ldaphost" , secondaryTestAddress ) ; final String ldifContent = StrSubstitutor . replace ( IOUtils . toString ( AdvancedLdapLoginModuleTestCase . class . getResourceAsStream ( ( ( AdvancedLdapLoginModuleTestCase . class . getSimpleName ( ) ) + ".ldif" ) ) , "UTF-8" ) , map ) ; AdvancedLdapLoginModuleTestCase . LOGGER . info ( ldifContent ) ; final SchemaManager schemaManager = directoryService . getSchemaManager ( ) ; try { for ( LdifEntry ldifEntry : new LdifReader ( IOUtils . toInputStream ( ldifContent ) ) ) { directoryService . getAdminSession ( ) . add ( new org . apache . directory . api . ldap . model . entry . DefaultEntry ( schemaManager , ldifEntry . getEntry ( ) ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; throw e ; } kdcServer = KDCServerAnnotationProcessor . getKdcServer ( directoryService , 1024 , hostname ) ; final ManagedCreateLdapServer createLdapServer = new ManagedCreateLdapServer ( ( ( CreateLdapServer ) ( AnnotationUtils . getInstance ( CreateLdapServer . class ) ) ) ) ; createLdapServer . setSaslHost ( secondaryTestAddress ) ; createLdapServer . setSaslPrincipal ( ( ( "ldap//" + secondaryTestAddress ) + "@JBOSS.ORG" ) ) ; fixTransportAddress ( createLdapServer , secondaryTestAddress ) ; ldapServer = ServerAnnotationProcessor . instantiateLdapServer ( createLdapServer , directoryService ) ; ldapServer . getSaslHost ( ) ; ldapServer . setSearchBaseDn ( "dc=jboss,dc=org" ) ; ldapServer . start ( ) ; } private void fixTransportAddress ( ManagedCreateLdapServer createLdapServer , String address ) { }

Fix:
final String secondaryTestAddress = Utils . getSecondaryTestAddress ( managementClient , true ) ;