aboutsummaryrefslogtreecommitdiffstats
path: root/abi-check-plugin
diff options
context:
space:
mode:
authorIlpo Ruotsalainen <ilpo.ruotsalainen@oath.com>2018-11-29 14:05:16 +0100
committerIlpo Ruotsalainen <ilpo.ruotsalainen@oath.com>2018-11-29 14:05:16 +0100
commita3e8241dbfda9952f9be93c23e073df4efd09f3a (patch)
tree37085d095d6cee87adfae1cdd6257ca45af5f9cc /abi-check-plugin
parent748ede2ebf22520358d65c954d7fc1b2241758e6 (diff)
Add some initial unit tests.
Diffstat (limited to 'abi-check-plugin')
-rw-r--r--abi-check-plugin/src/test/java/com/yahoo/abicheck/AccessConversionTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/abi-check-plugin/src/test/java/com/yahoo/abicheck/AccessConversionTest.java b/abi-check-plugin/src/test/java/com/yahoo/abicheck/AccessConversionTest.java
new file mode 100644
index 00000000000..f64d9c3b8fc
--- /dev/null
+++ b/abi-check-plugin/src/test/java/com/yahoo/abicheck/AccessConversionTest.java
@@ -0,0 +1,46 @@
+package com.yahoo.abicheck;
+
+import static org.junit.Assert.assertEquals;
+
+import com.yahoo.abicheck.collector.Util;
+import java.util.Arrays;
+import org.junit.Test;
+import org.objectweb.asm.Opcodes;
+
+public class AccessConversionTest {
+
+ @Test
+ public void testClassFlags() {
+ // ACC_SUPER should be ignored
+ assertEquals(
+ Arrays.asList("public", "abstract"),
+ Util.convertAccess(
+ Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER | Opcodes.ACC_ABSTRACT,
+ Util.classFlags));
+ }
+
+ @Test
+ public void testMethodFlags() {
+ // ACC_DEPRECATED should be ignored
+ assertEquals(
+ Arrays.asList("protected", "varargs"),
+ Util.convertAccess(
+ Opcodes.ACC_PROTECTED | Opcodes.ACC_VARARGS | Opcodes.ACC_DEPRECATED,
+ Util.methodFlags));
+ }
+
+ @Test
+ public void testFieldFlags() {
+ assertEquals(
+ Arrays.asList("private", "volatile"),
+ Util.convertAccess(
+ Opcodes.ACC_PRIVATE | Opcodes.ACC_VOLATILE,
+ Util.fieldFlags));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testUnsupportedFlags() {
+ // ACC_MODULE is not a valid flag for fields
+ Util.convertAccess(Opcodes.ACC_MODULE, Util.fieldFlags);
+ }
+}