avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject [avro] branch master updated: AVRO-2265 Remove Guava as a test dependency (#377)
Date Tue, 13 Nov 2018 08:50:11 GMT
This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 71be8a4  AVRO-2265 Remove Guava as a test dependency (#377)
71be8a4 is described below

commit 71be8a456ffb250abb22f2a956ae0c6acd5104fa
Author: Fokko Driesprong <fokko@driesprong.frl>
AuthorDate: Tue Nov 13 09:50:05 2018 +0100

    AVRO-2265 Remove Guava as a test dependency (#377)
---
 lang/java/avro/pom.xml                             |  12 --
 .../avro/message/TestBinaryMessageEncoding.java    | 131 ++++++++-------------
 lang/java/mapred/pom.xml                           |  27 -----
 lang/java/pom.xml                                  |   2 -
 4 files changed, 49 insertions(+), 123 deletions(-)

diff --git a/lang/java/avro/pom.xml b/lang/java/avro/pom.xml
index 817bb3a..c9104fb 100644
--- a/lang/java/avro/pom.xml
+++ b/lang/java/avro/pom.xml
@@ -179,18 +179,6 @@
       <groupId>com.github.luben</groupId>
       <artifactId>zstd-jni</artifactId>
     </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-      <version>${guava.version}</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion> <!-- GPL -->
-          <groupId>com.google.code.findbugs</groupId>
-          <artifactId>jsr305</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
   </dependencies>
 
 </project>
diff --git a/lang/java/avro/src/test/java/org/apache/avro/message/TestBinaryMessageEncoding.java
b/lang/java/avro/src/test/java/org/apache/avro/message/TestBinaryMessageEncoding.java
index 0c87189..4cb6c38 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/message/TestBinaryMessageEncoding.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/message/TestBinaryMessageEncoding.java
@@ -20,14 +20,8 @@
 package org.apache.avro.message;
 
 import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Ordering;
-import com.google.common.collect.Sets;
+import java.util.*;
+
 import org.apache.avro.AvroRuntimeException;
 import org.apache.avro.Schema;
 import org.apache.avro.SchemaBuilder;
@@ -38,33 +32,33 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public class TestBinaryMessageEncoding {
-  public static final Schema SCHEMA_V1 = SchemaBuilder.record("TestRecord")
+  private static final Schema SCHEMA_V1 = SchemaBuilder.record("TestRecord")
       .fields()
       .requiredInt("id")
       .optionalString("msg")
       .endRecord();
 
-  public static final GenericRecordBuilder V1_BUILDER =
+  private static final GenericRecordBuilder V1_BUILDER =
       new GenericRecordBuilder(SCHEMA_V1);
 
-  public static final List<Record> V1_RECORDS = Arrays.asList(
+  private static final List<Record> V1_RECORDS = Arrays.asList(
       V1_BUILDER.set("id", 1).set("msg", "m-1").build(),
       V1_BUILDER.set("id", 2).set("msg", "m-2").build(),
       V1_BUILDER.set("id", 4).set("msg", "m-4").build(),
       V1_BUILDER.set("id", 6).set("msg", "m-6").build()
   );
 
-  public static final Schema SCHEMA_V2 = SchemaBuilder.record("TestRecord")
+  private static final Schema SCHEMA_V2 = SchemaBuilder.record("TestRecord")
       .fields()
       .requiredLong("id")
       .name("message").aliases("msg").type().optional().stringType()
       .optionalDouble("data")
       .endRecord();
 
-  public static final GenericRecordBuilder V2_BUILDER =
+  private static final GenericRecordBuilder V2_BUILDER =
       new GenericRecordBuilder(SCHEMA_V2);
 
-  public static final List<Record> V2_RECORDS = Arrays.asList(
+  private static final List<Record> V2_RECORDS = Arrays.asList(
       V2_BUILDER.set("id", 3L).set("message", "m-3").set("data", 12.3).build(),
       V2_BUILDER.set("id", 5L).set("message", "m-5").set("data", 23.4).build(),
       V2_BUILDER.set("id", 7L).set("message", "m-7").set("data", 34.5).build(),
@@ -73,29 +67,25 @@ public class TestBinaryMessageEncoding {
 
   @Test
   public void testByteBufferRoundTrip() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     Record copy = decoder.decode(encoder.encode(V2_RECORDS.get(0)));
 
-    Assert.assertTrue("Copy should not be the same object",
-        copy != V2_RECORDS.get(0));
-    Assert.assertEquals("Record should be identical after round-trip",
-        V2_RECORDS.get(0), copy);
+    Assert.assertNotSame("Copy should not be the same object", copy, V2_RECORDS.get(0));
+    Assert.assertEquals("Record should be identical after round-trip", V2_RECORDS.get(0),
copy);
   }
 
   @Test
   public void testSchemaEvolution() throws Exception {
-    List<ByteBuffer> buffers = Lists.newArrayList();
-    List<Record> records = Ordering.usingToString().sortedCopy(
-        Iterables.concat(V1_RECORDS, V2_RECORDS));
+    List<ByteBuffer> buffers = new ArrayList<>();
+    List<Record> records = new ArrayList<>();
+
+    records.addAll(V1_RECORDS);
+    records.addAll(V2_RECORDS);
 
-    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1);
-    MessageEncoder<Record> v2Encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1);
+    MessageEncoder<Record> v2Encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
 
     for (Record record : records) {
       if (record.getSchema() == SCHEMA_V1) {
@@ -105,21 +95,17 @@ public class TestBinaryMessageEncoding {
       }
     }
 
-    Set<Record> allAsV2 = Sets.newHashSet(V2_RECORDS);
-    allAsV2.add(
-        V2_BUILDER.set("id", 1L).set("message", "m-1").clear("data").build());
-    allAsV2.add(
-        V2_BUILDER.set("id", 2L).set("message", "m-2").clear("data").build());
-    allAsV2.add(
-        V2_BUILDER.set("id", 4L).set("message", "m-4").clear("data").build());
-    allAsV2.add(
-        V2_BUILDER.set("id", 6L).set("message", "m-6").clear("data").build());
-
-    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    Set<Record> allAsV2 = new HashSet<>(V2_RECORDS);
+
+    allAsV2.add(V2_BUILDER.set("id", 1L).set("message", "m-1").clear("data").build());
+    allAsV2.add(V2_BUILDER.set("id", 2L).set("message", "m-2").clear("data").build());
+    allAsV2.add(V2_BUILDER.set("id", 4L).set("message", "m-4").clear("data").build());
+    allAsV2.add(V2_BUILDER.set("id", 6L).set("message", "m-6").clear("data").build());
+
+    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
     v2Decoder.addSchema(SCHEMA_V1);
 
-    Set<Record> decodedUsingV2 = Sets.newHashSet();
+    Set<Record> decodedUsingV2 = new HashSet<>();
     for (ByteBuffer buffer : buffers) {
       decodedUsingV2.add(v2Decoder.decode(buffer));
     }
@@ -129,10 +115,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = MissingSchemaException.class)
   public void testCompatibleReadFailsWithoutSchema() throws Exception {
-    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1);
-    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1);
+    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer v1Buffer = v1Encoder.encode(V1_RECORDS.get(3));
 
@@ -141,10 +125,8 @@ public class TestBinaryMessageEncoding {
 
   @Test
   public void testCompatibleReadWithSchema() throws Exception {
-    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1);
-    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1);
+    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
     v2Decoder.addSchema(SCHEMA_V1);
 
     ByteBuffer v1Buffer = v1Encoder.encode(V1_RECORDS.get(3));
@@ -158,13 +140,11 @@ public class TestBinaryMessageEncoding {
 
   @Test
   public void testCompatibleReadWithSchemaFromLookup() throws Exception {
-    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1);
+    MessageEncoder<Record> v1Encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1);
 
     SchemaStore.Cache schemaCache = new SchemaStore.Cache();
     schemaCache.addSchema(SCHEMA_V1);
-    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2, schemaCache);
+    BinaryMessageDecoder<Record> v2Decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2, schemaCache);
 
     ByteBuffer v1Buffer = v1Encoder.encode(V1_RECORDS.get(2));
 
@@ -180,32 +160,29 @@ public class TestBinaryMessageEncoding {
     // This test depends on the serialized version of record 1 being smaller or
     // the same size as record 0 so that the reused ByteArrayOutputStream won't
     // expand its internal buffer.
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1, false);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1, false);
 
     ByteBuffer b0 = encoder.encode(V1_RECORDS.get(0));
     ByteBuffer b1 = encoder.encode(V1_RECORDS.get(1));
 
     Assert.assertEquals(b0.array(), b1.array());
 
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V1);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V1);
     Assert.assertEquals("Buffer was reused, decode(b0) should be record 1",
         V1_RECORDS.get(1), decoder.decode(b0));
   }
 
   @Test
   public void testBufferCopy() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V1);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V1);
 
     ByteBuffer b0 = encoder.encode(V1_RECORDS.get(0));
     ByteBuffer b1 = encoder.encode(V1_RECORDS.get(1));
 
     Assert.assertNotEquals(b0.array(), b1.array());
 
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V1);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V1);
+
     // bytes are not changed by reusing the encoder
     Assert.assertEquals("Buffer was copied, decode(b0) should be record 0",
         V1_RECORDS.get(0), decoder.decode(b0));
