Bael 518 protobuffer (#1400)

* BEEL-518 code for protobuf article

* BEEL-518 add generated protobuf class

* BEEL-550 use newest version of protobuff

* BAEL-518 Small refactoring in protobuffer module

* BEEL-518 simpler protobuf example

* BEEL-518 proper package
This commit is contained in:
Tomasz Lelek
2017-03-25 11:14:09 +01:00
committed by Grzegorz Piwowarek
parent 669f4d6dce
commit 21f9df6330
13 changed files with 334 additions and 1283 deletions
View File
File diff suppressed because it is too large Load Diff
@@ -8,18 +8,7 @@ message Person {
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phones = 4;
repeated string numbers = 4;
}
message AddressBook {
@@ -28,24 +28,18 @@ public class ProtobufTest {
int id = new Random().nextInt();
String name = "Michael Program";
String number = "01234567890";
AddressBookProtos.Person.PhoneType type = AddressBookProtos.Person.PhoneType.HOME;
AddressBookProtos.Person person =
AddressBookProtos.Person.newBuilder()
.setId(id)
.setName(name)
.setEmail(email)
.addPhones(
AddressBookProtos.Person.PhoneNumber.newBuilder()
.setNumber(number)
.setType(type))
.addNumbers(number)
.build();
//then
assertEquals(person.getEmail(), email);
assertEquals(person.getId(), id);
assertEquals(person.getName(), name);
assertEquals(person.getPhones(0).getNumber(), number);
assertEquals(person.getPhones(0).getType(), type);
assertEquals(person.getPhonesList().size(), 1);
assertEquals(person.getNumbers(0), number);
}
@@ -56,16 +50,12 @@ public class ProtobufTest {
int id = new Random().nextInt();
String name = "Michael Program";
String number = "01234567890";
AddressBookProtos.Person.PhoneType type = AddressBookProtos.Person.PhoneType.HOME;
AddressBookProtos.Person person =
AddressBookProtos.Person.newBuilder()
.setId(id)
.setName(name)
.setEmail(email)
.addPhones(
AddressBookProtos.Person.PhoneNumber.newBuilder()
.setNumber(number)
.setType(type))
.addNumbers(number)
.build();
//when
@@ -82,9 +72,8 @@ public class ProtobufTest {
assertEquals(deserialized.getPeople(0).getEmail(), email);
assertEquals(deserialized.getPeople(0).getId(), id);
assertEquals(deserialized.getPeople(0).getName(), name);
assertEquals(deserialized.getPeople(0).getPhones(0).getNumber(), number);
assertEquals(deserialized.getPeople(0).getPhones(0).getType(), type);
assertEquals(deserialized.getPeople(0).getPhonesList().size(), 1);
assertEquals(deserialized.getPeople(0).getNumbers(0), number);
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,39 @@
\\ //
\\ .ooo. //
.@@@@@@@@@.
:@@@@@@@@@@@@@:
:@@. '@@@@@' .@@:
@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@
:@@ :@@@@@@@@@@@@@@@@@. @@:
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@ '@@@@@@@@@@@@@@@@@, @@@
@@@@@@@@@@@@@@@@@
'@@@@@@@@@@@@@@@'
@@@@ @@@@
@@@@ @@@@
@@@@ @@@@
'@@' '@@'
:@@@.
.@@@@@@@: +@@ `@@ @@` @@ @@
.@@@@'@@@@: +@@ `@@ @@` @@ @@
@@@ @@@ +@@ `@@ @@` @@ @@
.@@ @@: +@@ @@@ `@@ @@` @@@@@@ @@@@@@ @@;@@@@@
@@@ @@@ +@@ @@@ `@@ @@` @@@@@@ @@@@@@ @@@@@@@@@
@@@ @@@ +@@ @@@ `@@@@@@@@@@` @@ @@ @@@ :@@
@@@ @@@ +@@@@@ `@@@@@@@@@@` @@ @@ @@# @@+
@@@ @@@ +@@@@@+ `@@ @@` @@ @@ @@: @@#
@@: .@@` +@@@+@@ `@@ @@` @@ @@ @@# @@+
@@@. .@@@ +@@ @@@ `@@ @@` @@ @@ @@@ ,@@
@@@@@@@@@ +@@ @@@ `@@ @@` @@@@ @@@@ @@@@#@@@@
@@@@@@@ +@@ #@@ `@@ @@` @@@@: @@@@: @@'@@@@@
@@:
@@:
@@:
@@ -0,0 +1,13 @@
http://publicobject.com/helloworld.txt
GET
0
HTTP/1.1 301 Moved Permanently
8
Server: nginx/1.10.0 (Ubuntu)
Date: Thu, 09 Mar 2017 10:17:25 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://publicobject.com/helloworld.txt
OkHttp-Sent-Millis: 1489054646977
OkHttp-Received-Millis: 1489054647185
@@ -0,0 +1,7 @@
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.0 (Ubuntu)</center>
</body>
</html>
+12
View File
@@ -0,0 +1,12 @@
libcore.io.DiskLruCache
1
201105
2
DIRTY 4b217e04ba52215f3a6b64d28f6729c6
CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194
DIRTY 2d9345a30d2cc31bb3091d70a8ef6c18
CLEAN 2d9345a30d2cc31bb3091d70a8ef6c18 7618 1759
READ 4b217e04ba52215f3a6b64d28f6729c6
DIRTY 4b217e04ba52215f3a6b64d28f6729c6
CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194