Updates:
Status: WorkingAsIntended
Comment #1 on issue 416 by jas...@google.com: HasField is throwing
UnsupportedOperationException on repeated fields
http://code.google.com/p/protobuf/issues/detail?id=416
Do you really get an UnsupportedOperationException? You should get
Is there a tool that can be used to generated test cases given a .proto
file? I'm looking for something that will take a .proto file, and then
generate source code that creates the different message structures and
assigns random values to fields for testing purposes. I'm specifically
Hi Marc,
I had a similar question about the serialization of objects using protocol
buffers.
I prefer using a single .proto file for generation of C# and Java file, and
would like to know if my understanding of how to implement a generic list
of objects in the .proto file is right or not.
Hello,
I have plan for introducing protobuf to in our products for passing
information of product's input project file structure.
And this information may frequently upgrade near future(via product version
upgrade).
So, I have a question.
If I remove old field from message and add new field,
i do like following, and id does success;
ListFieldDescriptor fieldlist =
dynamicmsg.getDescriptorForType().getFields();
Protocal.Builder buildermsg = Protocal.newBuilder();
for(FieldDescriptor fieldDp : fieldlist){
buildermsg.setField(fieldDp, dynamicmsg .getField(fieldDp));
public static Message createMessage(String messageName) {
FileDescriptor dps = Addressbook.getDescriptor();
System.out.println(dps.getPackage());
Descriptor dp = dps.findMessageTypeByName(messageName);
...
return null;
}
by the messageName I have got the Descriptor
Are you using the getFooBuilder() methods?
A common practice for tests is to use the TextFormat: you can write out the
string representation of the pb you want, and then parse into a PB object.
Or you could narrow the API of your methods under test to take only the
submessages that they need.
You would need to list out all the message types you want to use, and
maintain a map from their Descriptor to their default instance (accessible
with getDefaultInstance()). You can then call newBuilder or other
construction methods.
If you are ok with using a dynamic rather than generated message
You can also copy via serialization:
Protocal.parseFrom(dynamicmsg.toByteArray());
On Sun, Sep 2, 2012 at 8:32 PM, qtom zheng zhfnj...@gmail.com wrote:
i do like following, and id does success;
ListFieldDescriptor fieldlist =
dynamicmsg.getDescriptorForType().getFields();
You can control whether the vector is empty or not: you can reserve memory
for the vector based on the descriptor size, or reuse a vector previously
passed to ListFields - calling vector::clear() does not delete the
allocated memory.
Admittedly, the reflection code is not heavily optimized. But
The general practices for changing messages are listed here:
https://developers.google.com/protocol-buffers/docs/proto#updating.
On Wed, Sep 5, 2012 at 7:04 PM, Minhyuk Kwon mug...@gmail.com wrote:
Hello,
I have plan for introducing protobuf to in our products for passing
information of
11 matches
Mail list logo