package de.is24.deadcode4j.analyzer;

import mockit.Mock;
import mockit.MockUp;
import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.fail;

public final class A_SpringNamespaceHandlerAnalyzer extends AnAnalyzer<SpringNamespaceHandlerAnalyzer> {

    private static final String SPRING_HANDLER_FILE = "META-INF/spring.handlers";

    @Override
    protected SpringNamespaceHandlerAnalyzer createAnalyzer() {
        return new SpringNamespaceHandlerAnalyzer();
    }

    @Test
    public void shouldRecognizeDefinedNamespaceHandlers() {
        analyzeFile(SPRING_HANDLER_FILE);

        assertThatDependenciesAreReported("CustomNamespaceHandler", "AnotherNamespaceHandler");
    }

    @Test
    public void handlesException() throws Exception {
        new MockUp<FileInputStream>() {
            @Mock
            public void $init(File file) throws IOException {
                throw new IOException("JUnit");
            }
        };

        try {
            analyzeFile(SPRING_HANDLER_FILE);
            fail("Should abort analysis!");
        } catch (RuntimeException e) {
            assertThat(e.getMessage(), containsString(SPRING_HANDLER_FILE));
        }
    }

}

@@ -84,22 +84,97 @@
 ort 
-org.junit.Test
+mockit.integration.junit4.JMockit;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith
 ;%0A%0Ai
@@ -397,16 +397,40 @@
 .fail;%0A%0A
+@RunWith(JMockit.class)%0A
 public f

fix side-effects of JMockit