Package org.apache.avro.test

Examples of org.apache.avro.test.TestRecord


    List<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(new Schema.Field("f", TestRecord.SCHEMA$, "", null));
    schema.setFields(fields);

    // create a generic instance of this record
    TestRecord nested = new TestRecord();
    nested.setName("foo");
    nested.setKind(Kind.BAR);
    nested.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    GenericData.Record record = new GenericData.Record(schema);
    record.put("f", nested);

    // test that this instance can be written & re-read
    TestSchema.checkBinary(schema, record,
View Full Code Here


    error.hashCode();
  }

  @Test
  public void testEcho() throws IOException {
    TestRecord record = new TestRecord();
    record.setName("foo");
    record.setKind(Kind.BAR);
    record.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    TestRecord echoed = proxy.echo(record);
    assertEquals(record, echoed);
    assertEquals(record.hashCode(), echoed.hashCode());
  }
View Full Code Here

public class TestSpecificData {
 
  @Test
  /** Make sure that even with nulls, hashCode() doesn't throw NPE. */
  public void testHashCode() {
    new TestRecord().hashCode();
    SpecificData.get().hashCode(null, TestRecord.SCHEMA$);
  }
View Full Code Here

  }

  @Test
  /** Make sure that even with nulls, toString() doesn't throw NPE. */
  public void testToString() {
    new TestRecord().toString();
  }
View Full Code Here

    List<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(new Schema.Field("f", TestRecord.SCHEMA$, "", null));
    schema.setFields(fields);

    // create a generic instance of this record
    TestRecord nested = new TestRecord();
    nested.setName("foo");
    nested.setKind(Kind.BAR);
    nested.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    GenericData.Record record = new GenericData.Record(schema);
    record.put("f", nested);

    // test that this instance can be written & re-read
    TestSchema.checkBinary(schema, record,
View Full Code Here

    // will throw exception if string is not parsable json
    mapper.readTree(parser);
  }

  @Test public void testExternalizeable() throws Exception {
    TestRecord before = new TestRecord();
    before.setName("foo");
    before.setKind(Kind.BAR);
    before.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bytes);
    out.writeObject(before);
    out.close();

    ObjectInputStream in =
      new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
    TestRecord after = (TestRecord)in.readObject();

    Assert.assertEquals(before, after);

  }
View Full Code Here

    check("[\"string\", \"long\"]", new Utf8("a"), new Long(1), false);
  }

  @Test
  public void testSpecificRecord() throws Exception {
    TestRecord s1 = new TestRecord();
    TestRecord s2 = new TestRecord();
    s1.setName("foo");
    s1.setKind(Kind.BAZ);
    s1.setHash(new MD5(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    s2.setName("bar");
    s2.setKind(Kind.BAR);
    s2.setHash(new MD5(new byte[] {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,6}));
    Schema schema = SpecificData.get().getSchema(TestRecord.class);

    check(schema, s1, s2, true, new SpecificDatumWriter<TestRecord>(schema),
          SpecificData.get());
    s2.setKind(Kind.BAZ);
    check(schema, s1, s2, true, new SpecificDatumWriter<TestRecord>(schema),
          SpecificData.get());
 
View Full Code Here

public class TestSpecificData {
 
  @Test
  /** Make sure that even with nulls, hashCode() doesn't throw NPE. */
  public void testHashCode() {
    new TestRecord().hashCode();
    SpecificData.get().hashCode(null, TestRecord.SCHEMA$);
  }
View Full Code Here

  }

  @Test
  /** Make sure that even with nulls, toString() doesn't throw NPE. */
  public void testToString() {
    new TestRecord().toString();
  }
View Full Code Here

    List<Schema.Field> fields = new ArrayList<Schema.Field>();
    fields.add(new Schema.Field("f", TestRecord.SCHEMA$, "", null));
    schema.setFields(fields);

    // create a generic instance of this record
    TestRecord nested = new TestRecord();
    nested.setName("foo");
    nested.setKind(Kind.BAR);
    nested.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
    GenericData.Record record = new GenericData.Record(schema);
    record.put("f", nested);

    // test that this instance can be written & re-read
    TestSchema.checkBinary(schema, record,
View Full Code Here

TOP

Related Classes of org.apache.avro.test.TestRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.