1 package org.incava.doctorj; 2 3 import junit.framework.TestCase; 4 import org.incava.analysis.Violation; 5 6 7 public class TestClassDocAnalyzer extends TestTypeDocAnalyzer 8 { 9 public TestClassDocAnalyzer(String name) 10 { 11 super(name); 12 } 13 14 public void testClassAuthorWithText() 15 { 16 evaluate("/** This is a description.\n" + 17 " * @author e. e. cummings\n" + 18 " */\n" + 19 "class Test {\n" + 20 "}\n", 21 new Violation[] { 22 }); 23 24 evaluate("/** This is a description.\n" + 25 " * @author I\n" + 26 " */\n" + 27 "class Test {\n" + 28 "}\n", 29 new Violation[] { 30 }); 31 32 evaluate("/** This is a description.\n" + 33 " * @author fred\n" + 34 " */\n" + 35 "class Test {\n" + 36 "}\n", 37 new Violation[] { 38 }); 39 } 40 41 public void testClassAuthorWithoutText() 42 { 43 evaluate("/** This is a description.\n" + 44 " * @author\n" + 45 " */\n" + 46 "class Test {\n" + 47 "}\n", 48 new Violation[] { 49 new Violation(TypeDocAnalyzer.MSG_AUTHOR_WITHOUT_NAME, 2, 5, 2, 11) 50 }); 51 } 52 53 public void testClassAuthorWithoutTextSpaces() 54 { 55 evaluate("/** This is a description.\n" + 56 " * @author \n" + 57 " */\n" + 58 "class Test {\n" + 59 "}\n", 60 new Violation[] { 61 new Violation(TypeDocAnalyzer.MSG_AUTHOR_WITHOUT_NAME, 2, 5, 2, 11) 62 }); 63 64 evaluate("/** This is a description.\n" + 65 " * @author \n" + 66 " */\n" + 67 "class Test {\n" + 68 "}\n", 69 new Violation[] { 70 new Violation(TypeDocAnalyzer.MSG_AUTHOR_WITHOUT_NAME, 2, 5, 2, 11) 71 }); 72 } 73 74 public void testClassVersionWithText() 75 { 76 evaluate("/** This is a description.\n" + 77 " * @version 1.1.2\n" + 78 " */\n" + 79 "class Test {\n" + 80 "}\n", 81 new Violation[] { 82 }); 83 84 evaluate("/** This is a description.\n" + 85 " * @version 1\n" + 86 " */\n" + 87 "class Test {\n" + 88 "}\n", 89 new Violation[] { 90 }); 91 } 92 93 public void testClassVersionWithoutText() 94 { 95 evaluate("/** This is a description.\n" + 96 " * @version\n" + 97 " */\n" + 98 "class Test {\n" + 99 "}\n", 100 new Violation[] { 101 new Violation(TypeDocAnalyzer.MSG_VERSION_WITHOUT_TEXT, 2, 5, 2, 12) 102 }); 103 } 104 105 public void testClassVersionWithoutTextSpaces() 106 { 107 evaluate("/** This is a description.\n" + 108 " * @version \n" + 109 " */\n" + 110 "class Test {\n" + 111 "}\n", 112 new Violation[] { 113 new Violation(TypeDocAnalyzer.MSG_VERSION_WITHOUT_TEXT, 2, 5, 2, 12) 114 }); 115 116 evaluate("/** This is a description.\n" + 117 " * @version \n" + 118 " */\n" + 119 "class Test {\n" + 120 "}\n", 121 new Violation[] { 122 new Violation(TypeDocAnalyzer.MSG_VERSION_WITHOUT_TEXT, 2, 5, 2, 12) 123 }); 124 } 125 126 public void testClassSerialWithText() 127 { 128 evaluate("/** This is a description.\n" + 129 " * @serial This describes the serial field.\n" + 130 " */\n" + 131 "class Test {\n" + 132 "}\n", 133 new Violation[] { 134 }); 135 136 evaluate("/** This is a description.\n" + 137 " * @serial description\n" + 138 " */\n" + 139 "class Test {\n" + 140 "}\n", 141 new Violation[] { 142 }); 143 } 144 145 public void testClassSerialWithoutText() 146 { 147 evaluate("/** This is a description.\n" + 148 " * @serial\n" + 149 " */\n" + 150 "class Test {\n" + 151 "}\n", 152 new Violation[] { 153 new Violation(TypeDocAnalyzer.MSG_SERIAL_WITHOUT_TEXT, 2, 5, 2, 11) 154 }); 155 } 156 157 public void testClassSerialWithoutTextSpaces() 158 { 159 evaluate("/** This is a description.\n" + 160 " * @serial \n" + 161 " */\n" + 162 "class Test {\n" + 163 "}\n", 164 new Violation[] { 165 new Violation(TypeDocAnalyzer.MSG_SERIAL_WITHOUT_TEXT, 2, 5, 2, 11) 166 }); 167 168 evaluate("/** This is a description.\n" + 169 " * @serial \n" + 170 " */\n" + 171 "class Test {\n" + 172 "}\n", 173 new Violation[] { 174 new Violation(TypeDocAnalyzer.MSG_SERIAL_WITHOUT_TEXT, 2, 5, 2, 11) 175 }); 176 } 177 178 } 179
| Popular Tags
|