avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From th...@apache.org
Subject [10/36] avro git commit: [fix] use a logger instead of System.out + reformat to 2 space indentation
Date Fri, 19 May 2017 17:12:24 GMT
[fix] use a logger instead of System.out +  reformat to 2 space indentation

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

Branch: refs/heads/master
Commit: df57d3ad29918b6c45b6fce15d4f0815024d49f2
Parents: b5e13ff
Author: Zoltan Farkas <zolyfarkas@yahoo.com>
Authored: Mon Apr 4 11:50:52 2016 -0400
Committer: Zoltan Farkas <zolyfarkas@yahoo.com>
Committed: Mon Apr 4 11:50:52 2016 -0400

----------------------------------------------------------------------
 .../org/apache/avro/compiler/idl/TestCycle.java | 102 ++++++++++---------
 1 file changed, 52 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/df57d3ad/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestCycle.java
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestCycle.java
b/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestCycle.java
index a38e978..bc76959 100644
--- a/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestCycle.java
+++ b/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestCycle.java
@@ -23,7 +23,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.apache.avro.Protocol;
 import org.apache.avro.Schema;
 import org.apache.avro.compiler.specific.SpecificCompiler;
@@ -36,6 +36,8 @@ import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.DecoderFactory;
 import org.apache.avro.io.EncoderFactory;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
@@ -43,63 +45,63 @@ import org.junit.Test;
  */
 public class TestCycle {
 
-    @Test
-    public void testCycleGeneration() throws ParseException, IOException {
-        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        Idl idl = new Idl(cl.getResourceAsStream("input/cycle.avdl"),
-                "UTF-8");
-        Protocol protocol = idl.CompilationUnit();
-        String json = protocol.toString();
-        System.out.println(json);
+  private static final Logger LOG = LoggerFactory.getLogger(TestCycle.class);
+  
+  @Test
+  public void testCycleGeneration() throws ParseException, IOException {
+    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+    Idl idl = new Idl(cl.getResourceAsStream("input/cycle.avdl"),
+            "UTF-8");
+    Protocol protocol = idl.CompilationUnit();
+    String json = protocol.toString();
+    LOG.info(json);
 
-        SpecificCompiler compiler = new SpecificCompiler(protocol);
-        compiler.setStringType(GenericData.StringType.String);
-        File output = new File("./target");
-        compiler.compileToDestination(null, output);
+    SpecificCompiler compiler = new SpecificCompiler(protocol);
+    compiler.setStringType(GenericData.StringType.String);
+    File output = new File("./target");
+    compiler.compileToDestination(null, output);
 
-        Map<String, Schema> schemas = new HashMap<String, Schema>();
-        for (Schema schema : protocol.getTypes()) {
-            final String name = schema.getName();
-            schemas.put(name, schema);
-        }
-
-        GenericRecordBuilder rb2 = new GenericRecordBuilder(schemas.get("SampleNode"));
-        rb2.set("count", 10);
-        rb2.set("subNodes", Collections.EMPTY_LIST);
-        GenericData.Record node = rb2.build();
+    Map<String, Schema> schemas = new HashMap<String, Schema>();
+    for (Schema schema : protocol.getTypes()) {
+      final String name = schema.getName();
+      schemas.put(name, schema);
+    }
 
-        GenericRecordBuilder mb = new GenericRecordBuilder(schemas.get("Method"));
-        mb.set("declaringClass", "Test");
-        mb.set("methodName", "test");
-        GenericData.Record method = mb.build();
+    GenericRecordBuilder rb2 = new GenericRecordBuilder(schemas.get("SampleNode"));
+    rb2.set("count", 10);
+    rb2.set("subNodes", Collections.EMPTY_LIST);
+    GenericData.Record node = rb2.build();
 
-        GenericRecordBuilder spb = new GenericRecordBuilder(schemas.get("SamplePair"));
-        spb.set("method", method);
-        spb.set("node", node);
-        GenericData.Record sp = spb.build();
+    GenericRecordBuilder mb = new GenericRecordBuilder(schemas.get("Method"));
+    mb.set("declaringClass", "Test");
+    mb.set("methodName", "test");
+    GenericData.Record method = mb.build();
 
+    GenericRecordBuilder spb = new GenericRecordBuilder(schemas.get("SamplePair"));
+    spb.set("method", method);
+    spb.set("node", node);
+    GenericData.Record sp = spb.build();
 
-        GenericRecordBuilder rb = new GenericRecordBuilder(schemas.get("SampleNode"));
-        rb.set("count", 10);
-        rb.set("subNodes", Arrays.asList(sp));
-        GenericData.Record record = rb.build();
+    GenericRecordBuilder rb = new GenericRecordBuilder(schemas.get("SampleNode"));
+    rb.set("count", 10);
+    rb.set("subNodes", Arrays.asList(sp));
+    GenericData.Record record = rb.build();
 
-        serDeserRecord(record);
+    serDeserRecord(record);
 
-    }
-
-    private static void serDeserRecord(GenericData.Record data) throws IOException {
-        ByteArrayOutputStream bab = new ByteArrayOutputStream();
-        GenericDatumWriter writer = new GenericDatumWriter(data.getSchema());
-        final BinaryEncoder directBinaryEncoder = EncoderFactory.get().directBinaryEncoder(bab,
null);
-        writer.write(data, directBinaryEncoder);
-        directBinaryEncoder.flush();
-        ByteArrayInputStream bis = new ByteArrayInputStream(bab.toByteArray(), 0, bab.size());
-        GenericDatumReader reader = new GenericDatumReader(data.getSchema());
-        BinaryDecoder directBinaryDecoder = DecoderFactory.get().directBinaryDecoder(bis,
null);
-        GenericData.Record read = (GenericData.Record) reader.read(null, directBinaryDecoder);
-        Assert.assertEquals(data.toString(), read.toString());
-    }
+  }
 
+  private static void serDeserRecord(GenericData.Record data) throws IOException {
+    ByteArrayOutputStream bab = new ByteArrayOutputStream();
+    GenericDatumWriter writer = new GenericDatumWriter(data.getSchema());
+    final BinaryEncoder directBinaryEncoder = EncoderFactory.get().directBinaryEncoder(bab,
null);
+    writer.write(data, directBinaryEncoder);
+    directBinaryEncoder.flush();
+    ByteArrayInputStream bis = new ByteArrayInputStream(bab.toByteArray(), 0, bab.size());
+    GenericDatumReader reader = new GenericDatumReader(data.getSchema());
+    BinaryDecoder directBinaryDecoder = DecoderFactory.get().directBinaryDecoder(bis, null);
+    GenericData.Record read = (GenericData.Record) reader.read(null, directBinaryDecoder);
+    Assert.assertEquals(data.toString(), read.toString());
+  }
 
 }


Mime
View raw message