javamethodconvertertest.java
来自「xstream是一个把java object序列化成xml文件的开源库,轻便好用」· Java 代码 · 共 65 行
JAVA
65 行
package com.thoughtworks.xstream.converters.extended;import java.lang.reflect.Method;import java.lang.reflect.Constructor;import com.thoughtworks.acceptance.AbstractAcceptanceTest;public class JavaMethodConverterTest extends AbstractAcceptanceTest { public void testMethod() throws Exception { Method method = AnIntClass.class.getDeclaredMethod("setValue", new Class[]{Integer.TYPE}); String expected = "<method>\n" + " <class>com.thoughtworks.xstream.converters.extended.JavaMethodConverterTest$AnIntClass</class>\n" + " <name>setValue</name>\n" + " <parameter-types>\n" + " <class>int</class>\n" + " </parameter-types>\n" + "</method>"; assertBothWays(method, expected); } public void testSupportsPrivateMethods() throws NoSuchMethodException { Method method = AnIntClass.class.getDeclaredMethod("privateMethod", new Class[]{}); String expected = "<method>\n" + " <class>com.thoughtworks.xstream.converters.extended.JavaMethodConverterTest$AnIntClass</class>\n" + " <name>privateMethod</name>\n" + " <parameter-types/>\n" + "</method>"; assertBothWays(method, expected); } public void testSupportsConstructor() throws NoSuchMethodException { Constructor constructor = AnIntClass.class.getDeclaredConstructor(new Class[] { int.class }); String expected = "<constructor>\n" + " <class>com.thoughtworks.xstream.converters.extended.JavaMethodConverterTest$AnIntClass</class>\n" + " <parameter-types>\n" + " <class>int</class>\n" + " </parameter-types>\n" + "</constructor>"; assertBothWays(constructor, expected); } static class AnIntClass { private int value = 0; protected AnIntClass(int integer) { this.value = integer; } public int getValue() { return value; } public void setValue(int integer) { this.value = integer; } private void privateMethod() { } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?