⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javamethodconvertertest.java

📁 xstream是一个把java object序列化成xml文件的开源库,轻便好用
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -