Treating the Unit Tests as *real* code.
This commit is contained in:
parent
dc5b2532be
commit
ceb894bc7a
|
|
@ -19,7 +19,7 @@
|
|||
failureProperty="checkstyle.failure.property"
|
||||
>
|
||||
<fileset dir="src"
|
||||
includes="checkstyle/**/*.java,checkstyle/**/*.properties,xdocs/**/*.xml"
|
||||
includes="checkstyle/**/*.java,checkstyle/**/*.properties,xdocs/**/*.xml,tests/**/*Test.java"
|
||||
excludes="**/Generated*.java,**/gui/*"/>
|
||||
<formatter type="plain"/>
|
||||
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_errors.xml"/>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
failureProperty="checkstyle.failure.property"
|
||||
>
|
||||
<fileset dir="src"
|
||||
includes="checkstyle/**/*.java,checkstyle/**/*.properties,xdocs/**/*.xml"
|
||||
includes="checkstyle/**/*.java,checkstyle/**/*.properties,xdocs/**/*.xml,tests/**/*Test.java"
|
||||
excludes="**/Generated*.java,**/gui/*"/>
|
||||
<formatter type="plain"/>
|
||||
<formatter type="xml" toFile="${target.dir}/cs_errors.xml"/>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -34,7 +52,7 @@ public class CheckerTest
|
|||
// let's take testinputs.dir
|
||||
String testinputs_dir = System.getProperty("testinputs.dir")
|
||||
.replace('/', File.separatorChar)
|
||||
.replace('\\',File.separatorChar);
|
||||
.replace('\\', File.separatorChar);
|
||||
|
||||
if (!testinputs_dir.endsWith(File.separator)) {
|
||||
testinputs_dir += File.separator;
|
||||
|
|
@ -48,7 +66,7 @@ public class CheckerTest
|
|||
@Test
|
||||
public void testDestroy() throws Exception
|
||||
{
|
||||
final DebugChecker c= new DebugChecker();
|
||||
final DebugChecker c = new DebugChecker();
|
||||
final DebugAuditAdapter aa = new DebugAuditAdapter();
|
||||
c.addListener(aa);
|
||||
final DebugFilter f = new DebugFilter();
|
||||
|
|
@ -74,7 +92,7 @@ public class CheckerTest
|
|||
@Test
|
||||
public void testAddListener() throws Exception
|
||||
{
|
||||
final DebugChecker c= new DebugChecker();
|
||||
final DebugChecker c = new DebugChecker();
|
||||
final DebugAuditAdapter aa = new DebugAuditAdapter();
|
||||
c.addListener(aa);
|
||||
|
||||
|
|
@ -105,7 +123,7 @@ public class CheckerTest
|
|||
@Test
|
||||
public void testRemoveListener() throws Exception
|
||||
{
|
||||
final DebugChecker c= new DebugChecker();
|
||||
final DebugChecker c = new DebugChecker();
|
||||
final DebugAuditAdapter aa = new DebugAuditAdapter();
|
||||
final DebugAuditAdapter aa2 = new DebugAuditAdapter();
|
||||
c.addListener(aa);
|
||||
|
|
@ -145,27 +163,27 @@ public class CheckerTest
|
|||
@Test
|
||||
public void testAddFilter() throws Exception
|
||||
{
|
||||
final DebugChecker c= new DebugChecker();
|
||||
final DebugChecker c = new DebugChecker();
|
||||
final DebugFilter f = new DebugFilter();
|
||||
|
||||
c.addFilter(f);
|
||||
|
||||
// Let's try fire some events
|
||||
// we do not call filter in fireAuditStarted() (fix for 1080343)
|
||||
// we do not call filter in fireAuditStarted() (fix for 1080343)
|
||||
// c.fireAuditStarted();
|
||||
// assertTrue("Checker.fireAuditStarted() doesn't call filter", f.wasCalled());
|
||||
|
||||
// we do not call filter in fireAuditFinished() (fix for 1080343)
|
||||
// we do not call filter in fireAuditFinished() (fix for 1080343)
|
||||
// f.resetFilter();
|
||||
// c.fireAuditFinished();
|
||||
// assertTrue("Checker.fireAuditFinished() doesn't call filter", f.wasCalled());
|
||||
|
||||
// we do not call filter in fireFileStarted() (fix for 1080343)
|
||||
// we do not call filter in fireFileStarted() (fix for 1080343)
|
||||
// f.resetFilter();
|
||||
// c.fireFileStarted("Some File Name");
|
||||
// assertTrue("Checker.fireFileStarted() doesn't call filter", f.wasCalled());
|
||||
|
||||
// we do not call filter in fireFileFinished() (fix for 1080343)
|
||||
// we do not call filter in fireFileFinished() (fix for 1080343)
|
||||
// f.resetFilter();
|
||||
// c.fireFileFinished("Some File Name");
|
||||
// assertTrue("Checker.fireFileFinished() doesn't call filter", f.wasCalled());
|
||||
|
|
@ -181,7 +199,7 @@ public class CheckerTest
|
|||
@Test
|
||||
public void testRemoveFilter() throws Exception
|
||||
{
|
||||
final DebugChecker c= new DebugChecker();
|
||||
final DebugChecker c = new DebugChecker();
|
||||
final DebugFilter f = new DebugFilter();
|
||||
final DebugFilter f2 = new DebugFilter();
|
||||
c.addFilter(f);
|
||||
|
|
@ -189,24 +207,24 @@ public class CheckerTest
|
|||
c.removeFilter(f);
|
||||
|
||||
// Let's try fire some events
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// c.fireAuditStarted();
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// c.fireAuditStarted();
|
||||
// assertTrue("Checker.fireAuditStarted() doesn't call filter", f2.wasCalled());
|
||||
// assertFalse("Checker.fireAuditStarted() does call removed filter", f.wasCalled());
|
||||
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// f2.resetFilter();
|
||||
// c.fireAuditFinished();
|
||||
// assertTrue("Checker.fireAuditFinished() doesn't call filter", f2.wasCalled());
|
||||
// assertFalse("Checker.fireAuditFinished() does call removed filter", f.wasCalled());
|
||||
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// f2.resetFilter();
|
||||
// c.fireFileStarted("Some File Name");
|
||||
// assertTrue("Checker.fireFileStarted() doesn't call filter", f2.wasCalled());
|
||||
// assertFalse("Checker.fireFileStarted() does call removed filter", f.wasCalled());
|
||||
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// we do call filter in fireErrors() only (fix for 1080343)
|
||||
// f2.resetFilter();
|
||||
// c.fireFileFinished("Some File Name");
|
||||
// assertTrue("Checker.fireFileFinished() doesn't call filter", f2.wasCalled());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -199,7 +217,7 @@ public class ConfigurationLoaderTest
|
|||
throws CheckstyleException
|
||||
{
|
||||
final String[] testValues = {null, "", "a", "$a", "{a",
|
||||
"{a}", "a}", "$a}", "$", "a$b"};
|
||||
"{a}", "a}", "$a}", "$", "a$b", };
|
||||
final Properties props = initProperties();
|
||||
for (int i = 0; i < testValues.length; i++) {
|
||||
final String value = ConfigurationLoader.replaceProperties(
|
||||
|
|
@ -253,7 +271,7 @@ public class ConfigurationLoaderTest
|
|||
{"x${a}${b}y", "xABy"},
|
||||
{"x${a}y${b}z", "xAyBz"},
|
||||
{"$$", "$"},
|
||||
};
|
||||
};
|
||||
final Properties props = initProperties();
|
||||
for (int i = 0; i < testValues.length; i++) {
|
||||
final String value = ConfigurationLoader.replaceProperties(
|
||||
|
|
@ -309,8 +327,8 @@ public class ConfigurationLoaderTest
|
|||
final Properties props = new Properties();
|
||||
props.put("checkstyle.basedir", "basedir");
|
||||
|
||||
final File file = new File(System.getProperty("testinputs.dir") +
|
||||
"/configs/subdir/including.xml");
|
||||
final File file = new File(System.getProperty("testinputs.dir")
|
||||
+ "/configs/subdir/including.xml");
|
||||
final DefaultConfiguration config =
|
||||
(DefaultConfiguration) ConfigurationLoader.loadConfiguration(
|
||||
file.toURI().toString(), new PropertiesExpander(props));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -19,7 +37,7 @@ public class PackageNamesLoaderTest
|
|||
public void testDefault()
|
||||
throws CheckstyleException
|
||||
{
|
||||
Set<String> packageNames = PackageNamesLoader
|
||||
final Set<String> packageNames = PackageNamesLoader
|
||||
.getPackageNames(Thread.currentThread()
|
||||
.getContextClassLoader());
|
||||
validatePackageNames(packageNames);
|
||||
|
|
@ -51,7 +69,7 @@ public class PackageNamesLoaderTest
|
|||
|
||||
assertEquals("pkgNames.length.", checkstylePackages.length,
|
||||
aPkgNames.size());
|
||||
Set<String> checkstylePackagesSet =
|
||||
final Set<String> checkstylePackagesSet =
|
||||
Sets.newHashSet(Arrays.asList(checkstylePackages));
|
||||
assertEquals("names set.", checkstylePackagesSet, aPkgNames);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -16,16 +34,16 @@ public class UtilsTest
|
|||
public void testLengthExpandedTabs()
|
||||
throws Exception
|
||||
{
|
||||
String s1 = "\t";
|
||||
final String s1 = "\t";
|
||||
assertEquals(8, Utils.lengthExpandedTabs(s1, s1.length(), 8));
|
||||
|
||||
String s2 = " \t";
|
||||
final String s2 = " \t";
|
||||
assertEquals(8, Utils.lengthExpandedTabs(s2, s2.length(), 8));
|
||||
|
||||
String s3 = "\t\t";
|
||||
final String s3 = "\t\t";
|
||||
assertEquals(16, Utils.lengthExpandedTabs(s3, s3.length(), 8));
|
||||
|
||||
String s4 = " \t ";
|
||||
final String s4 = " \t ";
|
||||
assertEquals(9, Utils.lengthExpandedTabs(s4, s4.length(), 8));
|
||||
|
||||
assertEquals(0, Utils.lengthMinusTrailingWhitespace(""));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -78,7 +96,7 @@ public class XMLLoggerTest
|
|||
outStream.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testCloseStream()
|
||||
throws IOException
|
||||
{
|
||||
|
|
@ -128,7 +146,8 @@ public class XMLLoggerTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAddError() throws IOException {
|
||||
public void testAddError() throws IOException
|
||||
{
|
||||
final XMLLogger logger = new XMLLogger(outStream, true);
|
||||
logger.auditStarted(null);
|
||||
final LocalizedMessage message =
|
||||
|
|
@ -138,8 +157,9 @@ public class XMLLoggerTest
|
|||
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
|
||||
logger.addError(ev);
|
||||
logger.auditFinished(null);
|
||||
final String[] expectedLines =
|
||||
{"<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\" source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>"};
|
||||
final String[] expectedLines = {
|
||||
"<error line=\"1\" column=\"1\" severity=\"error\" message=\"key\" source=\"com.puppycrawl.tools.checkstyle.XMLLoggerTest\"/>",
|
||||
};
|
||||
verifyLines(expectedLines);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -76,7 +94,7 @@ public class AbstractViolationReporterTest extends BaseCheckTestSupport
|
|||
messages.first().getMessage());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCustomMessageWithParametersNegative() throws CheckstyleException
|
||||
{
|
||||
DefaultConfiguration config = createCheckConfig(emptyCheck.getClass());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
|
@ -15,7 +33,7 @@ public class AutomaticBeanTest
|
|||
private final DefaultConfiguration mConf = new DefaultConfiguration(
|
||||
"testConf");
|
||||
|
||||
TestBean mTestBean = new TestBean();
|
||||
private final TestBean mTestBean = new TestBean();
|
||||
|
||||
@Test(expected = CheckstyleException.class)
|
||||
public void testNoSuchAttribute() throws CheckstyleException
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -15,7 +33,8 @@ import org.junit.Test;
|
|||
public class DetailASTTest
|
||||
{
|
||||
@Test
|
||||
public void testGetChildCount() {
|
||||
public void testGetChildCount()
|
||||
{
|
||||
final DetailAST root = new DetailAST();
|
||||
final DetailAST firstLevelA = new DetailAST();
|
||||
final DetailAST firstLevelB = new DetailAST();
|
||||
|
|
@ -52,7 +71,8 @@ public class DetailASTTest
|
|||
private void checkDir(File dir) throws Exception
|
||||
{
|
||||
File[] files = dir.listFiles(new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return (file.getName().endsWith(".java")
|
||||
|| file.isDirectory())
|
||||
&& !file.getName().endsWith("InputGrammar.java");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -29,8 +47,7 @@ public class FastStackTest
|
|||
assertTrue(fs.isEmpty());
|
||||
assertEquals(0, fs.size());
|
||||
final int num = 100;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
for (int i = 0; i < num; i++) {
|
||||
fs.push(i);
|
||||
}
|
||||
assertEquals(num, fs.size());
|
||||
|
|
@ -38,8 +55,7 @@ public class FastStackTest
|
|||
assertEquals(1, fs.peek(1).intValue());
|
||||
assertEquals(num - 1, fs.peek().intValue());
|
||||
assertEquals(num, fs.size());
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
for (int i = 0; i < num; i++) {
|
||||
fs.pop();
|
||||
}
|
||||
assertTrue(fs.isEmpty());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.api;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -104,22 +122,22 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("maximumMessage", "Empty statement.");
|
||||
|
||||
final String[] expected = {
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
"43:10: Empty statement.",
|
||||
"49:13: Empty statement.",
|
||||
"51:13: Empty statement.",
|
||||
"54:19: Empty statement.",
|
||||
"58:10: Empty statement.",
|
||||
"61:9: Empty statement.",
|
||||
"66:10: Empty statement.",
|
||||
"72:10: Empty statement.",
|
||||
"76:10: Empty statement.",
|
||||
"80:10: Empty statement.",
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
"43:10: Empty statement.",
|
||||
"49:13: Empty statement.",
|
||||
"51:13: Empty statement.",
|
||||
"54:19: Empty statement.",
|
||||
"58:10: Empty statement.",
|
||||
"61:9: Empty statement.",
|
||||
"66:10: Empty statement.",
|
||||
"72:10: Empty statement.",
|
||||
"76:10: Empty statement.",
|
||||
"80:10: Empty statement.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("InputEmptyStatement.java"), expected);
|
||||
|
|
@ -183,20 +201,20 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport
|
|||
|
||||
@Test
|
||||
public void testIllegalTokenNative() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(DescendantTokenCheck.class);
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(DescendantTokenCheck.class);
|
||||
checkConfig.addAttribute("tokens", "LITERAL_NATIVE");
|
||||
checkConfig.addAttribute("limitedTokens", "LITERAL_NATIVE");
|
||||
checkConfig.addAttribute("maximumNumber", "0");
|
||||
checkConfig.addAttribute("maximumDepth", "0");
|
||||
checkConfig.addAttribute("maximumMessage", "Using ''{2}'' is not allowed.");
|
||||
|
||||
final String[] expected = {
|
||||
"20:12: Using 'LITERAL_NATIVE' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
final String[] expected = {
|
||||
"20:12: Using 'LITERAL_NATIVE' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnFromCatch() throws Exception
|
||||
|
|
@ -210,7 +228,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport
|
|||
|
||||
String[] expected = {
|
||||
"7:11: Return from catch is not allowed.",
|
||||
"15:11: Return from catch is not allowed."
|
||||
"15:11: Return from catch is not allowed.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
|
|
@ -230,7 +248,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestSupport
|
|||
|
||||
String[] expected = {
|
||||
"7:11: Return from finally is not allowed.",
|
||||
"15:11: Return from finally is not allowed."
|
||||
"15:11: Return from finally is not allowed.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -23,7 +41,7 @@ public class FileSetCheckLifecycleTest
|
|||
|
||||
public static class TestFileSetCheck extends AbstractFileSetCheck
|
||||
{
|
||||
private static boolean destroyed = false;
|
||||
private static boolean destroyed;
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
|
|
@ -43,8 +61,7 @@ public class FileSetCheckLifecycleTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTranslation()
|
||||
throws Exception
|
||||
public void testTranslation() throws Exception
|
||||
{
|
||||
final Configuration checkConfig =
|
||||
createCheckConfig(TestFileSetCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -7,8 +25,7 @@ import org.junit.Test;
|
|||
public class FinalParametersCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testDefaultTokens()
|
||||
throws Exception
|
||||
public void testDefaultTokens() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
|
|
@ -29,8 +46,7 @@ public class FinalParametersCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCtorToken()
|
||||
throws Exception
|
||||
public void testCtorToken() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
|
|
@ -44,8 +60,7 @@ public class FinalParametersCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMethodToken()
|
||||
throws Exception
|
||||
public void testMethodToken() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
|
|
@ -64,8 +79,7 @@ public class FinalParametersCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCatchToken()
|
||||
throws Exception
|
||||
public void testCatchToken() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
|
|
@ -79,8 +93,7 @@ public class FinalParametersCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testForEachClauseToken()
|
||||
throws Exception
|
||||
public void testForEachClauseToken() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -19,13 +37,12 @@ public class NewlineAtEndOfFileCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNewlineAtEndOfFile()
|
||||
throws Exception
|
||||
public void testNewlineAtEndOfFile() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NewlineAtEndOfFileCheck.class);
|
||||
checkConfig.addAttribute("lineSeparator", LineSeparatorOption.LF.toString());
|
||||
final String[] expected = { };
|
||||
final String[] expected = {};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
getPath("InputNewlineAtEndOfFile.java"),
|
||||
|
|
@ -33,14 +50,13 @@ public class NewlineAtEndOfFileCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNoNewlineAtEndOfFile()
|
||||
throws Exception
|
||||
public void testNoNewlineAtEndOfFile() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NewlineAtEndOfFileCheck.class);
|
||||
checkConfig.addAttribute("lineSeparator", LineSeparatorOption.LF.toString());
|
||||
final String[] expected = {
|
||||
"0: File does not end with a newline."
|
||||
"0: File does not end with a newline.",
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
|
|
@ -48,7 +64,7 @@ public class NewlineAtEndOfFileCheckTest
|
|||
expected);
|
||||
}
|
||||
|
||||
@Test(expected=CheckstyleException.class)
|
||||
@Test(expected = CheckstyleException.class)
|
||||
public void testSetLineSeparatorFailure()
|
||||
throws Exception
|
||||
{
|
||||
|
|
@ -59,14 +75,13 @@ public class NewlineAtEndOfFileCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyFileFile()
|
||||
throws Exception
|
||||
public void testEmptyFileFile() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NewlineAtEndOfFileCheck.class);
|
||||
checkConfig.addAttribute("lineSeparator", LineSeparatorOption.LF.toString());
|
||||
final String[] expected = {
|
||||
"0: File does not end with a newline."
|
||||
"0: File does not end with a newline.",
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
|
|
|
|||
|
|
@ -1,28 +1,47 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class OuterTypeFilenameCheckTest extends BaseCheckTestSupport {
|
||||
public class OuterTypeFilenameCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testGood() throws Exception {
|
||||
public void testGood() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(OuterTypeFilenameCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
@Test
|
||||
public void testBad() throws Exception {
|
||||
public void testBad() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(OuterTypeFilenameCheck.class);
|
||||
final String[] expected = {
|
||||
"3: The name of the outer type and the file do not match."
|
||||
"3: The name of the outer type and the file do not match.",
|
||||
};
|
||||
verify(checkConfig, getPath("Input15Extensions.java"), expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -7,8 +25,7 @@ import org.junit.Test;
|
|||
public class RegexpCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testRequiredPass()
|
||||
throws Exception
|
||||
public void testRequiredPass() throws Exception
|
||||
{
|
||||
final String required = "Test case file";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -20,22 +37,20 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredFail()
|
||||
throws Exception
|
||||
public void testRequiredFail() throws Exception
|
||||
{
|
||||
final String required = "This text is not in the file";
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RegexpCheck.class);
|
||||
checkConfig.addAttribute("format", required);
|
||||
final String[] expected = {
|
||||
"0: Required pattern '" + required + "' missing in file."
|
||||
"0: Required pattern '" + required + "' missing in file.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredNoDuplicatesPass()
|
||||
throws Exception
|
||||
public void testRequiredNoDuplicatesPass() throws Exception
|
||||
{
|
||||
final String required = "Test case file";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -48,8 +63,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredNoDuplicatesFail()
|
||||
throws Exception
|
||||
public void testRequiredNoDuplicatesFail() throws Exception
|
||||
{
|
||||
final String required = "Boolean x = new Boolean";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -57,14 +71,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("format", required);
|
||||
checkConfig.addAttribute("duplicateLimit", "0");
|
||||
final String[] expected = {
|
||||
"24: Found duplicate pattern '" + required + "'."
|
||||
"24: Found duplicate pattern '" + required + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIllegalPass()
|
||||
throws Exception
|
||||
public void testIllegalPass() throws Exception
|
||||
{
|
||||
final String illegal = "This text is not in the file";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -77,8 +90,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIllegalFailBelowErrorLimit()
|
||||
throws Exception
|
||||
public void testIllegalFailBelowErrorLimit() throws Exception
|
||||
{
|
||||
final String illegal = "^import";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -89,18 +101,17 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
final String[] expected = {
|
||||
"7: Line matches the illegal pattern '" + illegal + "'.",
|
||||
"8: Line matches the illegal pattern '" + illegal + "'.",
|
||||
"9: Line matches the illegal pattern '" + illegal + "'."
|
||||
"9: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIllegalFailAboveErrorLimit()
|
||||
throws Exception
|
||||
public void testIllegalFailAboveErrorLimit() throws Exception
|
||||
{
|
||||
final String illegal = "^import";
|
||||
final String error = "The error limit has been exceeded, "
|
||||
+ "the check is aborting, there may be more unreported errors.";
|
||||
+ "the check is aborting, there may be more unreported errors.";
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RegexpCheck.class);
|
||||
checkConfig.addAttribute("format", illegal);
|
||||
|
|
@ -109,7 +120,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
final String[] expected = {
|
||||
"7: Line matches the illegal pattern '" + illegal + "'.",
|
||||
"8: Line matches the illegal pattern '" + illegal + "'.",
|
||||
"9: Line matches the illegal pattern '" + error + illegal + "'."
|
||||
"9: Line matches the illegal pattern '" + error + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
@ -126,7 +137,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("message", message);
|
||||
final String[] expected = {
|
||||
"69: Line matches the illegal pattern '" + message + "'."
|
||||
"69: Line matches the illegal pattern '" + message + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
@ -142,14 +153,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("message", null);
|
||||
final String[] expected = {
|
||||
"69: Line matches the illegal pattern '" + illegal + "'."
|
||||
"69: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCaseTrue()
|
||||
throws Exception
|
||||
public void testIgnoreCaseTrue() throws Exception
|
||||
{
|
||||
final String illegal = "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\(";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -157,14 +167,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("format", illegal);
|
||||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
final String[] expected = {
|
||||
"69: Line matches the illegal pattern '" + illegal + "'."
|
||||
"69: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCaseFalse()
|
||||
throws Exception
|
||||
public void testIgnoreCaseFalse() throws Exception
|
||||
{
|
||||
final String illegalTrue = "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\(";
|
||||
final DefaultConfiguration checkConfigTrue =
|
||||
|
|
@ -172,7 +181,8 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfigTrue.addAttribute("format", illegalTrue);
|
||||
checkConfigTrue.addAttribute("illegalPattern", "true");
|
||||
final String[] expectedTrue = {
|
||||
"69: Line matches the illegal pattern '" + illegalTrue + "'."};
|
||||
"69: Line matches the illegal pattern '" + illegalTrue + "'.",
|
||||
};
|
||||
verify(checkConfigTrue, getPath("InputSemantic.java"), expectedTrue);
|
||||
|
||||
final String illegalFalse = "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\(";
|
||||
|
|
@ -185,8 +195,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsCppStyle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsCppStyle() throws Exception
|
||||
{
|
||||
// See if the comment is removed properly
|
||||
final String illegal = "don't use trailing comments";
|
||||
|
|
@ -201,8 +210,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsFalseCppStyle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsFalseCppStyle() throws Exception
|
||||
{
|
||||
// See if the comment is removed properly
|
||||
final String illegal = "don't use trailing comments";
|
||||
|
|
@ -212,14 +220,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("ignoreComments", "false");
|
||||
final String[] expected = {
|
||||
"2: Line matches the illegal pattern '" + illegal + "'."
|
||||
"2: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputTrailingComment.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsCStyle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsCStyle() throws Exception
|
||||
{
|
||||
// See if the comment is removed properly
|
||||
final String illegal = "c-style 1";
|
||||
|
|
@ -234,8 +241,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsFalseCStyle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsFalseCStyle() throws Exception
|
||||
{
|
||||
final String illegal = "c-style 1";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -244,14 +250,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("ignoreComments", "false");
|
||||
final String[] expected = {
|
||||
"17: Line matches the illegal pattern '" + illegal + "'."
|
||||
"17: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputTrailingComment.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsMultipleCStyle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsMultipleCStyle() throws Exception
|
||||
{
|
||||
// See if a second comment on the same line is removed properly
|
||||
final String illegal = "c-style 2";
|
||||
|
|
@ -266,8 +271,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsMultiLine()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsMultiLine() throws Exception
|
||||
{
|
||||
final String illegal = "Let's check multi-line comments";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -281,8 +285,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsInlineStart()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsInlineStart() throws Exception
|
||||
{
|
||||
final String illegal = "long ms /";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -296,8 +299,7 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsInlineEnd()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsInlineEnd() throws Exception
|
||||
{
|
||||
final String illegal = "int z";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -306,14 +308,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("ignoreComments", "true");
|
||||
final String[] expected = {
|
||||
"20: Line matches the illegal pattern '" + illegal + "'."
|
||||
"20: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputTrailingComment.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsInlineMiddle()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsInlineMiddle() throws Exception
|
||||
{
|
||||
final String illegal = "int y";
|
||||
final DefaultConfiguration checkConfig =
|
||||
|
|
@ -322,14 +323,13 @@ public class RegexpCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("illegalPattern", "true");
|
||||
checkConfig.addAttribute("ignoreComments", "true");
|
||||
final String[] expected = {
|
||||
"21: Line matches the illegal pattern '" + illegal + "'."
|
||||
"21: Line matches the illegal pattern '" + illegal + "'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputTrailingComment.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCommentsNoSpaces()
|
||||
throws Exception
|
||||
public void testIgnoreCommentsNoSpaces() throws Exception
|
||||
{
|
||||
// make sure the comment is not turned into spaces
|
||||
final String illegal = "long ms ";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,8 +26,7 @@ public class TodoCommentCheckTest
|
|||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testIt()
|
||||
throws Exception
|
||||
public void testIt() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(TodoCommentCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -7,10 +25,11 @@ import org.junit.Test;
|
|||
|
||||
public class TrailingCommentCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
DefaultConfiguration mCheckConfig;
|
||||
private DefaultConfiguration mCheckConfig;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setUp()
|
||||
{
|
||||
mCheckConfig = createCheckConfig(TrailingCommentCheck.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -19,16 +37,15 @@ public class TranslationCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTranslation()
|
||||
throws Exception
|
||||
public void testTranslation() throws Exception
|
||||
{
|
||||
final Configuration checkConfig = createCheckConfig(TranslationCheck.class);
|
||||
final String[] expected = {
|
||||
"0: Key 'only.english' missing."
|
||||
"0: Key 'only.english' missing.",
|
||||
};
|
||||
final File[] propertyFiles = new File[] {
|
||||
new File(getPath("messages_de.properties")),
|
||||
new File(getPath("messages.properties"))
|
||||
new File(getPath("messages.properties")),
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.annotation;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -12,7 +30,8 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testParansAlways() throws Exception {
|
||||
public void testParansAlways() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ALWAYS");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -25,13 +44,14 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that annotation parens are never present.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testParansNever() throws Exception {
|
||||
public void testParansNever() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "NEVER");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -45,13 +65,9 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that annotation is always in expanded style.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testStyleExpanded() throws Exception {
|
||||
|
||||
public void testStyleExpanded() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "EXPANDED");
|
||||
|
|
@ -68,13 +84,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that annotation is always in compact style.
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testStyleCompact() throws Exception {
|
||||
public void testStyleCompact() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "COMPACT");
|
||||
|
|
@ -86,13 +99,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that annotation is always in compact no array style.
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testStyleCompactNoArray() throws Exception {
|
||||
public void testStyleCompactNoArray() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "COMPACT_NO_ARRAY");
|
||||
|
|
@ -107,9 +117,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "DifferentUseStyles.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCommaAlwaysViolations() throws Exception {
|
||||
public void testCommaAlwaysViolations() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -132,9 +143,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseNoTrailingComma.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCommaAlwaysNoViolations() throws Exception {
|
||||
public void testCommaAlwaysNoViolations() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -144,9 +156,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseWithTrailingComma.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCommaNeverViolations() throws Exception {
|
||||
public void testCommaNeverViolations() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -164,9 +177,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseWithTrailingComma.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCommaNeverNoViolations() throws Exception {
|
||||
public void testCommaNeverNoViolations() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
@ -176,9 +190,10 @@ public class AnnotationUseStyleTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "AnnotationUseNoTrailingComma.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEverythingMixed() throws Exception {
|
||||
public void testEverythingMixed() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AnnotationUseStyleCheck.class);
|
||||
checkConfig.addAttribute("closingParens", "ignore");
|
||||
checkConfig.addAttribute("elementStyle", "ignore");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.annotation;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -13,10 +31,10 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport
|
|||
* Tests that memebers that are only deprecated via javadoc are flagged.
|
||||
*/
|
||||
@Test
|
||||
public void testBadDeprecatedAnnotation() throws Exception {
|
||||
|
||||
public void testBadDeprecatedAnnotation() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"7: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.",
|
||||
"12: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.",
|
||||
|
|
@ -31,15 +49,16 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadDeprecatedAnnotation.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests that memebers that are only deprecated via the annotation are flagged.
|
||||
*/
|
||||
@Test
|
||||
public void testBadDeprecatedJavadoc() throws Exception {
|
||||
|
||||
public void testBadDeprecatedJavadoc() throws Exception
|
||||
{
|
||||
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.",
|
||||
"11: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.",
|
||||
|
|
@ -54,15 +73,16 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadDeprecatedJavadoc.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests various special deprecation conditions such as duplicate or empty tags.
|
||||
*/
|
||||
@Test
|
||||
public void testSpecialCaseDeprecated() throws Exception {
|
||||
|
||||
public void testSpecialCaseDeprecated() throws Exception
|
||||
{
|
||||
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5: Duplicate @deprecated tag.",
|
||||
"12: Duplicate @deprecated tag.",
|
||||
|
|
@ -81,15 +101,16 @@ public class MissingDeprecatedTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SpecialCaseDeprecated.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests that good forms of deprecation are not flagged.
|
||||
*/
|
||||
@Test
|
||||
public void testGoodDeprecated() throws Exception {
|
||||
|
||||
public void testGoodDeprecated() throws Exception
|
||||
{
|
||||
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingDeprecatedCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.annotation;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -8,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import org.junit.Test;
|
||||
|
||||
public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
{
|
||||
/**
|
||||
* This tests that classes not extending anything explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag.
|
||||
|
|
@ -19,7 +37,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "false");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"8: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.",
|
||||
"30: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.",
|
||||
|
|
@ -29,7 +47,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromObject.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests that classes not extending anything explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag even in Java 5 compatibility mode.
|
||||
|
|
@ -40,7 +58,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "true");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"8: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.",
|
||||
"30: Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.",
|
||||
|
|
@ -50,7 +68,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromObject.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests classes that are extending things explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag.
|
||||
|
|
@ -72,7 +90,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromOther.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests classes that are extending things explicitly will NOT be flagged while in
|
||||
* Java 5 compatibility mode.
|
||||
|
|
@ -83,13 +101,13 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "true");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadOverrideFromOther.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests anonymous inner classes that are overriding methods are correctly flagged
|
||||
* for only including the inheritDoc tag.
|
||||
|
|
@ -108,7 +126,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadAnnonOverride.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests anonymous inner classes that are overriding methods are NOT flagged while in
|
||||
* Java 5 compatibility mode.
|
||||
|
|
@ -124,13 +142,14 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadAnnonOverride.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests that inheritDoc misuse is properly flagged or missing Javadocs do not cause a problem.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testNotOverride() throws Exception {
|
||||
public void testNotOverride() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
final String[] expected = {
|
||||
"8: The Javadoc {@inheritDoc} tag is not valid at this location.",
|
||||
|
|
@ -141,7 +160,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "NotOverride.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests that classes not extending anything explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag.
|
||||
|
|
@ -152,13 +171,13 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "false");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "GoodOverrideFromObject.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests that classes not extending anything explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag even in Java 5 compatibility mode.
|
||||
|
|
@ -169,13 +188,13 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "true");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "GoodOverrideFromObject.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests classes that are extending things explicitly will be correctly
|
||||
* flagged for only including the inheritDoc tag.
|
||||
|
|
@ -190,7 +209,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "GoodOverrideFromOther.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests classes that are extending things explicitly will NOT be flagged while in
|
||||
* Java 5 compatibility mode.
|
||||
|
|
@ -201,13 +220,13 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MissingOverrideCheck.class);
|
||||
checkConfig.addAttribute("javaFiveCompatibility", "true");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "GoodOverrideFromOther.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests anonymous inner classes that are overriding methods are correctly flagged
|
||||
* for only including the inheritDoc tag.
|
||||
|
|
@ -222,7 +241,7 @@ public class MissingOverrideCheckTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "GoodAnnonOverride.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests anonymous inner classes that are overriding methods are NOT flagged while in
|
||||
* Java 5 compatibility mode.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.annotation;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -9,48 +27,48 @@ public class PackageAnnotationTest extends BaseCheckTestSupport
|
|||
{
|
||||
/**
|
||||
* This tests 1 package annotation that is not in the package-info.java file.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBadPackageAnnotation1() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(PackageAnnotationCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"0: Package annotations must be in the package-info.java info.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadPackageAnnotation1.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests 2 package annotations that are not in the package-info.java file.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBadPackageAnnotation2() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(PackageAnnotationCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"0: Package annotations must be in the package-info.java info.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "BadPackageAnnotation2.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This tests a package annotation that is in the package-info.java file.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGoodPackageAnnotation() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(PackageAnnotationCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,27 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.annotation;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SuppressWarningsTest extends BaseCheckTestSupport
|
||||
{
|
||||
|
|
@ -14,9 +30,10 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleDefault() throws Exception {
|
||||
public void testSingleDefault() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"8:23: The warning ' ' cannot be suppressed at this location.",
|
||||
"11:27: The warning '' cannot be suppressed at this location.",
|
||||
|
|
@ -31,16 +48,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings all warnings disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleAll() throws Exception {
|
||||
public void testSingleAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", ".*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"8:23: The warning ' ' cannot be suppressed at this location.",
|
||||
|
|
@ -80,16 +98,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleNoUnchecked() throws Exception {
|
||||
public void testSingleNoUnchecked() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"29:35: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"56:27: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:33: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:42: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:65: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -99,21 +118,22 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked warning disabled on certain tokens.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleNoUncheckedTokens() throws Exception {
|
||||
public void testSingleNoUncheckedTokens() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
checkConfig.addAttribute("tokens", "CLASS_DEF,METHOD_DEF");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"29:35: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:33: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:65: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"77:37: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -128,10 +148,11 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleNoUnWildcard() throws Exception {
|
||||
public void testSingleNoUnWildcard() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", ".*un.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"17:23: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -143,7 +164,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"47:27: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:27: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:33: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:42: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:54: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -156,16 +177,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleNoUncheckedUnused() throws Exception {
|
||||
public void testSingleNoUncheckedUnused() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"17:23: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -174,7 +196,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"47:27: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:27: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:33: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:42: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:54: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -187,16 +209,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings *, unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSingleNoUncheckedUnusedAll() throws Exception {
|
||||
public void testSingleNoUncheckedUnusedAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:19: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"8:23: The warning ' ' cannot be suppressed at this location.",
|
||||
|
|
@ -230,24 +253,25 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsSingle.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings with default regex.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactDefault() throws Exception {
|
||||
public void testCompactDefault() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"8:24: The warning ' ' cannot be suppressed at this location.",
|
||||
"11:41: The warning '' cannot be suppressed at this location.",
|
||||
"44:23: The warning '' cannot be suppressed at this location.",
|
||||
"53:27: The warning '' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:48: The warning '' cannot be suppressed at this location.",
|
||||
"64:76: The warning '' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"67:38: The warning '' cannot be suppressed at this location.",
|
||||
"72:47: The warning ' ' cannot be suppressed at this location.",
|
||||
"72:98: The warning ' ' cannot be suppressed at this location.",
|
||||
|
|
@ -260,16 +284,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings all warnings disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactAll() throws Exception {
|
||||
public void testCompactAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", ".*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:33: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -288,26 +313,26 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"53:27: The warning '' cannot be suppressed at this location.",
|
||||
"56:28: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:48: The warning '' cannot be suppressed at this location.",
|
||||
"64:62: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:76: The warning '' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"67:38: The warning '' cannot be suppressed at this location.",
|
||||
"67:43: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"72:47: The warning ' ' cannot be suppressed at this location.",
|
||||
"72:55: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:66: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:98: The warning ' ' cannot be suppressed at this location.",
|
||||
"72:106: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:117: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"77:38: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"77:61: The warning ' ' cannot be suppressed at this location.",
|
||||
"77:69: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"82:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"82:94: The warning '' cannot be suppressed at this location.",
|
||||
"82:99: The warning 'foo' cannot be suppressed at this location.",
|
||||
|
|
@ -328,10 +353,11 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactNoUnchecked() throws Exception {
|
||||
public void testCompactNoUnchecked() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"11:28: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -349,22 +375,23 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked warning disabled on certain tokens.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactNoUncheckedTokens() throws Exception {
|
||||
public void testCompactNoUncheckedTokens() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
checkConfig.addAttribute("tokens", "CLASS_DEF");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:62: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
};
|
||||
|
|
@ -377,10 +404,11 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactNoUnWildcard() throws Exception {
|
||||
public void testCompactNoUnWildcard() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "un.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:33: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -392,20 +420,20 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"47:28: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:28: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:62: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"67:43: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
"72:55: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:66: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:106: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:117: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"77:38: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"77:69: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"82:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"82:115: The warning 'unused' cannot be suppressed at this location.",
|
||||
"82:135: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -414,16 +442,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactNoUncheckedUnused() throws Exception {
|
||||
public void testCompactNoUncheckedUnused() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:33: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -433,7 +462,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"29:36: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"47:28: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:28: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:62: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:43: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -447,20 +476,21 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"82:115: The warning 'unused' cannot be suppressed at this location.",
|
||||
"82:135: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"82:202: The warning 'unused' cannot be suppressed at this location.",
|
||||
};
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings *, unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testCompactNoUncheckedUnusedAll() throws Exception {
|
||||
public void testCompactNoUncheckedUnusedAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:20: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:33: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -479,26 +509,26 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"53:27: The warning '' cannot be suppressed at this location.",
|
||||
"56:28: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:48: The warning '' cannot be suppressed at this location.",
|
||||
"64:62: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:76: The warning '' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"67:38: The warning '' cannot be suppressed at this location.",
|
||||
"67:43: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"72:47: The warning ' ' cannot be suppressed at this location.",
|
||||
"72:55: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:66: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"72:98: The warning ' ' cannot be suppressed at this location.",
|
||||
"72:106: The warning 'unused' cannot be suppressed at this location.",
|
||||
"72:117: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"77:38: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"77:61: The warning ' ' cannot be suppressed at this location.",
|
||||
"77:69: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"82:48: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"82:94: The warning '' cannot be suppressed at this location.",
|
||||
"82:99: The warning 'foo' cannot be suppressed at this location.",
|
||||
|
|
@ -513,13 +543,14 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsCompact.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings with default regex.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedDefault() throws Exception {
|
||||
public void testExpandedDefault() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
|
||||
final String[] expected = {
|
||||
|
|
@ -541,16 +572,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings all warnings disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedAll() throws Exception {
|
||||
public void testExpandedAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", ".*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:39: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -569,7 +601,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"53:33: The warning '' cannot be suppressed at this location.",
|
||||
"56:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:55: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:54: The warning '' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -595,7 +627,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"82:192: The warning 'foo' cannot be suppressed at this location.",
|
||||
"82:200: The warning ' ' cannot be suppressed at this location.",
|
||||
"82:208: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected);
|
||||
|
|
@ -606,17 +638,18 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedNoUnchecked() throws Exception {
|
||||
public void testExpandedNoUnchecked() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"11:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"29:42: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"56:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:55: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -629,20 +662,21 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked warning disabled on certain tokens.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedNoUncheckedTokens() throws Exception {
|
||||
public void testExpandedNoUncheckedTokens() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*");
|
||||
checkConfig.addAttribute("tokens", "CLASS_DEF");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
};
|
||||
|
|
@ -655,10 +689,11 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedNoUnWildcard() throws Exception {
|
||||
public void testExpandedNoUnWildcard() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "un.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:39: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -670,7 +705,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"47:34: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:55: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -688,17 +723,18 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedNoUncheckedUnused() throws Exception {
|
||||
public void testExpandedNoUncheckedUnused() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:39: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -709,7 +745,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"47:34: The warning 'unused' cannot be suppressed at this location.",
|
||||
"56:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:55: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"67:49: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
@ -727,16 +763,17 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
|
||||
verify(checkConfig, getPath("annotation" + File.separator + "SuppressWarningsExpanded.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests SuppressWarnings *, unchecked, unused warning disabled on everything.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExpandedNoUncheckedUnusedAll() throws Exception {
|
||||
public void testExpandedNoUncheckedUnusedAll() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
checkConfig.addAttribute("format", "^unchecked$*|^unused$*|.*");
|
||||
|
||||
|
||||
final String[] expected = {
|
||||
"5:26: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"5:39: The warning 'unused' cannot be suppressed at this location.",
|
||||
|
|
@ -755,7 +792,7 @@ public class SuppressWarningsTest extends BaseCheckTestSupport
|
|||
"53:33: The warning '' cannot be suppressed at this location.",
|
||||
"56:34: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"59:55: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
||||
|
||||
"64:40: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
"64:54: The warning '' cannot be suppressed at this location.",
|
||||
"64:68: The warning 'unchecked' cannot be suppressed at this location.",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.blocks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.blocks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.blocks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -119,7 +137,7 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNL3() throws Exception
|
||||
{
|
||||
|
|
@ -146,27 +164,27 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
};
|
||||
verify(mCheckConfig, getPath("InputBraces.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultWithAnnotations() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"10:1: '{' should be on the previous line.",
|
||||
"14:5: '{' should be on the previous line.",
|
||||
"21:5: '{' should be on the previous line."
|
||||
"21:5: '{' should be on the previous line.",
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyAnnotations.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNLWithAnnotations() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString());
|
||||
final String[] expected = {
|
||||
final String[] expected = {
|
||||
"35:34: '{' should be on a new line.",
|
||||
"38:41: '{' should be on a new line.",
|
||||
"44:27: '{' should be on a new line.",
|
||||
"58:32: '{' should be on a new line."
|
||||
"58:32: '{' should be on a new line.",
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyAnnotations.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2002 Oliver Burn
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.blocks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -13,7 +31,7 @@ public class DefaultComesLastCheckTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(DefaultComesLastCheck.class);
|
||||
final String[] expected = {
|
||||
"22:9: Default should be last label in the switch."
|
||||
"22:9: Default should be last label in the switch.",
|
||||
};
|
||||
verify(checkConfig,
|
||||
getPath("coding" + File.separator + "InputDefaultComesLast.java"),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -15,22 +33,22 @@ public class EmptyStatementCheckTest
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(EmptyStatementCheck.class);
|
||||
final String[] expected = {
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
"43:10: Empty statement.",
|
||||
"49:13: Empty statement.",
|
||||
"51:13: Empty statement.",
|
||||
"54:19: Empty statement.",
|
||||
"58:10: Empty statement.",
|
||||
"61:9: Empty statement.",
|
||||
"66:10: Empty statement.",
|
||||
"72:10: Empty statement.",
|
||||
"76:10: Empty statement.",
|
||||
"80:10: Empty statement.",
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
"43:10: Empty statement.",
|
||||
"49:13: Empty statement.",
|
||||
"51:13: Empty statement.",
|
||||
"54:19: Empty statement.",
|
||||
"58:10: Empty statement.",
|
||||
"61:9: Empty statement.",
|
||||
"66:10: Empty statement.",
|
||||
"72:10: Empty statement.",
|
||||
"76:10: Empty statement.",
|
||||
"80:10: Empty statement.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("InputEmptyStatement.java"), expected);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -5,8 +23,7 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EqualsAvoidNullTest
|
||||
extends BaseCheckTestSupport
|
||||
public class EqualsAvoidNullTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testIt() throws Exception
|
||||
|
|
@ -15,12 +32,12 @@ extends BaseCheckTestSupport
|
|||
createCheckConfig(EqualsAvoidNullCheck.class);
|
||||
|
||||
final String[] expected = {
|
||||
"18:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"20:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"22:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"24:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"26:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"28:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"18:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"20:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"22:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"24:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"26:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
"28:17: String literal expressions should be on the left side of an equals comparison.",
|
||||
};
|
||||
verify(checkConfig, getPath("coding" + File.separator + "InputEqualsAvoidNull.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -22,11 +40,11 @@ public class IllegalInstantiationCheckTest
|
|||
"19:21: Instantiation of java.lang.Boolean should be avoided.",
|
||||
"24:21: Instantiation of java.lang.Boolean should be avoided.",
|
||||
"31:16: Instantiation of java.lang.Boolean should be avoided.",
|
||||
"38:21: Instantiation of " +
|
||||
"com.puppycrawl.tools.checkstyle.InputModifier " +
|
||||
"should be avoided.",
|
||||
"38:21: Instantiation of "
|
||||
+ "com.puppycrawl.tools.checkstyle.InputModifier "
|
||||
+ "should be avoided.",
|
||||
"41:18: Instantiation of java.io.File should be avoided.",
|
||||
"44:21: Instantiation of java.awt.Color should be avoided."
|
||||
"44:21: Instantiation of java.awt.Color should be avoided.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -22,17 +40,16 @@ public class IllegalTokenCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNative()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(IllegalTokenCheck.class);
|
||||
checkConfig.addAttribute("tokens", "LITERAL_NATIVE");
|
||||
final String[] expected = {
|
||||
"20:12: Using 'native' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
public void testNative() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(IllegalTokenCheck.class);
|
||||
checkConfig.addAttribute("tokens", "LITERAL_NATIVE");
|
||||
final String[] expected = {
|
||||
"20:12: Using 'native' is not allowed.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -11,12 +29,14 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport
|
|||
private DefaultConfiguration mCheckConfig;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setUp()
|
||||
{
|
||||
mCheckConfig = createCheckConfig(IllegalTypeCheck.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaults() throws Exception {
|
||||
public void testDefaults() throws Exception
|
||||
{
|
||||
String[] expected = {
|
||||
"6:13: Declaring variables, return values or parameters of type 'AbstractClass' is not allowed.",
|
||||
"9:13: Declaring variables, return values or parameters of type "
|
||||
|
|
@ -30,7 +50,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreMethodNames() throws Exception {
|
||||
public void testIgnoreMethodNames() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("ignoredMethodNames", "table2");
|
||||
|
||||
String[] expected = {
|
||||
|
|
@ -45,7 +66,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFormat() throws Exception {
|
||||
public void testFormat() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("format", "^$");
|
||||
|
||||
String[] expected = {
|
||||
|
|
@ -57,7 +79,8 @@ public class IllegalTypeCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLegalAbstractClassNames() throws Exception {
|
||||
public void testLegalAbstractClassNames() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("legalAbstractClassNames", "AbstractClass");
|
||||
|
||||
String[] expected = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -221,49 +239,49 @@ public class MagicNumberCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreNegativeOctalHex()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(MagicNumberCheck.class);
|
||||
checkConfig.addAttribute("ignoreNumbers", "-9223372036854775808, -2147483648, -1, 0, 1, 2");
|
||||
checkConfig.addAttribute("tokens", "NUM_INT, NUM_LONG");
|
||||
final String[] expected = {
|
||||
"41:26: '3' is a magic number.",
|
||||
"43:27: '3' is a magic number.",
|
||||
"43:31: '4' is a magic number.",
|
||||
"45:29: '3' is a magic number.",
|
||||
"47:23: '3' is a magic number.",
|
||||
"50:22: '3' is a magic number.",
|
||||
"50:29: '5' is a magic number.",
|
||||
"50:37: '3' is a magic number.",
|
||||
"54:26: '3' is a magic number.",
|
||||
"55:39: '3' is a magic number.",
|
||||
"60:25: '010' is a magic number.",
|
||||
"61:25: '011' is a magic number.",
|
||||
"63:30: '010L' is a magic number.",
|
||||
"64:30: '011l' is a magic number.",
|
||||
"68:24: '0x10' is a magic number.",
|
||||
"69:24: '0X011' is a magic number.",
|
||||
"71:29: '0x10L' is a magic number.",
|
||||
"72:29: '0X11l' is a magic number.",
|
||||
"85:28: '3' is a magic number.",
|
||||
"92:14: '0xffffffffL' is a magic number.",
|
||||
"100:30: '+3' is a magic number.",
|
||||
"101:29: '-2' is a magic number.",
|
||||
"131:20: '378' is a magic number.",
|
||||
"160:16: '31' is a magic number.",
|
||||
"165:16: '42' is a magic number.",
|
||||
"170:16: '13' is a magic number.",
|
||||
"174:15: '21' is a magic number.",
|
||||
"178:15: '37' is a magic number.",
|
||||
"182:15: '101' is a magic number.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputMagicNumber.java"), expected);
|
||||
}
|
||||
public void testIgnoreNegativeOctalHex() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(MagicNumberCheck.class);
|
||||
checkConfig.addAttribute("ignoreNumbers", "-9223372036854775808, -2147483648, -1, 0, 1, 2");
|
||||
checkConfig.addAttribute("tokens", "NUM_INT, NUM_LONG");
|
||||
final String[] expected = {
|
||||
"41:26: '3' is a magic number.",
|
||||
"43:27: '3' is a magic number.",
|
||||
"43:31: '4' is a magic number.",
|
||||
"45:29: '3' is a magic number.",
|
||||
"47:23: '3' is a magic number.",
|
||||
"50:22: '3' is a magic number.",
|
||||
"50:29: '5' is a magic number.",
|
||||
"50:37: '3' is a magic number.",
|
||||
"54:26: '3' is a magic number.",
|
||||
"55:39: '3' is a magic number.",
|
||||
"60:25: '010' is a magic number.",
|
||||
"61:25: '011' is a magic number.",
|
||||
"63:30: '010L' is a magic number.",
|
||||
"64:30: '011l' is a magic number.",
|
||||
"68:24: '0x10' is a magic number.",
|
||||
"69:24: '0X011' is a magic number.",
|
||||
"71:29: '0x10L' is a magic number.",
|
||||
"72:29: '0X11l' is a magic number.",
|
||||
"85:28: '3' is a magic number.",
|
||||
"92:14: '0xffffffffL' is a magic number.",
|
||||
"100:30: '+3' is a magic number.",
|
||||
"101:29: '-2' is a magic number.",
|
||||
"131:20: '378' is a magic number.",
|
||||
"160:16: '31' is a magic number.",
|
||||
"165:16: '42' is a magic number.",
|
||||
"170:16: '13' is a magic number.",
|
||||
"174:15: '21' is a magic number.",
|
||||
"178:15: '37' is a magic number.",
|
||||
"182:15: '101' is a magic number.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputMagicNumber.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreHashCodeMethod() throws Exception {
|
||||
public void testIgnoreHashCodeMethod() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(MagicNumberCheck.class);
|
||||
checkConfig.addAttribute("ignoreHashCodeMethod", "true");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,7 +26,8 @@ public class ModifiedControlVariableCheckTest
|
|||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testModifiedControlVariable() throws Exception {
|
||||
public void testModifiedControlVariable() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(ModifiedControlVariableCheck.class);
|
||||
final String[] expected = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -19,7 +37,7 @@ public class MultipleStringLiteralsCheckTest extends BaseCheckTestSupport
|
|||
"5:16: The String \"StringContents\" appears 3 times in the file.",
|
||||
"8:17: The String \"\" appears 4 times in the file.",
|
||||
"10:23: The String \", \" appears 3 times in the file.",
|
||||
};
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getPath("coding" + File.separator + "InputMultipleStringLiterals.java"),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,23 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck;
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import org.junit.Test;
|
||||
|
|
@ -9,7 +26,8 @@ import org.junit.Test;
|
|||
* The unit-test for the <code>NestedForDepthCheck</code>-checkstyle enhancement.
|
||||
* @see com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck
|
||||
*/
|
||||
public class NestedForDepthCheckTest extends BaseCheckTestSupport {
|
||||
public class NestedForDepthCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
/**
|
||||
* Call the check allowing 2 layers of nested for-statements. This
|
||||
* means the top-level for can contain up to 2 levels of nested for
|
||||
|
|
@ -20,7 +38,8 @@ public class NestedForDepthCheckTest extends BaseCheckTestSupport {
|
|||
* interface-requirements for test-methods
|
||||
*/
|
||||
@Test
|
||||
public void testNestedTooDeep() throws Exception {
|
||||
public void testNestedTooDeep() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NestedForDepthCheck.class);
|
||||
checkConfig.addAttribute("max", "2");
|
||||
|
|
@ -45,7 +64,8 @@ public class NestedForDepthCheckTest extends BaseCheckTestSupport {
|
|||
* interface-requirements for test-methods
|
||||
*/
|
||||
@Test
|
||||
public void testNestedOk() throws Exception {
|
||||
public void testNestedOk() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NestedForDepthCheck.class);
|
||||
checkConfig.addAttribute("max", "4");
|
||||
|
|
@ -56,4 +76,4 @@ public class NestedForDepthCheckTest extends BaseCheckTestSupport {
|
|||
verify(checkConfig, getPath("coding/InputNestedForDepth.java"),
|
||||
expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,26 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
//Copyright (C) 2001-2010 Oliver Burn
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
//This library is free software; you can redistribute it and/or
|
||||
//modify it under the terms of the GNU Lesser General Public
|
||||
//License as published by the Free Software Foundation; either
|
||||
//version 2.1 of the License, or (at your option) any later version.
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
//Lesser General Public License for more details.
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU Lesser General Public
|
||||
//License along with this library; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
|
|
@ -22,16 +22,19 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
|||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OneStatementPerLineCheckTest extends BaseCheckTestSupport {
|
||||
public class OneStatementPerLineCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testMultiCaseClass() throws Exception {
|
||||
public void testMultiCaseClass() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(OneStatementPerLineCheck.class);
|
||||
final String[] expected = {
|
||||
"99:18: Only one statement per line allowed.",
|
||||
"127:11: Only one statement per line allowed.",};
|
||||
"127:11: Only one statement per line allowed.",
|
||||
};
|
||||
|
||||
verify(checkConfig,
|
||||
getSrcPath("checks/coding/OneStatementPerLineCheckInput.java"),
|
||||
expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -27,7 +45,7 @@ public class PackageDeclarationCheckTest extends BaseCheckTestSupport
|
|||
.replace('/', File.separatorChar);
|
||||
|
||||
String[] expected = {
|
||||
"1:9: Package declaration does not match directory '" + dname + "'."
|
||||
"1:9: Package declaration does not match directory '" + dname + "'.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("coding" + File.separator + "InputIllegalCatchCheck.java"), expected);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,28 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ReturnCountCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,8 +26,7 @@ public class SimplifyBooleanExpressionCheckTest
|
|||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testIt()
|
||||
throws Exception
|
||||
public void testIt() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(SimplifyBooleanExpressionCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,8 +26,7 @@ public class SimplifyBooleanReturnCheckTest
|
|||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testIt()
|
||||
throws Exception
|
||||
public void testIt() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(SimplifyBooleanReturnCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -9,8 +27,7 @@ public class StringLiteralEqualityCheckTest
|
|||
extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testIt()
|
||||
throws Exception
|
||||
public void testIt() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(StringLiteralEqualityCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -12,8 +30,8 @@ import org.junit.Test;
|
|||
*/
|
||||
public class UnnecessaryParenthesesCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
private static final String TEST_FILE = "coding" + File.separator +
|
||||
"InputUnnecessaryParentheses.java";
|
||||
private static final String TEST_FILE = "coding" + File.separator
|
||||
+ "InputUnnecessaryParentheses.java";
|
||||
|
||||
@Test
|
||||
public void testDefault() throws Exception
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,22 +26,24 @@ import org.junit.Test;
|
|||
public class InnerTypeLastCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testMembersBeforeInner() throws Exception {
|
||||
public void testMembersBeforeInner() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(InnerTypeLastCheck.class);
|
||||
final String[] expected = {
|
||||
"15:17: Fields and methods should be before inner classes.",
|
||||
"25:17: Fields and methods should be before inner classes.",
|
||||
"26:17: Fields and methods should be before inner classes.",
|
||||
"39:25: Fields and methods should be before inner classes.",
|
||||
"40:25: Fields and methods should be before inner classes.",
|
||||
"44:9: Fields and methods should be before inner classes.",
|
||||
"60:25: Fields and methods should be before inner classes.",
|
||||
"61:25: Fields and methods should be before inner classes.",
|
||||
"65:9: Fields and methods should be before inner classes.",
|
||||
"69:9: Fields and methods should be before inner classes.",
|
||||
"78:5: Fields and methods should be before inner classes.", };
|
||||
"15:17: Fields and methods should be before inner classes.",
|
||||
"25:17: Fields and methods should be before inner classes.",
|
||||
"26:17: Fields and methods should be before inner classes.",
|
||||
"39:25: Fields and methods should be before inner classes.",
|
||||
"40:25: Fields and methods should be before inner classes.",
|
||||
"44:9: Fields and methods should be before inner classes.",
|
||||
"60:25: Fields and methods should be before inner classes.",
|
||||
"61:25: Fields and methods should be before inner classes.",
|
||||
"65:9: Fields and methods should be before inner classes.",
|
||||
"69:9: Fields and methods should be before inner classes.",
|
||||
"78:5: Fields and methods should be before inner classes.",
|
||||
};
|
||||
verify(checkConfig, getPath("design" + File.separator
|
||||
+ "InputInnerClassCheck.java"), expected);
|
||||
+ "InputInnerClassCheck.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,7 +26,8 @@ import org.junit.Test;
|
|||
public class MutableExceptionCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
public void test() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(MutableExceptionCheck.class);
|
||||
|
||||
String[] expected = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -8,7 +26,8 @@ import org.junit.Test;
|
|||
public class ThrowsCountCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testDefault() throws Exception {
|
||||
public void testDefault() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(ThrowsCountCheck.class);
|
||||
|
||||
String[] expected = {
|
||||
|
|
@ -21,7 +40,8 @@ public class ThrowsCountCheckTest extends BaseCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMax() throws Exception {
|
||||
public void testMax() throws Exception
|
||||
{
|
||||
DefaultConfiguration checkConfig = createCheckConfig(ThrowsCountCheck.class);
|
||||
checkConfig.addAttribute("max", "2");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.design;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -48,7 +66,8 @@ public class VisibilityModifierCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
public void testSimple() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"39:19: Variable 'mNumCreated2' must be private and have accessor methods.",
|
||||
"49:23: Variable 'sTest1' must be private and have accessor methods.",
|
||||
|
|
@ -61,8 +80,7 @@ public class VisibilityModifierCheckTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testStrictJavadoc()
|
||||
throws Exception
|
||||
public void testStrictJavadoc() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"44:9: Variable 'mLen' must be private and have accessor methods.",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.duplicates;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -25,12 +43,12 @@ public class StrictDuplicateCodeCheckTest extends BaseCheckTestSupport
|
|||
final Configuration checkConfig = createCheckConfig(StrictDuplicateCodeCheck.class);
|
||||
final String innerDupPath = getPath("duplicates/InnerDup.java");
|
||||
final String[] expected = {
|
||||
"6: Found duplicate of 13 lines in " + innerDupPath + ", starting from line 22",
|
||||
};
|
||||
"6: Found duplicate of 13 lines in " + innerDupPath + ", starting from line 22",
|
||||
};
|
||||
final File[] checkedFiles = new File[] {
|
||||
new File(innerDupPath),
|
||||
new File(getPath("duplicates/Shorty.java")),
|
||||
};
|
||||
new File(innerDupPath),
|
||||
new File(getPath("duplicates/Shorty.java")),
|
||||
};
|
||||
verify(createChecker(checkConfig), checkedFiles, innerDupPath, expected);
|
||||
}
|
||||
|
||||
|
|
@ -42,13 +60,13 @@ public class StrictDuplicateCodeCheckTest extends BaseCheckTestSupport
|
|||
final String aPath = getPath("duplicates/A.java");
|
||||
final String bPath = getPath("duplicates/B.java");
|
||||
final String[] expected = {
|
||||
// imports should not be marked because developer cannot avoid them
|
||||
// same constant def should not be marked because order is important for this check
|
||||
};
|
||||
// imports should not be marked because developer cannot avoid them
|
||||
// same constant def should not be marked because order is important for this check
|
||||
};
|
||||
final File[] checkedFiles = new File[] {
|
||||
new File(aPath),
|
||||
new File(bPath),
|
||||
};
|
||||
new File(aPath),
|
||||
new File(bPath),
|
||||
};
|
||||
verify(createChecker(checkConfig), checkedFiles, aPath, expected);
|
||||
}
|
||||
|
||||
|
|
@ -59,15 +77,15 @@ public class StrictDuplicateCodeCheckTest extends BaseCheckTestSupport
|
|||
checkConfig.addAttribute("min", "3");
|
||||
final String path = getPath("duplicates/Overlapping.java");
|
||||
final String[] expected = {
|
||||
"6: Found duplicate of 3 lines in " + path + ", starting from line 13",
|
||||
"6: Found duplicate of 5 lines in " + path + ", starting from line 25",
|
||||
"7: Found duplicate of 5 lines in " + path + ", starting from line 19",
|
||||
"13: Found duplicate of 3 lines in " + path + ", starting from line 25",
|
||||
"19: Found duplicate of 4 lines in " + path + ", starting from line 26",
|
||||
};
|
||||
"6: Found duplicate of 3 lines in " + path + ", starting from line 13",
|
||||
"6: Found duplicate of 5 lines in " + path + ", starting from line 25",
|
||||
"7: Found duplicate of 5 lines in " + path + ", starting from line 19",
|
||||
"13: Found duplicate of 3 lines in " + path + ", starting from line 25",
|
||||
"19: Found duplicate of 4 lines in " + path + ", starting from line 26",
|
||||
};
|
||||
final File[] checkedFiles = new File[] {
|
||||
new File(path),
|
||||
};
|
||||
new File(path),
|
||||
};
|
||||
final Checker checker = createChecker(checkConfig);
|
||||
verify(checker, checkedFiles, path, expected);
|
||||
}
|
||||
|
|
@ -78,10 +96,10 @@ public class StrictDuplicateCodeCheckTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig = createCheckConfig(StrictDuplicateCodeCheck.class);
|
||||
final String path = getPath("duplicates/LotsOfEmptyLines.java");
|
||||
final String[] expected = {
|
||||
};
|
||||
};
|
||||
final File[] checkedFiles = new File[] {
|
||||
new File(path),
|
||||
};
|
||||
new File(path),
|
||||
};
|
||||
final Checker checker = createChecker(checkConfig);
|
||||
verify(checker, checkedFiles, path, expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.header;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
|
@ -10,15 +28,14 @@ import org.junit.Test;
|
|||
public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testStaticHeader()
|
||||
throws Exception
|
||||
public void testStaticHeader() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(HeaderCheck.class);
|
||||
checkConfig.addAttribute("headerFile", getPath("java.header"));
|
||||
checkConfig.addAttribute("ignoreLines", "");
|
||||
final String[] expected = {
|
||||
"1: Missing a header - not enough lines in file."
|
||||
"1: Missing a header - not enough lines in file.",
|
||||
};
|
||||
verify(checkConfig, getPath("inputHeader.java"), expected);
|
||||
}
|
||||
|
|
@ -30,27 +47,25 @@ public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
|||
createCheckConfig(RegexpHeaderCheck.class);
|
||||
checkConfig.addAttribute("headerFile", getPath("regexp.header"));
|
||||
final String[] expected = {
|
||||
"3: Line does not match expected header line of '// Created: 2002'."
|
||||
"3: Line does not match expected header line of '// Created: 2002'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineRegexpHeader()
|
||||
throws Exception
|
||||
public void testInlineRegexpHeader() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RegexpHeaderCheck.class);
|
||||
checkConfig.addAttribute("header", "^/*$\\n// .*\\n// Created: 2002\\n^//.*\\n^//.*");
|
||||
final String[] expected = {
|
||||
"3: Line does not match expected header line of '// Created: 2002'."
|
||||
"3: Line does not match expected header line of '// Created: 2002'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureForMultilineRegexp()
|
||||
throws Exception
|
||||
public void testFailureForMultilineRegexp() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RegexpHeaderCheck.class);
|
||||
|
|
@ -131,7 +146,7 @@ public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
|||
checkConfig.addAttribute("headerFile", getPath("regexp.header2"));
|
||||
checkConfig.addAttribute("multiLines", "3");
|
||||
final String[] expected = {
|
||||
"1: Missing a header - not enough lines in file."
|
||||
"1: Missing a header - not enough lines in file.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputRegexpHeader4.java"), expected);
|
||||
}
|
||||
|
|
@ -165,8 +180,7 @@ public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNonExistingHeaderFile()
|
||||
throws Exception
|
||||
public void testNonExistingHeaderFile() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(HeaderCheck.class);
|
||||
|
|
@ -181,8 +195,7 @@ public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidCharset()
|
||||
throws Exception
|
||||
public void testInvalidCharset() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(HeaderCheck.class);
|
||||
|
|
@ -198,8 +211,7 @@ public class HeaderCheckTest extends BaseFileSetCheckTestSupport
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyFilename()
|
||||
throws Exception
|
||||
public void testEmptyFilename() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(HeaderCheck.class);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -32,7 +50,7 @@ public class AvoidStarImportTest
|
|||
checkConfig.addAttribute("excludes", "java.io,java.lang");
|
||||
// allow the java.io/java.lang star imports
|
||||
final String[] expected2 = new String[] {
|
||||
"7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.imports.*."
|
||||
"7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.imports.*.",
|
||||
};
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -34,12 +52,12 @@ public class AvoidStaticImportTest
|
|||
checkConfig.addAttribute("excludes", "java.io.File.*,sun.net.ftpclient.FtpClient.*");
|
||||
// allow the java.io.File.*/sun.net.ftpclient.FtpClient.* star imports
|
||||
final String[] expected = {
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
};
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
};
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMemberExcludes()
|
||||
throws Exception
|
||||
|
|
@ -49,29 +67,31 @@ public class AvoidStaticImportTest
|
|||
checkConfig.addAttribute("excludes", "java.io.File.listRoots");
|
||||
// allow the java.io.File.listRoots member imports
|
||||
final String[] expected = {
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"27: Using a static member import should be avoided - java.io.File.createTempFile.",
|
||||
"28: Using a static member import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
};
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"27: Using a static member import should be avoided - java.io.File.createTempFile.",
|
||||
"28: Using a static member import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
};
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBogusMemberExcludes()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(AvoidStaticImportCheck.class);
|
||||
checkConfig.addAttribute("excludes", "java.io.File.listRoots.listRoots, javax.swing.WindowConstants," +
|
||||
"sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk, java.io.File.listRootsmorejunk");
|
||||
checkConfig.addAttribute(
|
||||
"excludes",
|
||||
"java.io.File.listRoots.listRoots, javax.swing.WindowConstants,"
|
||||
+ "sun.net.ftpclient.FtpClient.*FtpClient, sun.net.ftpclient.FtpClientjunk, java.io.File.listRootsmorejunk");
|
||||
// allow the java.io.File.listRoots member imports
|
||||
final String[] expected = {
|
||||
"23: Using a static member import should be avoided - java.io.File.listRoots.",
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"27: Using a static member import should be avoided - java.io.File.createTempFile.",
|
||||
"28: Using a static member import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
"23: Using a static member import should be avoided - java.io.File.listRoots.",
|
||||
"25: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"26: Using a static member import should be avoided - javax.swing.WindowConstants.*.",
|
||||
"27: Using a static member import should be avoided - java.io.File.createTempFile.",
|
||||
"28: Using a static member import should be avoided - sun.net.ftpclient.FtpClient.*.",
|
||||
};
|
||||
verify(checkConfig, getPath("imports" + File.separator + "InputImport.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -5,8 +23,7 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IllegalImportCheckTest
|
||||
extends BaseCheckTestSupport
|
||||
public class IllegalImportCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
public void testWithSupplied()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
|
|
@ -25,9 +43,11 @@ public class ImportControlCheckRegExTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
|
||||
checkConfig.addAttribute("file", System.getProperty("testinputs.dir")
|
||||
+ "/import-control_two-re.xml");
|
||||
final String[] expected = {"3:1: Disallowed import - java.awt.Image.",
|
||||
"4:1: Disallowed import - javax.swing.border.*.",
|
||||
"6:1: Disallowed import - java.awt.Button.ABORT."};
|
||||
final String[] expected = {
|
||||
"3:1: Disallowed import - java.awt.Image.",
|
||||
"4:1: Disallowed import - javax.swing.border.*.",
|
||||
"6:1: Disallowed import - java.awt.Button.ABORT.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("imports" + File.separator
|
||||
+ "InputImportControl.java"), expected);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
|
@ -27,9 +45,11 @@ public class ImportControlCheckTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig = createCheckConfig(ImportControlCheck.class);
|
||||
checkConfig.addAttribute("file", System.getProperty("testinputs.dir")
|
||||
+ "/import-control_two.xml");
|
||||
final String[] expected = {"3:1: Disallowed import - java.awt.Image.",
|
||||
"4:1: Disallowed import - javax.swing.border.*.",
|
||||
"6:1: Disallowed import - java.awt.Button.ABORT."};
|
||||
final String[] expected = {
|
||||
"3:1: Disallowed import - java.awt.Image.",
|
||||
"4:1: Disallowed import - javax.swing.border.*.",
|
||||
"6:1: Disallowed import - java.awt.Button.ABORT.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("imports" + File.separator
|
||||
+ "InputImportControl.java"), expected);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// checkstyle: Checks Java source code for adherence to a set of rules.
|
||||
// Copyright (C) 2001-2010 Oliver Burn
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks.imports;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue