|
@@ -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);
|
|
|
}
|