Package org.junithelper.core.meta

Examples of org.junithelper.core.meta.ClassMeta


     * @see {@link http://code.google.com/p/junithelper/issues/detail?id=66}
     */
    @Test
    public void getNewTestCaseSourceCode_A$_packageIsEmpty() throws Exception {
        String sourceCodeString = "public class Sample {}";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        config.testCaseClassNameToExtend = "";
        String actual = target.getNewTestCaseSourceCode();
        String expected = "import Sample.*;\r\nimport static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\npublic class SampleTest {\r\n\r\n  @Test\r\n  public void type() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    assertThat(Sample.class, notNullValue());\r\n  }\r\n\r\n  @Test\r\n  public void instantiation() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    assertThat(target, notNullValue());\r\n  }\r\n\r\n}\r\n";
        assertThat(actual, is(equalTo(expected)));
View Full Code Here


        // ext config
        InputStream is = this.getClass().getClassLoader().getResourceAsStream("junithelper-extension.xml");
        config.extConfiguration = new ExtConfigurationLoader().load(is);

        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } public void overload(String str) { } public void overload(String str, Object obj) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_overload_A$String$Object() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(4, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

        config.extConfiguration = new ExtConfigurationLoader().load(is);

        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { "
                + "public int doSomething(Something something, String str, String str2, long longValue) throws Throwable { System.out.println(\"aaaa\") } "
                + "public void overload(String str) { } " + "public void overload(String str, Object obj) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_overload_A$String$Object() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(4, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

        InputStream is = this.getClass().getClassLoader().getResourceAsStream("junithelper-extension.xml");
        config.isExtensionEnabled = true;
        config.extConfiguration = new ExtConfigurationLoader().load(is);

        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } public void overload(String str) { } public void overload(String str, Object obj) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_overload_A$String$Object() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(10, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

        config.extConfiguration = new ExtConfigurationLoader().load(is);

        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { "
                + "public int doSomething(Something something, String str, String str2, long longValue) throws Throwable { System.out.println(\"aaaa\") } "
                + "public void overload(String str) { } " + "public void overload(String str, Object obj) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_overload_A$String$Object() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(10, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

    public void getLackingTestMethodMetaList_A$String_Slim3_AbstractModelRef() throws Exception {
        String encoding = UniversalDetectorUtil.getDetectedEncoding(IOUtil
                .getResourceAsStream("inputs/Slim3_AbstractModelRef.txt"));
        String sourceCodeString = IOUtil.readAsString(IOUtil.getResourceAsStream("inputs/Slim3_AbstractModelRef.txt"),
                encoding);
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals("", 6, actual.size());
    }
View Full Code Here

    @Test
    public void getLackingTestMethodMetaList_A$String_IOUtil() throws Exception {
        String encoding = UniversalDetectorUtil.getDetectedEncoding(IOUtil.getResourceAsStream("inputs/IOUtil.txt"));
        String sourceCodeString = IOUtil.readAsString(IOUtil.getResourceAsStream("inputs/IOUtil.txt"), encoding);
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertThat(actual.size(), is(equalTo(10)));
        assertThat(actual.get(2).methodMeta.argTypes.get(0).name, is(equalTo("InputStream")));
View Full Code Here

    }

    @Test
    public void getLackingTestMethodMetaList_A$String() throws Exception {
        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } public void overload(String str) { } public void overload(String str, Object obj) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_overload_A$String$Object() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(4, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

    }

    @Test
    public void getLackingTestMethodMetaList_A$String_Overload() throws Exception {
        String sourceCodeString = "public class Sample { public void doSomething(String str) throws Throwable {} public void doSomething() throws Throwable {} }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo; public class SampleTest extends TestCase { public void test_doSomething_A$String() throws Exception { } }";
        List<TestMethodMeta> actual = target.getLackingTestMethodMetaList(currentTestCaseSourceCode);
        assertEquals(3, actual.size());
        assertEquals(true, actual.get(0).isTypeTest);
View Full Code Here

    public void getNewTestCaseSourceCode_A$_JUnit3() throws Exception {
        Configuration config = new Configuration();
        config.junitVersion = JUnitVersion.version3;
        TestCaseGeneratorImpl target = new TestCaseGeneratorImpl(config, lineBreakProvider);
        String sourceCodeString = "package hoge.foo; import java.util.List;\r\nimport java.util.Map; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\"); } public void doSomething(List<Map<String, String>> nested, Map<String,Map<String,String>> nested2) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String actual = target.getNewTestCaseSourceCode();
        String expected = "package hoge.foo;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.HashMap;\r\nimport hoge.foo.Sample.*;\r\n\r\nimport java.util.List;\r\nimport java.util.Map;\r\nimport junit.framework.TestCase;\r\n\r\npublic class SampleTest extends TestCase {\r\n\r\n  public void test_type() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    assertNotNull(Sample.class);\r\n  }\r\n\r\n  public void test_instantiation() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    assertNotNull(target);\r\n  }\r\n\r\n  public void test_doSomething_A$String$long() throws Throwable {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    String str = null;\r\n    long longValue = 0L;\r\n    int actual = target.doSomething(str, longValue);\r\n    int expected = 0;\r\n    assertEquals(expected, actual);\r\n  }\r\n\r\n  public void test_doSomething_A$List$Map() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    List nested = new ArrayList();\r\n    Map nested2 = new HashMap();\r\n    target.doSomething(nested, nested2);\r\n  }\r\n\r\n}\r\n";
        assertEquals(expected, actual);
    }
View Full Code Here

TOP

Related Classes of org.junithelper.core.meta.ClassMeta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.