### Question:
ProtoLanguageFileWriter { public static void write( Descriptors.FileDescriptor fd, ProtoDomain PContainer, OutputStream outputStream) { PrintWriter printWriter = new PrintWriter(outputStream); new ProtoLanguageFileWriter(fd, PContainer).write(printWriter); printWriter.flush(); } private  ProtoLanguageFileWriter(Descriptors.FileDescriptor fileDescriptor, ProtoDomain domain); private  ProtoLanguageFileWriter(Descriptors.FileDescriptor fileDescriptor); static void write(
      Descriptors.FileDescriptor fd, ProtoDomain PContainer, OutputStream outputStream); static String write(Descriptors.FileDescriptor fd, ProtoDomain PContainer); static void write(Descriptors.FileDescriptor fd, OutputStream outputStream); static String write(Descriptors.FileDescriptor fd); void write(PrintWriter writer);  }### Answer:
@Test public void extensionTest() throws Exception { DescriptorProtos.FileDescriptorProto.Builder fileDescriptorProtoBuilder = DescriptorProtos.FileDescriptorProto.newBuilder() .setName("test") .setSyntax("proto3") .addDependency("google/protobuf/descriptor.proto"); DescriptorProtos.FieldDescriptorProto extensionField = DescriptorProtos.FieldDescriptorProto.newBuilder() .setName("test_extension") .setNumber(66666700) .setType(DescriptorProtos.FieldDescriptorProto.Type.TYPE_STRING) .setExtendee(".google.protobuf.FileOptions") .build(); fileDescriptorProtoBuilder.addExtension(extensionField); Descriptors.FileDescriptor[] dependencies = new Descriptors.FileDescriptor[1]; dependencies[0] = DescriptorProtos.getDescriptor(); Descriptors.FileDescriptor fileDescriptor = Descriptors.FileDescriptor.buildFrom(fileDescriptorProtoBuilder.build(), dependencies); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ProtoLanguageFileWriter.write(fileDescriptor, outputStream); String expected = "syntax = \"proto3\";\n" + "\n" + "import \"google/protobuf/descriptor.proto\";\n" + "\n" + "\n" + "\n" + "extend google.protobuf.FileOptions {\n" + "\tstring test_extension = 66666700;\n" + "}\n" + "\n"; Assert.assertEquals(expected, outputStream.toString()); }