Not supporting Ashcroft (or other alternative SecurityManagers) is blocking me from making sure that my coders write unit tests that follow the rules the project's set up (such as no Unit test is allowed to touch the filesystem, network, take longer than x milliseconds, ...). I've seen that jboss uses a maven profile to set jvm arguments like this:
profiles > profile > properites:
<surefire.jvm.args>-Djava.security.manager -Djava.security.policy=${policy.file} ${test.env}</surefire.jvm.args>
http://repository.jboss.org/maven2/org/jboss/security/jbosssx-parent/2.0.2.CR1/jbosssx-parent-2.0.2.CR1.pom
That forces one to rely on maven profiles. I had hoped this would work:
<project><build><plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
<systemProperties>
<property>
<name>java.security.manager</name>
<value>this.is.where.ashcroft.would.be.nice.or.some.other.UnitTestSecurityManager</value>
</property>
</systemProperties>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Another option of course would be to put tests that must run outside the Ashcroft security manager in another project. But it's sad to base that decision on the shortcomings of Surefire.
As discussed on IRC, this patch creates a surefire.policy with all permissions.