You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2012/04/06 01:10:52 UTC
svn commit: r1310127 - in /bval/trunk/bval-jsr303: pom.xml
src/test/java/org/apache/bval/jsr303/util/TestUtils.java
src/test/resources/java.policy
Author: mbenson
Date: Thu Apr 5 23:10:52 2012
New Revision: 1310127
URL: http://svn.apache.org/viewvc?rev=1310127&view=rev
Log:
add profile to run bval-jsr303 tests with a securityManager to support confident refactoring
Added:
bval/trunk/bval-jsr303/src/test/resources/java.policy
Modified:
bval/trunk/bval-jsr303/pom.xml
bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
Modified: bval/trunk/bval-jsr303/pom.xml
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr303/pom.xml?rev=1310127&r1=1310126&r2=1310127&view=diff
==============================================================================
--- bval/trunk/bval-jsr303/pom.xml (original)
+++ bval/trunk/bval-jsr303/pom.xml Thu Apr 5 23:10:52 2012
@@ -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>
-
Modified: bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java?rev=1310127&r1=1310126&r2=1310127&view=diff
==============================================================================
--- bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java (original)
+++ bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java Thu Apr 5 23:10:52 2012
@@ -26,7 +26,7 @@ import javax.validation.ConstraintViolat
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
-import org.junit.Assert;
+import junit.framework.Assert;
/**
* Description: <br/>
Added: bval/trunk/bval-jsr303/src/test/resources/java.policy
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr303/src/test/resources/java.policy?rev=1310127&view=auto
==============================================================================
--- bval/trunk/bval-jsr303/src/test/resources/java.policy (added)
+++ bval/trunk/bval-jsr303/src/test/resources/java.policy Thu Apr 5 23:10:52 2012
@@ -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";
+};