Skip to content

Commit

Permalink
refactor ProtobufIDLProxyTest
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemalin committed Feb 26, 2016
1 parent cb6cc35 commit 6805a38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jprotobuf-1.x JDK 6 或以上版本
<dependency>
<groupId>com.baidu</groupId>
<artifactId>jprotobuf</artifactId>
<version>1.9.5</version>
<version>1.9.6</version>
</dependency>
```
[下载发行包](http://repo1.maven.org/maven2/com/baidu/jprotobuf/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

import org.junit.Ignore;
Expand Down Expand Up @@ -151,8 +152,23 @@ public void testInnerIncludingServiceIDLGenerateSource() {
idl.append(" optional DataInfo.SubDataInfo.Sub2DataInfo sub2DataInfo = 3;\n");
idl.append("}");

System.out.println(idl.toString());
ProtobufIDLProxy.generateSource(idl.toString(), new File("D:/"));
Map<String, IDLProxyObject> map = ProtobufIDLProxy.create(idl.toString());

IDLProxyObject idlProxyObject = map.get("DataStatus");

idlProxyObject.put("subDataInfo.name", "abc");

try {
byte[] bytes = idlProxyObject.encode();

System.out.println(Arrays.toString(bytes));

IDLProxyObject idlProxyObject2 = idlProxyObject.decode(bytes);
Assert.assertEquals(idlProxyObject2.get("subDataInfo.name"), "abc");

} catch (IOException e) {
e.printStackTrace();
}
}

}

0 comments on commit 6805a38

Please sign in to comment.