| Index: third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h 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/cpp/cpp_extension.h
|
| copy to third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| index 50ad035ba8ff80ac5fd0f1d18b4d97b48116aee2..e7905f79d05a2f7760dd1e99c93b317bbb89382d 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h
|
| +++ b/third_party/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,59 +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;
|
|
|
| -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
|
| -#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
|
| +import protobuf_unittest.UnittestProto.TestDeprecatedFields;
|
|
|
| -#include <string>
|
| -#include <google/protobuf/stubs/common.h>
|
| -#include <google/protobuf/compiler/cpp/cpp_options.h>
|
| +import junit.framework.TestCase;
|
|
|
| -namespace google {
|
| -namespace protobuf {
|
| - class FieldDescriptor; // descriptor.h
|
| - namespace io {
|
| - class Printer; // printer.h
|
| +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));
|
| + }
|
| + }
|
| +
|
| + private boolean isDeprecated(AnnotatedElement annotated) {
|
| + return annotated.isAnnotationPresent(Deprecated.class);
|
| }
|
| }
|
| -
|
| -namespace protobuf {
|
| -namespace compiler {
|
| -namespace cpp {
|
| -
|
| -// Generates code for an extension, which may be within the scope of some
|
| -// message or may be at file scope. This is much simpler than FieldGenerator
|
| -// since extensions are just simple identifiers with interesting types.
|
| -class ExtensionGenerator {
|
| - public:
|
| - // See generator.cc for the meaning of dllexport_decl.
|
| - explicit ExtensionGenerator(const FieldDescriptor* desycriptor,
|
| - const Options& options);
|
| - ~ExtensionGenerator();
|
| -
|
| - // Header stuff.
|
| - void GenerateDeclaration(io::Printer* printer);
|
| -
|
| - // Source file stuff.
|
| - void GenerateDefinition(io::Printer* printer);
|
| -
|
| - // Generate code to register the extension.
|
| - void GenerateRegistration(io::Printer* printer);
|
| -
|
| - private:
|
| - const FieldDescriptor* descriptor_;
|
| - string type_traits_;
|
| - Options options_;
|
| -
|
| - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
|
| -};
|
| -
|
| -} // namespace cpp
|
| -} // namespace compiler
|
| -} // namespace protobuf
|
| -
|
| -} // namespace google
|
| -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
|
|