Add a test demostrating bug in indentation check

This commit is contained in:
Oliver Burn 2011-10-23 15:39:38 +11:00
parent 711c0feac6
commit be8b1ceab1
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.puppycrawl.tools.checkstyle.indentation;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
class InputValidTryResourcesIndent
{
// Taken from JDK7 java.lang.Package src code.
private static Manifest loadManifest(String fn) {
try (FileInputStream fis = new FileInputStream(fn);
JarInputStream jis = new JarInputStream(fis, false))
{
return jis.getManifest();
} catch (IOException e)
{
return null;
}
}
}

View File

@ -731,4 +731,16 @@ public class IndentationCheckTest extends BaseCheckTestSupport
final String[] expected = {};
verify(checkConfig, getPath("Input15Extensions.java"), expected);
}
@Test
public void testTryResources() throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(IndentationCheck.class);
final String[] expected = {
"something is expected, but there is a NullPointerException",
};
verify(checkConfig, getPath("indentation/InputValidTryResourcesIndent.java"),
expected);
}
}