}
public void testDynamicOneofMessage() throws Exception {
DynamicMessage.Builder builder =
DynamicMessage.newBuilder(TestAllTypes.getDescriptor());
OneofDescriptor oneof = TestAllTypes.getDescriptor().getOneofs().get(0);
assertFalse(builder.hasOneof(oneof));
assertSame(null, builder.getOneofFieldDescriptor(oneof));
reflectionTester.setAllFieldsViaReflection(builder);
assertTrue(builder.hasOneof(oneof));
FieldDescriptor field = oneof.getField(3);
assertSame(field, builder.getOneofFieldDescriptor(oneof));
DynamicMessage message = builder.buildPartial();
assertTrue(message.hasOneof(oneof));
DynamicMessage.Builder mergedBuilder =
DynamicMessage.newBuilder(TestAllTypes.getDescriptor());
FieldDescriptor mergedField = oneof.getField(0);
mergedBuilder.setField(mergedField, 123);
assertTrue(mergedBuilder.hasField(mergedField));
mergedBuilder.mergeFrom(message);
assertTrue(mergedBuilder.hasField(field));
assertFalse(mergedBuilder.hasField(mergedField));