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

📄 reflectionclassestest.java

📁 xstream是一个把java object序列化成xml文件的开源库,轻便好用
💻 JAVA
字号:
package com.thoughtworks.acceptance;import java.lang.reflect.Constructor;import java.lang.reflect.Method;public class ReflectionClassesTest extends AbstractAcceptanceTest {    public static class StupidObject {        public StupidObject(String arg) {        }        public void aMethod(String something) {        }        public void aMethod(int cheese) {        }    }    public void testReflectionMethod() throws NoSuchMethodException {        Method method = StupidObject.class.getMethod("aMethod", new Class[]{String.class});        String expected =                "<method>\n" +                "  <class>com.thoughtworks.acceptance.ReflectionClassesTest$StupidObject</class>\n" +                "  <name>aMethod</name>\n" +                "  <parameter-types>\n" +                "    <class>java.lang.String</class>\n" +                "  </parameter-types>\n" +                "</method>";        assertBothWays(method, expected);    }    public void testReflectionConstructor() throws NoSuchMethodException {        Constructor constructor = StupidObject.class.getConstructor(new Class[]{String.class});        String expected =                "<constructor>\n" +                "  <class>com.thoughtworks.acceptance.ReflectionClassesTest$StupidObject</class>\n" +                "  <parameter-types>\n" +                "    <class>java.lang.String</class>\n" +                "  </parameter-types>\n" +                "</constructor>";        assertBothWays(constructor, expected);    }    public void testSupportsPrimitiveTypes() {        assertBothWays(int.class, "<java-class>int</java-class>");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -