This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to tag 0.4
in repository https://gitbox.apache.org/repos/asf/bval.git
commit 1bd764a4cfdd69d77b389f01259bf762d5ea9011
Author: mbenson <mbenson@13f79535-47bb-0310-9956-ffa450edef68>
AuthorDate: Thu Apr 5 23:10:52 2012 +0000
add profile to run bval-jsr303 tests with a securityManager to support
confident refactoring
git-svn-id: http://svn.apache.org/repos/asf/bval/trunk@1310127
13f79535-47bb-0310-9956-ffa450edef68
---
bval-jsr303/pom.xml | 23 ++++++-
.../org/apache/bval/jsr303/util/TestUtils.java | 2 +-
bval-jsr303/src/test/resources/java.policy | 76 ++++++++++++++++++++++
3 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/bval-jsr303/pom.xml b/bval-jsr303/pom.xml
index 453737b..93320c1 100644
--- a/bval-jsr303/pom.xml
+++ b/bval-jsr303/pom.xml
@@ -92,6 +92,24 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>sec</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <argLine>-Djava.security.manager
-Djava.security.policy=${project.basedir}/src/test/resources/java.policy</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<dependencies>
@@ -107,6 +125,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -193,7 +212,8 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.6</version>
+ <!-- 2.12 has http://jira.codehaus.org/browse/SUREFIRE-836 -->
+ <version>2.11</version>
<configuration>
<includes>
<include>**/*Test.java</include>
@@ -204,4 +224,3 @@
</plugins>
</build>
</project>
-
diff --git
a/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
b/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
index 4224ce0..30fcb4b 100644
--- a/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
+++ b/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
@@ -26,7 +26,7 @@ import javax.validation.ConstraintViolation;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
-import org.junit.Assert;
+import junit.framework.Assert;
/**
* Description: <br/>
diff --git a/bval-jsr303/src/test/resources/java.policy
b/bval-jsr303/src/test/resources/java.policy
new file mode 100644
index 0000000..98bb345
--- /dev/null
+++ b/bval-jsr303/src/test/resources/java.policy
@@ -0,0 +1,76 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//
+// $Id$
+//
+// Allows unit tests to run with a Java Security Manager
+//
+// Cloned from
https://svn.apache.org/repos/asf/commons/proper/lang/trunk/src/test/resources/java.policy
+//
+// <argLine>-Djava.security.manager
-Djava.security.policy=${basedir}/src/test/resources/java.policy</argLine>
+//
+
+grant
+{
+ // let everyone read target dir
+ permission java.io.FilePermission "${user.dir}/target/-", "read";
+};
+
+// we don't care about the permissions of the testing infrastructure,
+// including maven;
+grant codeBase "file://${user.home}/.m2/repository/org/apache/maven/-"
+{
+ permission java.security.AllPermission;
+};
+
+// junit;
+grant codeBase "file://${user.home}/.m2/repository/junit/-"
+{
+ permission java.security.AllPermission;
+};
+
+// mockito;
+grant codeBase "file://${user.home}/.m2/repository/org/mockito/-"
+{
+ permission java.security.AllPermission;
+};
+
+// objenesis (via mockito);
+grant codeBase "file://${user.home}/.m2/repository/org/objenesis/-"
+{
+ permission java.security.AllPermission;
+};
+
+// and our own testcases
+grant codeBase "file://${user.dir}/target/test-classes/-"
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file://${user.home}/.m2/repository/org/apache/bval/-"
+{
+ permission java.lang.RuntimePermission "accessDeclaredMembers";
+ permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+};
+
+grant codeBase "file://${user.dir}/target/classes/-"
+{
+ permission java.lang.RuntimePermission "accessDeclaredMembers";
+ permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+ permission java.io.FilePermission "${user.home}/.m2/repository/-", "read";
+};