11package de .andrena .tools .nopackagecycles ;
22
3- import de .andrena .tools .nopackagecycles .mock .EnforcerRuleHelperMock ;
4- import org .apache .commons .io .IOUtils ;
5- import org .apache .maven .enforcer .rule .api .EnforcerRuleException ;
6- import org .junit .Before ;
7- import org .junit .Test ;
3+ import static org .junit .Assert .assertEquals ;
4+ import static org .junit .Assert .fail ;
85
96import java .io .File ;
107import java .io .IOException ;
118import java .net .URISyntaxException ;
129import java .net .URL ;
1310
14- import static org .junit .Assert .*;
11+ import org .apache .commons .io .IOUtils ;
12+ import org .apache .maven .enforcer .rule .api .EnforcerRuleException ;
13+ import org .junit .Before ;
14+ import org .junit .Test ;
1515
16+ import de .andrena .tools .nopackagecycles .mock .EnforcerRuleHelperMock ;
1617
1718public class NoPackageCyclesRuleIntegrationTest {
18-
1919 private static final URL FITNESSE_TARGET_FOLDER = getResource ("fitnesse-target" );
2020 private static final URL FITNESSE_EXPECTED_OUTPUT = getResource ("fitnesse-expected-output.txt" );
2121 private static final URL JUNIT_TARGET_FOLDER = getResource ("junit-target" );
@@ -24,45 +24,38 @@ public class NoPackageCyclesRuleIntegrationTest {
2424 private NoPackageCyclesRule rule ;
2525 private EnforcerRuleHelperMock helper ;
2626
27-
2827 @ Before
2928 public void setUp () throws Exception {
3029 rule = new NoPackageCyclesRule ();
3130 helper = new EnforcerRuleHelperMock ();
3231 }
3332
34-
3533 @ Test
3634 public void fitnesseIntegrationTest () throws Exception {
3735 assertPackageCycles (FITNESSE_TARGET_FOLDER , FITNESSE_EXPECTED_OUTPUT );
3836 }
3937
40-
4138 @ Test
4239 public void junitIntegrationTest () throws Exception {
4340 assertPackageCycles (JUNIT_TARGET_FOLDER , JUNIT_EXPECTED_OUTPUT );
4441 }
4542
46-
4743 private void assertPackageCycles (URL targetFolder , URL expectedOutput ) throws URISyntaxException , IOException {
4844 helper .setTestClassesDir (new File ("non-existent" ));
4945 helper .setClassesDir (new File (targetFolder .toURI ()));
5046 try {
5147 rule .execute (helper );
5248 fail ("expected EnforcerRuleException" );
53- }
54- catch (EnforcerRuleException e ) {
49+ } catch (EnforcerRuleException e ) {
5550 // using assertEquals to get a nice comparison editor in eclipse
56- assertEquals (getExpectedOutput (expectedOutput ), e .getMessage () + " \n " );
51+ assertEquals (getExpectedOutput (expectedOutput ), e .getMessage ());
5752 }
5853 }
5954
60-
6155 private String getExpectedOutput (URL expectedOutput ) throws IOException {
6256 return IOUtils .toString (expectedOutput .openStream ()).replaceAll ("\r " , "" );
6357 }
6458
65-
6659 private static URL getResource (String path ) {
6760 return Thread .currentThread ().getContextClassLoader ().getResource (path );
6861 }
0 commit comments