Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1427

Minor issues with Resolving Decoder Tests

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.5
    • Fix Version/s: 1.7.6
    • Component/s: java
    • Labels:

      Description

      Hard coded TestValidatingIO.Encoding.BINARY is used rather than "this.eEnc" passed in via the @Parameterized test, preventing the other Encodings being tested.

      TestResolvingIOResolving.java
        @Test
        public void testResolving()
          throws IOException {
          Schema writerSchema = new Schema.Parser().parse(sJsWrtSchm);
          byte[] bytes = TestValidatingIO.make(writerSchema, sWrtCls,
              oaWrtVals, TestValidatingIO.Encoding.BINARY);
      // Needs changing to
        @Test
        public void testResolving()
          throws IOException {
          Schema writerSchema = new Schema.Parser().parse(sJsWrtSchm);
          byte[] bytes = TestValidatingIO.make(writerSchema, sWrtCls,
              oaWrtVals, eEnc);
      

      Number types are not checked for exact matches in TestResolvingIO.check() so that an expected type of Integer 100 matches Long 100 at line 178 as follows:

      TestResolvingIOResolving.java
              { "[ \"int\", \"string\"]", "U0I", new Object[] { 100 },
                  "\"long\"", "L", new Object[] { 100 } },
      // Needs changing to
              { "[ \"int\", \"string\"]", "U0I", new Object[] { 100 },
                  "\"long\"", "L", new Object[] { 100L } },
      

      The above fix to TestResolvingIO.check() makes TestResolvingIO fail, so the expected values need to be generated with the correct type and not just reuse the random input values. This can be done by making the random generation deterministic so that correctly typed expected values may be generated.

      TestValidatingIO.java
        public static Object[] randomValues(String calls) {
          Random r = new Random();
      // Needs changing to
        public static Object[] randomValues(String calls) {
          Random r = new Random(0L);
      

      Patch to follow.

        Attachments

        1. AVRO-1427.patch
          8 kB
          Rob Turner

          Activity

            People

            • Assignee:
              robair Rob Turner
              Reporter:
              robair Rob Turner
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: