| Index: third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc b/third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| similarity index 50%
|
| copy from third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| copy to third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| index 455c239a936bd9cec724ab65e85092b743fa1070..1f8bb445b242053d456f71f3d7feba5df1cb7bad 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/code_generator.cc
|
| +++ b/third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| @@ -28,53 +28,53 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Author: kenton@google.com (Kenton Varda)
|
| -// Based on original Protocol Buffers design by
|
| -// Sanjay Ghemawat, Jeff Dean, and others.
|
| +package com.google.protobuf;
|
|
|
| -#include <google/protobuf/compiler/code_generator.h>
|
| +import protobuf_unittest.UnittestProto.TestDeprecatedFields;
|
|
|
| -#include <google/protobuf/stubs/common.h>
|
| -#include <google/protobuf/stubs/strutil.h>
|
| +import junit.framework.TestCase;
|
|
|
| -namespace google {
|
| -namespace protobuf {
|
| -namespace compiler {
|
| -
|
| -CodeGenerator::~CodeGenerator() {}
|
| -GeneratorContext::~GeneratorContext() {}
|
| -
|
| -io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
|
| - const string& filename, const string& insertion_point) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
|
| - return NULL; // make compiler happy
|
| -}
|
| -
|
| -void GeneratorContext::ListParsedFiles(
|
| - vector<const FileDescriptor*>* output) {
|
| - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
|
| -}
|
| -
|
| -// Parses a set of comma-delimited name/value pairs.
|
| -void ParseGeneratorParameter(const string& text,
|
| - vector<pair<string, string> >* output) {
|
| - vector<string> parts;
|
| - SplitStringUsing(text, ",", &parts);
|
| -
|
| - for (int i = 0; i < parts.size(); i++) {
|
| - string::size_type equals_pos = parts[i].find_first_of('=');
|
| - pair<string, string> value;
|
| - if (equals_pos == string::npos) {
|
| - value.first = parts[i];
|
| - value.second = "";
|
| - } else {
|
| - value.first = parts[i].substr(0, equals_pos);
|
| - value.second = parts[i].substr(equals_pos + 1);
|
| +import java.lang.reflect.AnnotatedElement;
|
| +import java.lang.reflect.Method;
|
| +/**
|
| + * 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"};
|
| +
|
| + public void testDeprecatedField() throws Exception {
|
| + Class<?> deprecatedFields = TestDeprecatedFields.class;
|
| + Class<?> deprecatedFieldsBuilder = TestDeprecatedFields.Builder.class;
|
| + for (String name : deprecatedGetterNames) {
|
| + Method method = deprecatedFields.getMethod(name);
|
| + assertTrue("Method " + name + " should be deprecated",
|
| + isDeprecated(method));
|
| + }
|
| + for (String name : deprecatedBuilderGetterNames) {
|
| + Method method = deprecatedFieldsBuilder.getMethod(name);
|
| + assertTrue("Method " + name + " should be deprecated",
|
| + isDeprecated(method));
|
| + }
|
| + for (String name : deprecatedBuilderSetterNames) {
|
| + Method method = deprecatedFieldsBuilder.getMethod(name, int.class);
|
| + assertTrue("Method " + name + " should be deprecated",
|
| + isDeprecated(method));
|
| }
|
| - output->push_back(value);
|
| + }
|
| +
|
| + private boolean isDeprecated(AnnotatedElement annotated) {
|
| + return annotated.isAnnotationPresent(Deprecated.class);
|
| }
|
| }
|
| -
|
| -} // namespace compiler
|
| -} // namespace protobuf
|
| -} // namespace google
|
|
|