Your solution seems to be two parts: (1) informing the process, through Maven, that it is running in a given configuration, and (2) running a test conditionally based on that configuration.
The first bit is easy: Use the -D
switch to pass in a system property, as in this SO answer, acknowledging that you need to pass a system property as an argument within a system property using the surefire argLine property:
mvn -DargLine="-DldapTests=disable" test
For the second, you can use the new assumeTrue
and related assumption API in JUnit, as in this other SO answer.
@Before
public void checkLdapTests() {
assumeThat(System.getProperty("ldapTests"), is(not(equalTo("disable"))));
}