add spring-trpc junit - #36
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
|
|
There was a problem hiding this comment.
i fix it
| } | ||
|
|
||
| @Test | ||
| public void testEmptyIfNull() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
There was a problem hiding this comment.
这个函数可以通过AddFilterTRpcConfigManagerCustomizer构造函数测,尽量减少使用setAccessible。
There was a problem hiding this comment.
i fix it
| } | ||
|
|
||
| @Test | ||
| public void testMerge() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
There was a problem hiding this comment.
这个函数可以通过customize函数测,尽量减少使用setAccessible。
There was a problem hiding this comment.
i fix it
| Assert.assertEquals((long) value, addFilterTRpcConfigManagerCustomizer.getOrder()); | ||
| } | ||
|
|
||
| static final class AddFilterTRpcConfigManagerCustomizer2 extends AddFilterTRpcConfigManagerCustomizer { |
There was a problem hiding this comment.
建议不用出现1 2 3这种数字的命名,可以命名为TestFilterConfigManagerCustomizer
There was a problem hiding this comment.
i fix it
| public void testGetOrder() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer2(); | ||
| Assert.assertEquals(Integer.MAX_VALUE, addFilterTRpcConfigManagerCustomizer.getOrder()); | ||
| Integer value = 1024; |
There was a problem hiding this comment.
把这个定义为常量,getOrder里面直接返回常量就行。
There was a problem hiding this comment.
i fix it
|
|
||
| @Test | ||
| public void testGetOrder() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer2(); |
There was a problem hiding this comment.
new AddFilterTRpcConfigManagerCustomizer();然后断言
There was a problem hiding this comment.
i fix it
|
|
||
| @Override | ||
| public int getOrder() { | ||
| return System.getProperty(KEY) == null ? super.getOrder() : Integer.parseInt(System.getProperty(KEY)); |
There was a problem hiding this comment.
i fix it
| public void testAddClientFilters() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer(); | ||
| AddFilterTRpcConfigManagerCustomizer customizer = addFilterTRpcConfigManagerCustomizer.addClientFilters( | ||
| "filter1", "filter2"); |
There was a problem hiding this comment.
i fix it
|
|
||
| @Test | ||
| public void testConstructorWithNullEmpty() { | ||
| addFilterTRpcConfigManagerCustomizer.addClientFilters(FILTER_ONE, FILTER_TWO); |
| } | ||
|
|
||
| @Test | ||
| public void testConstructorWithNullEmpty() { |
There was a problem hiding this comment.
这个函数是测emptyIfNull,可以在new AddFilterTRpcConfigManagerCustomizer(null, null);后,向clientFilters和serverFilters添加插件,然后断言
linked: #34