Index: third_party/protobuf/java/src/test/java/com/google/protobuf/WellKnownTypesTest.java |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h b/third_party/protobuf/java/src/test/java/com/google/protobuf/WellKnownTypesTest.java |
similarity index 52% |
copy from third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
copy to third_party/protobuf/java/src/test/java/com/google/protobuf/WellKnownTypesTest.java |
index 009ed9ffacaf207d4fb6322dca43697499b32991..982e200f53f678bfce021ed2e93ece13edc55cda 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
+++ b/third_party/protobuf/java/src/test/java/com/google/protobuf/WellKnownTypesTest.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,50 +28,38 @@ |
// (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_JAVA_EXTENSION_H__ |
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ |
+import com.google.protobuf.Descriptors.Descriptor; |
+import com.google.protobuf.Descriptors.EnumDescriptor; |
+import com.google.protobuf.Descriptors.EnumValueDescriptor; |
+import com.google.protobuf.Descriptors.FieldDescriptor; |
+import com.google.protobuf.test.TestWellKnownTypes; |
-#include <string> |
+import junit.framework.TestCase; |
-#include <google/protobuf/stubs/common.h> |
+import java.util.ArrayList; |
+import java.util.HashMap; |
+import java.util.List; |
+import java.util.Map; |
-namespace google { |
-namespace protobuf { |
- class FieldDescriptor; // descriptor.h |
- namespace io { |
- class Printer; // printer.h |
+/** |
+ * This test ensures that well-known types are included in protobuf Java |
+ * runtime library. |
+ */ |
+public class WellKnownTypesTest extends TestCase { |
+ public void testWellKnownTypes() { |
+ // The test passes if it compiles. |
+ TestWellKnownTypes message = TestWellKnownTypes.newBuilder().build(); |
+ assertEquals(0, message.getAnyField().getSerializedSize()); |
+ assertEquals(0, message.getApiField().getSerializedSize()); |
+ assertEquals(0, message.getDurationField().getSerializedSize()); |
+ assertEquals(0, message.getEmptyField().getSerializedSize()); |
+ assertEquals(0, message.getFieldMaskField().getSerializedSize()); |
+ assertEquals(0, message.getSourceContextField().getSerializedSize()); |
+ assertEquals(0, message.getStructField().getSerializedSize()); |
+ assertEquals(0, message.getTimestampField().getSerializedSize()); |
+ assertEquals(0, message.getTypeField().getSerializedSize()); |
+ assertEquals(0, message.getInt32Field().getSerializedSize()); |
} |
} |
- |
-namespace protobuf { |
-namespace compiler { |
-namespace java { |
- |
-// 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: |
- explicit ExtensionGenerator(const FieldDescriptor* descriptor); |
- ~ExtensionGenerator(); |
- |
- void Generate(io::Printer* printer); |
- void GenerateNonNestedInitializationCode(io::Printer* printer); |
- void GenerateRegistrationCode(io::Printer* printer); |
- |
- private: |
- const FieldDescriptor* descriptor_; |
- string scope_; |
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); |
-}; |
- |
-} // namespace java |
-} // namespace compiler |
-} // namespace protobuf |
- |
-} // namespace google |
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ |