use of com.twitter.data.proto.tutorial.AddressBookProtos.AddressBook in project elephant-bird by twitter.
the class TestTypedProtobufWritable method setUp.
@BeforeClass
public static void setUp() {
Person p1 = Person.newBuilder().setEmail("email1@example.com").setId(74).setName("Example Person").addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("2930423").build()).addPhone(PhoneNumber.newBuilder().setType(PhoneType.HOME).setNumber("214121").build()).build();
Person p2 = Person.newBuilder().setEmail("email2@example.com").setId(7334).setName("Another person").addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("030303").build()).build();
referenceAb = AddressBook.newBuilder().addPerson(p1).addPerson(p2).build();
referenceAbWritable = new TypedProtobufWritable<AddressBook>(referenceAb);
}
use of com.twitter.data.proto.tutorial.AddressBookProtos.AddressBook in project elephant-bird by twitter.
the class TestTypedProtobufWritable method testReadWrite.
@Test
public void testReadWrite() throws IOException {
DataOutputStream dos = new DataOutputStream(new FileOutputStream("test.txt"));
referenceAbWritable.write(dos);
dos.close();
DataInputStream dis = new DataInputStream(new FileInputStream("test.txt"));
TypedProtobufWritable<AddressBook> after = new TypedProtobufWritable<AddressBook>();
after.readFields(dis);
dis.close();
AddressBook ab2 = after.get();
assertEquals(referenceAb, ab2);
assertEquals(referenceAbWritable.hashCode(), after.hashCode());
}
use of com.twitter.data.proto.tutorial.AddressBookProtos.AddressBook in project elephant-bird by twitter.
the class TestProtobufWritable method setUp.
@BeforeClass
public static void setUp() {
Person p1 = Person.newBuilder().setEmail("email1@example.com").setId(74).setName("Example Person").addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("2930423").build()).addPhone(PhoneNumber.newBuilder().setType(PhoneType.HOME).setNumber("214121").build()).build();
Person p2 = Person.newBuilder().setEmail("email2@example.com").setId(7334).setName("Another person").addPhone(PhoneNumber.newBuilder().setType(PhoneType.MOBILE).setNumber("030303").build()).build();
referenceAb = AddressBook.newBuilder().addPerson(p1).addPerson(p2).build();
referenceAbWritable = new ProtobufWritable<AddressBook>(referenceAb, new TypeRef<AddressBook>() {
});
}
use of com.twitter.data.proto.tutorial.AddressBookProtos.AddressBook in project elephant-bird by twitter.
the class TestProtobufWritable method testReadWrite.
@Test
public void testReadWrite() throws IOException {
DataOutputStream dos = new DataOutputStream(new FileOutputStream("test.txt"));
referenceAbWritable.write(dos);
dos.close();
DataInputStream dis = new DataInputStream(new FileInputStream("test.txt"));
ProtobufWritable<AddressBook> after = new ProtobufWritable<AddressBook>(new TypeRef<AddressBook>() {
});
after.readFields(dis);
dis.close();
AddressBook ab2 = after.get();
assertEquals(referenceAb, ab2);
assertEquals(referenceAbWritable.hashCode(), after.hashCode());
}
Aggregations