Author: mbenson
Date: Tue Jul 30 15:45:27 2013
New Revision: 1508498

URL: http://svn.apache.org/r1508498
Log:
reenable tests (not sure how they got disabled); add first test for field 
access in blueprint method

Modified:
    commons/sandbox/weaver/branches/priv-asm/example/pom.xml
    
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/UsingBlueprints.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/Utils.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/NoArgsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/OverloadingTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/PrivateMethodsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticNoArgsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticOverloadingTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticPrivateMethodsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticUsingArgsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingArgsTest.java
    
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingBlueprintsTest.java

Modified: commons/sandbox/weaver/branches/priv-asm/example/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/pom.xml?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- commons/sandbox/weaver/branches/priv-asm/example/pom.xml (original)
+++ commons/sandbox/weaver/branches/priv-asm/example/pom.xml Tue Jul 30 
15:45:27 2013
@@ -28,6 +28,7 @@
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <privilizer.policy>ON_INIT</privilizer.policy>
+    <privilizer.verify>true</privilizer.verify>
   </properties>
   <dependencies>
     <dependency>
@@ -56,6 +57,7 @@
           <weaverConfig>
             <privilizer.accessLevel>PACKAGE</privilizer.accessLevel>
             <privilizer.policy>${privilizer.policy}</privilizer.policy>
+            <privilizer.verify>${privilizer.verify}</privilizer.verify>
           </weaverConfig>
         </configuration>
         <executions>
