package com.siyeh.ig.errorhandling;

import com.intellij.codeInspection.LocalInspectionTool;
import com.siyeh.ig.LightInspectionTestCase;

public class EmptyCatchBlockInspectionTest extends LightInspectionTestCase {

  @Override
  protected LocalInspectionTool getInspection() {
    final EmptyCatchBlockInspection tool = new EmptyCatchBlockInspection();
    tool.m_includeComments = true;
    tool.m_ignoreTestCases = true;
    tool.m_ignoreIgnoreParameter = true;
    return tool;
  }

  @Override
  protected String[] getEnvironmentClasses() {
    return new String[] {
      "package junit.framework; public abstract class TestCase {}"
    };
  }

  public void testSimple() {
    doTest("class C {\n" +
           "  void m() {\n" +
           "    try {\n" +
           "      throw new Exception();\n" +
           "    } /*Empty 'catch' block*/catch/**/ (Exception e) {\n" +
           "    }\n" +
           "  }\n" +
           "}\n");
  }

  public void testEmptyStatement() {
    doTest("class C {\n" +
           "  void m() {\n" +
           "    try {\n" +
           "      throw new Exception();\n" +
           "    } /*Empty 'catch' block*/catch/**/ (Exception e) {\n" +
           "      ;\n" +
           "    }\n" +
           "  }\n" +
           "}\n");
  }

  public void testComment() {
    doTest("class C {\n" +
           "  void m() {\n" +
           "    try {\n" +
           "      throw new Exception();\n" +
           "    } catch (Exception e) {\n" +
           "      // comment\n" +
           "    }\n" +
           "  }\n" +
           "}\n");
  }

  public void testIgnored() {
    doTest("class C {\n" +
           "  void m() {\n" +
           "    try {\n" +
           "      throw new Exception();\n" +
           "    } catch (Exception ignored) {\n" +
           "    }\n" +
           "  }\n" +
           "}\n");
  }

  public void testTest() {
    doTest("import junit.framework.TestCase;\n" +
           "class C extends TestCase {\n" +
           "  public void testM() {\n" +
           "    try {\n" +
           "      throw new Exception();\n" +
           "    } catch (Exception e) {}\n" +
           "  }\n" +
           "}\n");
  }
}

@@ -1864,333 +1864,7 @@
 %0A  %7D
-%0A%0A  public void testTest() %7B%0A    doTest(%22import junit.framework.TestCase;%5Cn%22 +%0A           %22class C extends TestCase %7B%5Cn%22 +%0A           %22  public void testM() %7B%5Cn%22 +%0A           %22    try %7B%5Cn%22 +%0A           %22      throw new Exception();%5Cn%22 +%0A           %22    %7D catch (Exception e) %7B%7D%5Cn%22 +%0A           %22  %7D%5Cn%22 +%0A           %22%7D%5Cn%22);%0A  %7D
 %0A%7D%0A

remove obsolete test