aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsyev <[email protected]>2014-10-24 12:11:36 +0200
committersyev <[email protected]>2014-10-24 12:11:36 +0200
commit28320018e8c6f97a37389aa14af3e14c5b082701 (patch)
treec63f7584171020e07ea5d6d47b5bb252f0d4ab6a
parent32b247d1dc0209faa5cb79b3db72ccc54ebb8991 (diff)
Tests on access permissions checks.
-rw-r--r--api/src/test/java/org/osjava/jardiff/ToolsTest.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/api/src/test/java/org/osjava/jardiff/ToolsTest.java b/api/src/test/java/org/osjava/jardiff/ToolsTest.java
index 39683bd..7af6d45 100644
--- a/api/src/test/java/org/osjava/jardiff/ToolsTest.java
+++ b/api/src/test/java/org/osjava/jardiff/ToolsTest.java
@@ -58,10 +58,20 @@ public class ToolsTest {
assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_FINAL, 0));
assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_FINAL + Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC));
- // No matter the final access, can't become protected or private or
- // package if it was public.
+ // A field can become more accessible
+ assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isFieldAccessChange(0, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isFieldAccessChange(0, Opcodes.ACC_PROTECTED));
+ assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PROTECTED));
+ assertFalse(Tools.isFieldAccessChange(Opcodes.ACC_PRIVATE, 0));
+ // ...but can't become less accessible
assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_FINAL + Opcodes.ACC_PUBLIC, 0));
assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PROTECTED));
+ assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PRIVATE));
+ assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, 0));
+ assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PRIVATE));
+ assertTrue(Tools.isFieldAccessChange(0, Opcodes.ACC_PRIVATE));
// A field can't change static
assertTrue(Tools.isFieldAccessChange(Opcodes.ACC_STATIC, 0));
@@ -96,10 +106,21 @@ public class ToolsTest {
assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC,
Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL));
- // No matter the final access, can't become protected or private or
- // package if it was public.
+ // A method can become more accessible
+ assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isMethodAccessChange(0, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isMethodAccessChange(0, Opcodes.ACC_PROTECTED));
+ assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PUBLIC));
+ assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_PRIVATE, Opcodes.ACC_PROTECTED));
+ assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_PRIVATE, 0));
+ // ...but can't become less accessible
assertTrue(Tools.isMethodAccessChange(Opcodes.ACC_FINAL + Opcodes.ACC_PUBLIC, 0));
assertTrue(Tools.isMethodAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PROTECTED));
+ assertTrue(Tools.isMethodAccessChange(Opcodes.ACC_PUBLIC, Opcodes.ACC_PRIVATE));
+ assertTrue(Tools.isMethodAccessChange(Opcodes.ACC_PROTECTED, 0));
+ assertTrue(Tools.isMethodAccessChange(Opcodes.ACC_PROTECTED, Opcodes.ACC_PRIVATE));
+ assertTrue(Tools.isMethodAccessChange(0, Opcodes.ACC_PRIVATE));
+
// A class or method can become concrete.
assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_ABSTRACT, 0));
assertFalse(Tools.isMethodAccessChange(Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC, Opcodes.ACC_PUBLIC));