1 /******************************************************************************* 2 * Copyright (c) 2008, 2018 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.pde.api.tools.builder.tests.tags; 15 16 import org.eclipse.core.runtime.IPath; 17 import org.eclipse.pde.api.tools.internal.JavadocTagManager; 18 import org.eclipse.pde.api.tools.internal.builder.BuilderMessages; 19 20 import junit.framework.Test; 21 22 /** 23 * Tests unsupported javadoc tags on class constructors 24 * 25 * @since 1.0 26 */ 27 public class InvalidClassConstructorTagTests extends InvalidMethodTagTests { 28 InvalidClassConstructorTagTests(String name)29 public InvalidClassConstructorTagTests(String name) { 30 super(name); 31 } 32 33 @Override getTestSourcePath()34 protected IPath getTestSourcePath() { 35 return super.getTestSourcePath().append("class"); //$NON-NLS-1$ 36 } 37 38 /** 39 * @return the test for this class 40 */ suite()41 public static Test suite() { 42 return buildTestSuite(InvalidClassConstructorTagTests.class); 43 } 44 testInvalidClassMethodTag1I()45 public void testInvalidClassMethodTag1I() { 46 x1(true); 47 } 48 testInvalidClassMethodTag1F()49 public void testInvalidClassMethodTag1F() { 50 x1(false); 51 } 52 53 /** 54 * Tests the unsupported @noreference Javadoc tag on private constructors in a variety of inner / outer classes 55 * is detected properly 56 */ x1(boolean inc)57 private void x1(boolean inc) { 58 setExpectedProblemIds(getDefaultProblemSet(8)); 59 setExpectedMessageArgs(new String[][] { 60 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 61 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 62 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 63 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 64 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 65 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 66 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 67 {"@noreference", BuilderMessages.TagValidator_private_constructor} //$NON-NLS-1$ 68 }); 69 deployTagTest("test15.java", inc, false); //$NON-NLS-1$ 70 } 71 testInvalidClassMethodTag2I()72 public void testInvalidClassMethodTag2I() { 73 x2(true); 74 } 75 testInvalidClassMethodTag2F()76 public void testInvalidClassMethodTag2F() { 77 x2(false); 78 } 79 80 /** 81 * Tests the unsupported @noreference Javadoc tag on private constructors in a class in the default package 82 * is detected properly 83 */ x2(boolean inc)84 private void x2(boolean inc) { 85 setExpectedProblemIds(getDefaultProblemSet(2)); 86 setExpectedMessageArgs(new String[][] { 87 {"@noreference", BuilderMessages.TagValidator_private_constructor}, //$NON-NLS-1$ 88 {"@noreference", BuilderMessages.TagValidator_private_constructor} //$NON-NLS-1$ 89 }); 90 deployTagTest("test16.java", inc, true); //$NON-NLS-1$ 91 } 92 testInvalidClassMethodTag3I()93 public void testInvalidClassMethodTag3I() { 94 x3(true); 95 } 96 testInvalidClassMethodTag3F()97 public void testInvalidClassMethodTag3F() { 98 x3(false); 99 } 100 101 /** 102 * Tests the unsupported @noinstantiate Javadoc tag on constructors in a variety of inner / outer classes 103 * is detected properly 104 */ x3(boolean inc)105 private void x3(boolean inc) { 106 setExpectedProblemIds(getDefaultProblemSet(8)); 107 setExpectedMessageArgs(new String[][] { 108 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 109 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 110 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 111 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 112 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 113 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 114 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 115 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 116 }); 117 deployTagTest("test17.java", inc, false); //$NON-NLS-1$ 118 } 119 testInvalidClassMethodTag4I()120 public void testInvalidClassMethodTag4I() { 121 x4(true); 122 } 123 testInvalidClassMethodTag4F()124 public void testInvalidClassMethodTag4F() { 125 x4(false); 126 } 127 128 /** 129 * Tests the unsupported @noinstantiate Javadoc tag on constructors in a class in the default package 130 * is detected properly 131 */ x4(boolean inc)132 private void x4(boolean inc) { 133 setExpectedProblemIds(getDefaultProblemSet(2)); 134 setExpectedMessageArgs(new String[][] { 135 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 136 {"@noinstantiate", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 137 }); 138 deployTagTest("test18.java", inc, true); //$NON-NLS-1$ 139 } 140 testInvalidClassMethodTag5I()141 public void testInvalidClassMethodTag5I() { 142 x5(true); 143 } 144 testInvalidClassMethodTag5F()145 public void testInvalidClassMethodTag5F() { 146 x5(false); 147 } 148 149 /** 150 * Tests the unsupported @noextend Javadoc tag on constructors in a variety of inner / outer classes 151 * is detected properly 152 */ x5(boolean inc)153 private void x5(boolean inc) { 154 setExpectedProblemIds(getDefaultProblemSet(8)); 155 setExpectedMessageArgs(new String[][] { 156 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 157 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 158 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 159 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 160 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 161 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 162 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 163 {"@noextend", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 164 }); 165 deployTagTest("test19.java", inc, false); //$NON-NLS-1$ 166 } 167 testInvalidClassMethodTag6I()168 public void testInvalidClassMethodTag6I() { 169 x6(true); 170 } 171 testInvalidClassMethodTag6F()172 public void testInvalidClassMethodTag6F() { 173 x6(false); 174 } 175 176 /** 177 * Tests the unsupported @noextend Javadoc tag on constructors in a class in the default package 178 * is detected properly 179 */ x6(boolean inc)180 private void x6(boolean inc) { 181 setExpectedProblemIds(getDefaultProblemSet(2)); 182 setExpectedMessageArgs(new String[][] { 183 {"@noextend", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 184 {"@noextend", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 185 }); 186 deployTagTest("test20.java", inc, true); //$NON-NLS-1$ 187 } 188 testInvalidClassMethodTag7I()189 public void testInvalidClassMethodTag7I() { 190 x7(true); 191 } 192 testInvalidClassMethodTag7F()193 public void testInvalidClassMethodTag7F() { 194 x7(false); 195 } 196 197 /** 198 * Tests the unsupported @nooverride Javadoc tag on constructors in a variety of inner / outer classes 199 * is detected properly 200 */ x7(boolean inc)201 private void x7(boolean inc) { 202 setExpectedProblemIds(getDefaultProblemSet(8)); 203 setExpectedMessageArgs(new String[][] { 204 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 205 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 206 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 207 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 208 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 209 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 210 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 211 {"@nooverride", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 212 }); 213 deployTagTest("test21.java", inc, false); //$NON-NLS-1$ 214 } 215 testInvalidClassMethodTag8I()216 public void testInvalidClassMethodTag8I() { 217 x8(true); 218 } 219 220 testInvalidClassMethodTag8F()221 public void testInvalidClassMethodTag8F() { 222 x8(false); 223 } 224 225 /** 226 * Tests the unsupported @nooverride Javadoc tag on constructors in a class in the default package 227 * is detected properly 228 */ x8(boolean inc)229 private void x8(boolean inc) { 230 setExpectedProblemIds(getDefaultProblemSet(2)); 231 setExpectedMessageArgs(new String[][] { 232 {"@nooverride", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 233 {"@nooverride", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 234 }); 235 deployTagTest("test22.java", inc, true); //$NON-NLS-1$ 236 } 237 testInvalidClassMethodTag9I()238 public void testInvalidClassMethodTag9I() { 239 x9(true); 240 } 241 testInvalidClassMethodTag9F()242 public void testInvalidClassMethodTag9F() { 243 x9(false); 244 } 245 246 /** 247 * Tests the unsupported @noimplement Javadoc tag on constructors in a variety of inner / outer classes 248 * is detected properly 249 */ x9(boolean inc)250 private void x9(boolean inc) { 251 setExpectedProblemIds(getDefaultProblemSet(8)); 252 setExpectedMessageArgs(new String[][] { 253 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 254 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 255 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 256 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 257 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 258 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 259 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 260 {"@noimplement", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 261 }); 262 deployTagTest("test23.java", inc, false); //$NON-NLS-1$ 263 } 264 testInvalidClassMethodTag10I()265 public void testInvalidClassMethodTag10I() { 266 x10(true); 267 } 268 testInvalidClassMethodTag10F()269 public void testInvalidClassMethodTag10F() { 270 x10(false); 271 } 272 273 /** 274 * Tests the unsupported @noimplement Javadoc tag on constructors in a class in the default package 275 * is detected properly 276 */ x10(boolean inc)277 private void x10(boolean inc) { 278 setExpectedProblemIds(getDefaultProblemSet(2)); 279 setExpectedMessageArgs(new String[][] { 280 {"@noimplement", BuilderMessages.TagValidator_a_constructor}, //$NON-NLS-1$ 281 {"@noimplement", BuilderMessages.TagValidator_a_constructor} //$NON-NLS-1$ 282 }); 283 deployTagTest("test24.java", inc, true); //$NON-NLS-1$ 284 } 285 testInvalidConstructorMethodTag1I()286 public void testInvalidConstructorMethodTag1I() { 287 x11(true); 288 } 289 testInvalidConstructorMethodTag1F()290 public void testInvalidConstructorMethodTag1F() { 291 x11(false); 292 } 293 294 /** 295 * Tests the unsupported @nooverride Javadoc tag on constructors in a class 296 * is detected properly 297 * 298 * @since 1.0.400 299 */ x11(boolean inc)300 private void x11(boolean inc) { 301 setExpectedProblemIds(getDefaultProblemSet(4)); 302 setExpectedMessageArgs(new String[][] { 303 {JavadocTagManager.TAG_NOOVERRIDE, BuilderMessages.TagValidator_a_constructor}, 304 {JavadocTagManager.TAG_NOOVERRIDE, BuilderMessages.TagValidator_a_constructor}, 305 {JavadocTagManager.TAG_NOREFERENCE, BuilderMessages.TagValidator_private_constructor}, 306 {JavadocTagManager.TAG_NOREFERENCE, BuilderMessages.TagValidator_a_package_default_constructor} 307 }); 308 deployTagTest("test25.java", inc, true); //$NON-NLS-1$ 309 } 310 }