Skip to content

Commit

Permalink
ignore some error while on pre-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemalin committed Dec 31, 2019
1 parent 6036f8e commit 657e3e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ protected void onEntry(EntryData entryData) throws Exception {
}

try {
List<Field> fields = FieldUtils.findMatchedFields(c, Protobuf.class);
List<Field> fields = null;
try {
fields = FieldUtils.findMatchedFields(c, Protobuf.class);
} catch (Exception e) {
return;
}
if (!fields.isEmpty()) {
compiledClasses.add(c);
ProtobufProxy.create(c, false, outputPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
*/
package com.baidu.bjf.remoting.protobuf.idlproxy;

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

import junit.framework.Assert;

import org.junit.Test;

import com.baidu.bjf.remoting.protobuf.IDLProxyObject;
Expand All @@ -29,21 +28,33 @@
import com.baidu.bjf.remoting.protobuf.simpletypes.AllTypes.InterClassName;
import com.baidu.bjf.remoting.protobuf.simpletypes.AllTypesPojoClass;

import junit.framework.Assert;

/**
* Test class for {@link ProtobufIDLProxy}
*
* @author xiemalin
* @since 1.0.2
*/
public class ProtobufIDLProxyTest {

@Test
public void testCodeGenerateFromIDL() {
String protoCotent = "package mypackage.test; "
+ "option java_package = \"com.baidu.bjf.remoting.protobuf.simplestring\";"
+ "option java_outer_classname = \"StringTypeClassToIDLGenerator\"; " + "message StringMessage { "
+ " required string message = 1 [default = \"hello\"]; }";
ProtobufIDLProxy.generateSource(protoCotent, new File("."));

}

@Test
public void testDecode() throws Exception {

String protoCotent = "package mypackage.test; "
+ "option java_package = \"com.baidu.bjf.remoting.protobuf.simplestring\";"
+ "option java_outer_classname = \"StringTypeClass\"; " + "message StringMessage { "
+ " required string message = 1; }";
+ " required string message = 1 [default = \"hello\"]; }";
IDLProxyObject object = ProtobufIDLProxy.createSingle(protoCotent);

// 动态设置字段值
Expand Down

0 comments on commit 657e3e4

Please sign in to comment.