@@ -213,10 +190,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = AvroRuntimeException.class)
   public void testByteBufferMissingPayload() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer buffer = encoder.encode(V2_RECORDS.get(0));
 
@@ -227,10 +202,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = BadHeaderException.class)
   public void testByteBufferMissingFullHeader() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer buffer = encoder.encode(V2_RECORDS.get(0));
 
@@ -241,10 +214,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = BadHeaderException.class)
   public void testByteBufferBadMarkerByte() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer buffer = encoder.encode(V2_RECORDS.get(0));
     buffer.array()[0] = 0x00;
@@ -254,10 +225,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = BadHeaderException.class)
   public void testByteBufferBadVersionByte() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer buffer = encoder.encode(V2_RECORDS.get(0));
     buffer.array()[1] = 0x00;
@@ -267,10 +236,8 @@ public class TestBinaryMessageEncoding {
 
   @Test(expected = MissingSchemaException.class)
   public void testByteBufferUnknownSchema() throws Exception {
-    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(
-        GenericData.get(), SCHEMA_V2);
-    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(
-        GenericData.get(), SCHEMA_V2);
+    MessageEncoder<Record> encoder = new BinaryMessageEncoder<>(GenericData.get(),
SCHEMA_V2);
+    MessageDecoder<Record> decoder = new BinaryMessageDecoder<>(GenericData.get(),
SCHEMA_V2);
 
     ByteBuffer buffer = encoder.encode(V2_RECORDS.get(0));
     buffer.array()[4] = 0x00;
diff --git a/lang/java/mapred/pom.xml b/lang/java/mapred/pom.xml
index fb705ef..368226a 100644
--- a/lang/java/mapred/pom.xml
+++ b/lang/java/mapred/pom.xml
@@ -101,33 +101,6 @@
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-enforcer-plugin</artifactId>
-        <version>1.4.1</version>
-        <executions>
-          <execution>
-            <id>enforce-banned-dependencies</id>
-            <goals>
-              <goal>enforce</goal>
-            </goals>
-            <configuration>
-              <rules>
-                <bannedDependencies>
-                  <!-- Ban all versions of Guava other than 11.0.2 that Hadoop uses -->
-                  <excludes>
-                    <exclude>com.google.guava:guava</exclude>
-                  </excludes>
-                  <includes>
-                    <include>com.google.guava:guava:11.0.2</include>
-                  </includes>
-                </bannedDependencies>
-              </rules>
-              <fail>true</fail>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>
 
diff --git a/lang/java/pom.xml b/lang/java/pom.xml
index cb596cf..43892c0 100644
--- a/lang/java/pom.xml
+++ b/lang/java/pom.xml
@@ -62,8 +62,6 @@
     <hamcrest.version>1.3</hamcrest.version>
     <joda.version>2.10.1</joda.version>
     <grpc.version>1.16.1</grpc.version>
-    <!-- This Guava version should match Hadoop's Guava version. See AVRO-1781. -->
-    <guava.version>11.0.2</guava.version>
     <findbugs-annotations.version>1.3.9-1</findbugs-annotations.version>
     <zstd-jni.version>1.3.7-1</zstd-jni.version>
 


Mime
View raw message