~ubuntu-branches/debian/experimental/protobuf/experimental

« back to all changes in this revision

Viewing changes to java/src/test/java/com/google/protobuf/MessageTest.java

  • Committer: Package Import Robot
  • Author(s): Robert S. Edmonds, Micah Anderson, Colin Watson, Steve Langasek, Robert S. Edmonds
  • Date: 2013-10-12 18:32:37 UTC
  • mfrom: (1.3.1) (10.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20131012183237-jz6tvmj9tn68atrf
Tags: 2.5.0-1
[ Micah Anderson ]
* New upstream version. (Closes: #704731.)
* Update debian/watch.
* Refresh patches.

[ Colin Watson ]
* Use the autotools-dev dh addon to update config.guess/config.sub for
  arm64. (Closes: #725976.)

[ Steve Langasek ]
* Don't recommend protobuf-compiler from the bindings, it's not used and
  this doesn't need to be pulled in at runtime. (Closes: #703628.)
* Mark protobuf-compiler Multi-Arch: foreign; the output of this command
  is architecture-independent source, we don't need the version of the
  compiler to match the target arch.
* Bump to debhelper compat 9, so that our libs get installed to the
  multiarch locations.
* Mark the library packages Multi-Arch: same.
* Fix debian/rules to support cross-building of the python bindings.
* Build-depend on libpython-dev, not python-dev, for cross-build
  compatibility.
* (Closes: #726083.)

[ Robert S. Edmonds ]
* Upload to experimental.
* Bump ABI version from 7 to 8.
* Bump Standards-Version to 3.9.4.
* Convert from python-support to dh-python.
* Drop support for python2.6.
* python-protobuf: switch back to the pure Python implementation, as
  upstream appears to no longer be maintaining the current C++ based Python
  binding. See the following upstream issues for details:
  - https://code.google.com/p/protobuf/issues/detail?id=434
  - https://code.google.com/p/protobuf/issues/detail?id=503

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
import junit.framework.TestCase;
40
40
 
 
41
import java.util.List;
 
42
 
41
43
/**
42
44
 * Misc. unit tests for message operations that apply to both generated
43
45
 * and dynamic messages.
310
312
      assertEquals("Message missing required fields: a, b, c", e.getMessage());
311
313
    }
312
314
  }
 
315
  
 
316
  /** Test reading unset repeated message from DynamicMessage. */
 
317
  public void testDynamicRepeatedMessageNull() throws Exception {
 
318
    Descriptors.Descriptor descriptor = TestRequired.getDescriptor();
 
319
    DynamicMessage result =
 
320
      DynamicMessage.newBuilder(TestAllTypes.getDescriptor())
 
321
        .mergeFrom(DynamicMessage.newBuilder(MERGE_SOURCE).build())
 
322
        .build();
 
323
 
 
324
    assertTrue(result.getField(result.getDescriptorForType()
 
325
        .findFieldByName("repeated_foreign_message")) instanceof List<?>);
 
326
    assertEquals(result.getRepeatedFieldCount(result.getDescriptorForType()
 
327
        .findFieldByName("repeated_foreign_message")), 0);
 
328
  }
 
329
  
 
330
  /** Test reading repeated message from DynamicMessage. */
 
331
  public void testDynamicRepeatedMessageNotNull() throws Exception {
 
332
 
 
333
    TestAllTypes REPEATED_NESTED =
 
334
      TestAllTypes.newBuilder()
 
335
        .setOptionalInt32(1)
 
336
        .setOptionalString("foo")
 
337
        .setOptionalForeignMessage(ForeignMessage.getDefaultInstance())
 
338
        .addRepeatedString("bar")
 
339
        .addRepeatedForeignMessage(ForeignMessage.getDefaultInstance())
 
340
        .addRepeatedForeignMessage(ForeignMessage.getDefaultInstance())
 
341
        .build();
 
342
    Descriptors.Descriptor descriptor = TestRequired.getDescriptor();
 
343
    DynamicMessage result =
 
344
      DynamicMessage.newBuilder(TestAllTypes.getDescriptor())
 
345
        .mergeFrom(DynamicMessage.newBuilder(REPEATED_NESTED).build())
 
346
        .build();
 
347
 
 
348
    assertTrue(result.getField(result.getDescriptorForType()
 
349
        .findFieldByName("repeated_foreign_message")) instanceof List<?>);
 
350
    assertEquals(result.getRepeatedFieldCount(result.getDescriptorForType()
 
351
        .findFieldByName("repeated_foreign_message")), 2);
 
352
  }
313
353
}