crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tzo...@apache.org
Subject [3/3] git commit: clean the test code
Date Fri, 10 May 2013 06:22:47 GMT
clean the test code


Project: http://git-wip-us.apache.org/repos/asf/crunch/repo
Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/70da18c5
Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/70da18c5
Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/70da18c5

Branch: refs/heads/master
Commit: 70da18c541b951d3ae6ca3ffe9e0b3ab13519c1f
Parents: d757048
Author: tzolov <tzolov@apache.org>
Authored: Fri May 10 07:13:59 2013 +0200
Committer: tzolov <tzolov@apache.org>
Committed: Fri May 10 07:13:59 2013 +0200

----------------------------------------------------------------------
 .../apache/crunch/io/avro/AvroMemPipelineIT.java   |   31 ++++++++-------
 1 files changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/crunch/blob/70da18c5/crunch-core/src/it/java/org/apache/crunch/io/avro/AvroMemPipelineIT.java
----------------------------------------------------------------------
diff --git a/crunch-core/src/it/java/org/apache/crunch/io/avro/AvroMemPipelineIT.java b/crunch-core/src/it/java/org/apache/crunch/io/avro/AvroMemPipelineIT.java
index b997a52..9cafa3f 100644
--- a/crunch-core/src/it/java/org/apache/crunch/io/avro/AvroMemPipelineIT.java
+++ b/crunch-core/src/it/java/org/apache/crunch/io/avro/AvroMemPipelineIT.java
@@ -27,7 +27,6 @@ import java.util.List;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericData.Record;
 import org.apache.avro.generic.GenericRecord;
-import org.apache.avro.util.Utf8;
 import org.apache.crunch.PCollection;
 import org.apache.crunch.impl.mem.MemPipeline;
 import org.apache.crunch.io.At;
@@ -56,8 +55,7 @@ public class AvroMemPipelineIT implements Serializable {
   @Test
   public void testMemPipelienWithSpecificRecord() {
 
-    List<CharSequence> siblingnames = Lists.newArrayList();
-    Person writeRecord = new Person("John", 41, siblingnames);
+    Person writeRecord = createSpecificRecord();
 
     final PCollection<Person> writeCollection = MemPipeline.collectionOf(Collections.singleton(writeRecord));
 
@@ -67,29 +65,34 @@ public class AvroMemPipelineIT implements Serializable {
         At.avroFile(avroFile.getAbsolutePath(), Avros.records(Person.class)));
 
     Person readRecord = readCollection.materialize().iterator().next();
-    
+
     assertEquals(writeRecord, readRecord);
   }
 
+  private Person createSpecificRecord() {
+    List<CharSequence> siblingnames = Lists.newArrayList();
+    return new Person("John", 41, siblingnames);
+  }
+
   @Test
   public void testMemPipelienWithGenericRecord() {
 
     GenericRecord writeRecord = createGenericRecord();
-    
-    final PCollection<GenericRecord> persons = MemPipeline.collectionOf(Collections.singleton(writeRecord));
 
-    persons.write(To.avroFile(avroFile.getAbsolutePath()));
+    final PCollection<GenericRecord> writeCollection = MemPipeline.collectionOf(Collections.singleton(writeRecord));
+
+    writeCollection.write(To.avroFile(avroFile.getAbsolutePath()));
 
     PCollection<Record> readCollection = MemPipeline.getInstance().read(
         At.avroFile(avroFile.getAbsolutePath(), Avros.generics(writeRecord.getSchema())));
 
     Record readRecord = readCollection.materialize().iterator().next();
-    
+
     assertEquals(writeRecord, readRecord);
   }
 
   private GenericRecord createGenericRecord() {
-    
+
     GenericRecord savedRecord = new GenericData.Record(Person.SCHEMA$);
     savedRecord.put("name", "John Doe");
     savedRecord.put("age", 42);
@@ -97,21 +100,21 @@ public class AvroMemPipelineIT implements Serializable {
 
     return savedRecord;
   }
-  
+
   @Test
   public void testMemPipelienWithReflectionRecord() {
 
     String writeRecord = "John Doe";
-    
-    final PCollection<String> persons = MemPipeline.collectionOf(Collections.singleton(writeRecord));
 
-    persons.write(To.avroFile(avroFile.getAbsolutePath()));
+    final PCollection<String> writeCollection = MemPipeline.collectionOf(Collections.singleton(writeRecord));
+
+    writeCollection.write(To.avroFile(avroFile.getAbsolutePath()));
 
     PCollection<? extends String> readCollection = MemPipeline.getInstance().read(
         At.avroFile(avroFile.getAbsolutePath(), Avros.reflects(writeRecord.getClass())));
 
     Object readRecord = readCollection.materialize().iterator().next();
-    
+
     assertEquals(writeRecord, readRecord.toString());
   }
 


Mime
View raw message