Skip to content

Commit

Permalink
Issue checkstyle#4586: Moved resources for the JavadocPackage check test
Browse files Browse the repository at this point in the history
  • Loading branch information
djydewang committed Jul 8, 2017
1 parent 3a2a51d commit c6865c5
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 21 deletions.
Expand Up @@ -37,7 +37,8 @@ public class JavadocPackageCheckTest
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "javadoc" + File.separator + filename);
+ "javadoc" + File.separator
+ "javadocpackage" + File.separator + filename);
}

@Override
Expand All @@ -56,8 +57,8 @@ public void testMissing() throws Exception {
};
verify(
createChecker(checkConfig),
getPath("InputBadCls.java"),
getPath("InputBadCls.java"),
getPath("InputJavadocPackageBadCls.java"),
getPath("InputJavadocPackageBadCls.java"),
expected);
}

Expand All @@ -70,16 +71,16 @@ public void testMissingWithAllowLegacy() throws Exception {
};
verify(
createChecker(checkConfig),
getPath("InputBadCls.java"),
getPath("InputBadCls.java"),
getPath("InputJavadocPackageBadCls.java"),
getPath("InputJavadocPackageBadCls.java"),
expected);
}

@Test
public void testWithMultipleFiles() throws Exception {
final Configuration checkConfig = createCheckConfig(JavadocPackageCheck.class);
final String path1 = getPath("InputNoJavadoc.java");
final String path2 = getPath("InputBadTag.java");
final String path1 = getPath("InputJavadocPackageNoJavadoc.java");
final String path2 = getPath("InputJavadocPackageBadTag.java");
final String[] expected = {
"0: " + getCheckMessage(MSG_PACKAGE_INFO),
};
Expand All @@ -97,8 +98,9 @@ public void testBoth() throws Exception {
"0: " + getCheckMessage(MSG_LEGACY_PACKAGE_HTML),
};
verify(createChecker(checkConfig),
getPath("bothfiles" + File.separator + "InputIgnored.java"),
getPath("bothfiles" + File.separator + "InputIgnored.java"), expected);
getPath("bothfiles" + File.separator + "InputJavadocPackageBothIgnored.java"),
getPath("bothfiles"
+ File.separator + "InputJavadocPackageBothIgnored.java"), expected);
}

@Test
Expand All @@ -108,8 +110,8 @@ public void testHtmlDisallowed() throws Exception {
"0: " + getCheckMessage(MSG_PACKAGE_INFO),
};
verify(createChecker(checkConfig),
getPath("pkghtml" + File.separator + "InputIgnored.java"),
getPath("pkghtml" + File.separator + "InputIgnored.java"), expected);
getPath("pkghtml" + File.separator + "InputJavadocPackageHtmlIgnored.java"),
getPath("pkghtml" + File.separator + "InputJavadocPackageHtmlIgnored.java"), expected);
}

@Test
Expand All @@ -118,7 +120,7 @@ public void testHtmlAllowed() throws Exception {
checkConfig.addAttribute("allowLegacy", "true");
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(createChecker(checkConfig),
getPath("pkghtml" + File.separator + "InputIgnored.java"),
getPath("pkghtml" + File.separator + "InputJavadocPackageHtmlIgnored.java"),
getPath("pkghtml" + File.separator + "package-info.java"), expected);
}

Expand All @@ -127,9 +129,9 @@ public void testAnnotation() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(JavadocPackageCheck.class);
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(createChecker(checkConfig),
getPath("pkginfo" + File.separator + "annotation"
getPath("annotation"
+ File.separator + "package-info.java"),
getPath("pkginfo" + File.separator + "annotation"
getPath("annotation"
+ File.separator + "package-info.java"), expected);
}
}

This file was deleted.

@@ -0,0 +1,6 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocpackage;

class InputJavadocPackageBadCls {
class X extends Exception {}
void m() throws X {}
}
@@ -0,0 +1,9 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocpackage;

/**
* The following is a bad tag.
* @mytag Hello
*/
public class InputJavadocPackageBadTag
{
}
@@ -0,0 +1,120 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackage;

public class InputJavadocPackageNoJavadoc //comment test
{
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}

protected class ProtectedInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

class PackageInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

private class PrivateInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}
}

class PackageClass {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}

public class PublicInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

protected class ProtectedInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

class PackageInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

private class PrivateInner {
public int i1;
protected int i2;
int i3;
private int i4;

public void foo1() {}
protected void foo2() {}
void foo3() {}
private void foo4() {}
}

class IgnoredName {
// ignore by name
private int logger;
// no warning, 'serialVersionUID' fields do not require Javadoc
private static final long serialVersionUID = 0;
}

/**/
void methodWithTwoStarComment() {}
}
@@ -0,0 +1,12 @@
/**
* This is a valid package documentation. <--- See the period after the
* first sentence.
*
* <p>
* hurray for javadocs in html
* <br>
* with a legacy non-closed br element
* </p>
*/
@Deprecated
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocpackage.annotation;
@@ -0,0 +1,5 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.javapackage.bothfiles;

class InputJavadocPackageBothIgnored
{
}
@@ -0,0 +1 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.bothfiles;
@@ -1,5 +1,5 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.pkghtml;

class InputIgnored
class InputJavadocPackageHtmlIgnored
{
}
@@ -0,0 +1 @@
Ignored

0 comments on commit c6865c5

Please sign in to comment.