@@ -76,6 +78,25 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-weaver-privilizer</artifactId>
             <version>${project.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>org.ow2.asm</groupId>
+                <artifactId>asm</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.ow2.asm</groupId>
+                <artifactId>asm-commons</artifactId>
+              </exclusion>
+              <exclusion>
+                <groupId>org.ow2.asm</groupId>
+                <artifactId>asm-tree</artifactId>
+              </exclusion>
+            </exclusions>
+          </dependency>
+          <dependency>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm-debug-all</artifactId>
+            <version>${asm.version}</version>
           </dependency>
         </dependencies>
       </plugin>

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/UsingBlueprints.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/UsingBlueprints.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/UsingBlueprints.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/UsingBlueprints.java
 Tue Jul 30 15:45:27 2013
@@ -25,6 +25,10 @@ public class UsingBlueprints {
         return Utils.readPublicConstant();
     }
 
+    public int utilsReadPrivateField() {
+        return Utils.readPrivateField();
+    }
+
     public String utilsGetProperty() {
         return Utils.getProperty();
     }

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/Utils.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/Utils.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/Utils.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/main/java/org/apache/commons/weaver/privilizer/example/Utils.java
 Tue Jul 30 15:45:27 2013
@@ -52,4 +52,13 @@ public class Utils {
     public static String getProperty(String key) {
         return System.getProperty(key);
     }
+
+    private static Integer n;
+    static {
+        n = Integer.valueOf(999);
+    }
+
+    public static int readPrivateField() {
+        return n;
+    }
 }

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/NoArgsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/NoArgsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/NoArgsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/NoArgsTest.java
 Tue Jul 30 15:45:27 2013
@@ -25,10 +25,13 @@ import java.security.PrivilegedAction;
 
 import org.apache.commons.weaver.privilizer.example.NoArgs.CheckedException1;
 import org.apache.commons.weaver.privilizer.example.NoArgs.CheckedException2;
+import org.junit.Before;
+import org.junit.Test;
 
 public class NoArgsTest {
     private NoArgs noArgs;
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
 
@@ -41,22 +44,27 @@ public class NoArgsTest {
         noArgs = new NoArgs();
     }
 
+    @Test
     public void testThrowAwayFoo() {
         noArgs.throwAwayFoo();
     }
 
+    @Test
     public void testGetFoo() {
         assertEquals("foo-value", noArgs.getFoo());
     }
 
+    @Test
     public void testGetTrue() {
         assertSame(Boolean.TRUE, noArgs.getTrue());
     }
 
+    @Test
     public void testGetFalse() {
         assertFalse(noArgs.getFalse());
     }
 
+    @Test
     public void testThrowingCheckedException1() {
         try {
             noArgs.throwingCheckedException1();
@@ -65,6 +73,7 @@ public class NoArgsTest {
         }
     }
 
+    @Test
     public void testThrowingCheckedException2() {
         try {
             noArgs.throwingCheckedException2();

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/OverloadingTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/OverloadingTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/OverloadingTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/OverloadingTest.java
 Tue Jul 30 15:45:27 2013
@@ -20,9 +20,13 @@ import static org.junit.Assert.assertEqu
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.junit.Before;
+import org.junit.Test;
+
 public class OverloadingTest {
     private Overloading overloading;
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -36,14 +40,17 @@ public class OverloadingTest {
         overloading = new Overloading();
     }
 
+    @Test
     public void testNoArgs() {
         assertEquals("foo-value", overloading.get());
     }
 
+    @Test
     public void testStringArg() {
         assertEquals("bar-value", overloading.get("bar"));
     }
 
+    @Test
     public void testCharishArgs() {
         assertEquals("baz-value", overloading.get('b', 'a', (short) 'z'));
     }

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/PrivateMethodsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/PrivateMethodsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/PrivateMethodsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/PrivateMethodsTest.java
 Tue Jul 30 15:45:27 2013
@@ -20,9 +20,13 @@ import static org.junit.Assert.assertEqu
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.junit.Before;
+import org.junit.Test;
+
 public class PrivateMethodsTest {
     private PrivateMethods privateMethods;
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -36,6 +40,7 @@ public class PrivateMethodsTest {
         privateMethods = new PrivateMethods();
     }
 
+    @Test
     public void testGet() {
         assertEquals("foo-value", privateMethods.get("foo"));
         assertEquals("bar-value", privateMethods.get("bar"));

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticNoArgsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticNoArgsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticNoArgsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticNoArgsTest.java
 Tue Jul 30 15:45:27 2013
@@ -25,8 +25,11 @@ import java.security.PrivilegedAction;
 
 import 
org.apache.commons.weaver.privilizer.example.StaticNoArgs.CheckedException1;
 import 
org.apache.commons.weaver.privilizer.example.StaticNoArgs.CheckedException2;
+import org.junit.Before;
+import org.junit.Test;
 
 public class StaticNoArgsTest {
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
 
@@ -38,22 +41,27 @@ public class StaticNoArgsTest {
         });
     }
 
+    @Test
     public void testThrowAwayFoo() {
         StaticNoArgs.throwAwayFoo();
     }
 
+    @Test
     public void testGetFoo() {
         assertEquals("foo-value", StaticNoArgs.getFoo());
     }
 
+    @Test
     public void testGetTrue() {
         assertSame(Boolean.TRUE, StaticNoArgs.getTrue());
     }
 
+    @Test
     public void testGetFalse() {
         assertFalse(StaticNoArgs.getFalse());
     }
 
+    @Test
     public void testThrowingCheckedException1() {
         try {
             StaticNoArgs.throwingCheckedException1();
@@ -62,6 +70,7 @@ public class StaticNoArgsTest {
         }
     }
 
+    @Test
     public void testThrowingCheckedException2() {
         try {
             StaticNoArgs.throwingCheckedException2();

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticOverloadingTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticOverloadingTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticOverloadingTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticOverloadingTest.java
 Tue Jul 30 15:45:27 2013
@@ -20,8 +20,12 @@ import static org.junit.Assert.assertEqu
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.junit.Before;
+import org.junit.Test;
+
 public class StaticOverloadingTest {
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -34,14 +38,17 @@ public class StaticOverloadingTest {
         });
     }
 
+    @Test
     public void testNoArgs() {
         assertEquals("foo-value", StaticOverloading.get());
     }
 
+    @Test
     public void testStringArg() {
         assertEquals("bar-value", StaticOverloading.get("bar"));
     }
 
+    @Test
     public void testCharishArgs() {
         assertEquals("baz-value", StaticOverloading.get('b', 'a', (short) 
'z'));
     }

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticPrivateMethodsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticPrivateMethodsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticPrivateMethodsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticPrivateMethodsTest.java
 Tue Jul 30 15:45:27 2013
@@ -20,8 +20,12 @@ import static org.junit.Assert.assertEqu
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.junit.Before;
+import org.junit.Test;
+
 public class StaticPrivateMethodsTest {
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -34,6 +38,7 @@ public class StaticPrivateMethodsTest {
         });
     }
 
+    @Test
     public void testGet() {
         assertEquals("foo-value", StaticPrivateMethods.get("foo"));
         assertEquals("bar-value", StaticPrivateMethods.get("bar"));

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticUsingArgsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticUsingArgsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticUsingArgsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/StaticUsingArgsTest.java
 Tue Jul 30 15:45:27 2013
@@ -25,9 +25,12 @@ import java.util.Arrays;
 
 import 
org.apache.commons.weaver.privilizer.example.StaticUsingArgs.CheckedException1;
 import 
org.apache.commons.weaver.privilizer.example.StaticUsingArgs.CheckedException2;
+import org.junit.Before;
+import org.junit.Test;
 
 public class StaticUsingArgsTest {
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -40,12 +43,14 @@ public class StaticUsingArgsTest {
         });
     }
 
+    @Test
     public void testGetProperty() {
         assertEquals("foo-value", StaticUsingArgs.getProperty("foo"));
         assertEquals("bar-value", StaticUsingArgs.getProperty("bar"));
         assertEquals("baz-value", StaticUsingArgs.getProperty("baz"));
     }
 
+    @Test
     public void testGetProperties() {
         assertTrue(Arrays.equals(new String[] { "foo-value", "bar-value", 
"baz-value" },
             StaticUsingArgs.getProperties("foo", "bar", "baz")));
@@ -53,16 +58,19 @@ public class StaticUsingArgsTest {
         assertNull(StaticUsingArgs.getProperties((String[]) null));
     }
 
+    @Test
     public void testThrowAwayProperty() {
         StaticUsingArgs.throwAwayProperty('f', "o", 'o');
     }
 
+    @Test
     public void testAssembleAndGetProperty() {
         assertEquals("foo-value", StaticUsingArgs.assembleAndGetProperty('f', 
new StringBuilder().append('o'), 'o'));
         assertEquals("bar-value", StaticUsingArgs.assembleAndGetProperty('b', 
new StringBuilder().append('a'), 'r'));
         assertEquals("baz-value", StaticUsingArgs.assembleAndGetProperty('b', 
new StringBuilder().append('a'), 'z'));
     }
 
+    @Test
     public void testThrowingCheckedException() throws CheckedException1, 
CheckedException2 {
         assertEquals(0, StaticUsingArgs.throwingCheckedException(0, "foo"));
         try {

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingArgsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingArgsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingArgsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingArgsTest.java
 Tue Jul 30 15:45:27 2013
@@ -25,10 +25,13 @@ import java.util.Arrays;
 
 import 
org.apache.commons.weaver.privilizer.example.UsingArgs.CheckedException1;
 import 
org.apache.commons.weaver.privilizer.example.UsingArgs.CheckedException2;
+import org.junit.Before;
+import org.junit.Test;
 
 public class UsingArgsTest {
     private UsingArgs usingArgs;
 
+    @Before
     public void setUp() throws Exception {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
@@ -42,12 +45,14 @@ public class UsingArgsTest {
         usingArgs = new UsingArgs();
     }
 
+    @Test
     public void testGetProperty() {
         assertEquals("foo-value", usingArgs.getProperty("foo"));
         assertEquals("bar-value", usingArgs.getProperty("bar"));
         assertEquals("baz-value", usingArgs.getProperty("baz"));
     }
 
+    @Test
     public void testGetProperties() {
         assertTrue(Arrays.equals(new String[] { "foo-value", "bar-value", 
"baz-value" },
             usingArgs.getProperties("foo", "bar", "baz")));
@@ -55,16 +60,19 @@ public class UsingArgsTest {
         assertNull(usingArgs.getProperties((String[]) null));
     }
 
+    @Test
     public void testThrowAwayProperty() {
         usingArgs.throwAwayProperty('f', "o", 'o');
     }
 
+    @Test
     public void testAssembleAndGetProperty() {
         assertEquals("foo-value", usingArgs.assembleAndGetProperty('f', new 
StringBuilder().append('o'), 'o'));
         assertEquals("bar-value", usingArgs.assembleAndGetProperty('b', new 
StringBuilder().append('a'), 'r'));
         assertEquals("baz-value", usingArgs.assembleAndGetProperty('b', new 
StringBuilder().append('a'), 'z'));
     }
 
+    @Test
     public void testThrowingCheckedException() throws CheckedException1, 
CheckedException2 {
         assertEquals(0, usingArgs.throwingCheckedException(0, "foo"));
         try {

Modified: 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingBlueprintsTest.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingBlueprintsTest.java?rev=1508498&r1=1508497&r2=1508498&view=diff
==============================================================================
--- 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingBlueprintsTest.java
 (original)
+++ 
commons/sandbox/weaver/branches/priv-asm/example/src/test/java/org/apache/commons/weaver/privilizer/example/UsingBlueprintsTest.java
 Tue Jul 30 15:45:27 2013
@@ -47,6 +47,11 @@ public class UsingBlueprintsTest {
     }
 
     @Test
+    public void testUtilsReadPrivateField() {
+        assertEquals(999, usingBlueprints.utilsReadPrivateField());
+    }
+
+    @Test
     public void testUtilsGetProperty() {
         assertEquals("foo-value", usingBlueprints.utilsGetProperty());
     }


Reply via email to