aboutsummaryrefslogtreecommitdiffhomepage
path: root/java
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2017-12-13 14:09:50 -0800
committerGravatar Jisi Liu <jisi.liu@gmail.com>2017-12-13 14:09:50 -0800
commit22e1cfd84ac2e7a6e0ee1101d75673c13a801c03 (patch)
treee84659634b5a3952a89436d9fd7d1df525dfa9a2 /java
parent5ce724bcebebb56914da6efc40b85c4c801e6fe1 (diff)
Add deprecation annotation for oneof case.
Diffstat (limited to 'java')
-rw-r--r--java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java b/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
index 2c272a73..9c0997c4 100644
--- a/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
+++ b/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
@@ -37,22 +37,22 @@ import junit.framework.TestCase;
/**
* Test field deprecation
- *
+ *
* @author birdo@google.com (Roberto Scaramuzzi)
*/
public class DeprecatedFieldTest extends TestCase {
private String[] deprecatedGetterNames = {
"hasDeprecatedInt32",
"getDeprecatedInt32"};
-
+
private String[] deprecatedBuilderGetterNames = {
"hasDeprecatedInt32",
"getDeprecatedInt32",
"clearDeprecatedInt32"};
-
+
private String[] deprecatedBuilderSetterNames = {
- "setDeprecatedInt32"};
-
+ "setDeprecatedInt32"};
+
public void testDeprecatedField() throws Exception {
Class<?> deprecatedFields = TestDeprecatedFields.class;
Class<?> deprecatedFieldsBuilder = TestDeprecatedFields.Builder.class;
@@ -72,7 +72,15 @@ public class DeprecatedFieldTest extends TestCase {
isDeprecated(method));
}
}
-
+
+ public void testDeprecatedFieldInOneof() throws Exception {
+ Class<?> oneofCase = TestDeprecatedFields.OneofFieldsCase.class;
+ String name = "DEPRECATED_INT32_IN_ONEOF";
+ java.lang.reflect.Field enumValue = oneofCase.getField(name);
+ assertTrue("Enum value " + name + " should be deprecated.",
+ isDeprecated(enumValue));
+ }
+
private boolean isDeprecated(AnnotatedElement annotated) {
return annotated.isAnnotationPresent(Deprecated.class);
}