@Test public void testMessageDependencyMissException() { String idl = "package tutorial;" + "option java_package = \"com.example.tutorial\";" + "option java_outer_classname = \"AddressBookProtos\";" + "enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2;}" + " message PhoneNumber {" + "optional PhoneType type = 1 [default = HOME];" + "optional int32 name = 2 [default = 10];" + "optional String vName = 3 [default = \"hello world\"];" + "}"; try { ProtobufIDLProxy.createSingle(idl); Assert.fail(); } catch (Exception e) { Assert.assertNotNull(e); } }
@Test public void testDefaultValue() { String idl = "package tutorial;" + "option java_package = \"com.example.tutorial\";" + "option java_outer_classname = \"AddressBookProtos\";" + "enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2;}" + " message PhoneNumber {" + "optional PhoneType type = 1 [default = HOME];" + "optional int32 name = 2 [default = 10];" + "optional string vName = 3 [default = \"hello world\"];" + "}"; IDLProxyObject idlProxyObject = ProtobufIDLProxy.createSingle(idl); Object type = idlProxyObject.get("type"); Assert.assertEquals(type + "", "HOME"); Assert.assertEquals(10, idlProxyObject.get("name")); Assert.assertEquals("hello world", idlProxyObject.get("vName")); }