11package de .andrena .tools .nopackagecycles ;
22
3- import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .fail ;
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 ;
58
69import java .io .File ;
710import java .io .IOException ;
811import java .net .URISyntaxException ;
912import java .net .URL ;
1013
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 ;
14+ import static org .junit .Assert .*;
1515
16- import de .andrena .tools .nopackagecycles .mock .EnforcerRuleHelperMock ;
1716
1817public 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,38 +24,45 @@ public class NoPackageCyclesRuleIntegrationTest {
2424 private NoPackageCyclesRule rule ;
2525 private EnforcerRuleHelperMock helper ;
2626
27+
2728 @ Before
2829 public void setUp () throws Exception {
2930 rule = new NoPackageCyclesRule ();
3031 helper = new EnforcerRuleHelperMock ();
3132 }
3233
34+
3335 @ Test
3436 public void fitnesseIntegrationTest () throws Exception {
3537 assertPackageCycles (FITNESSE_TARGET_FOLDER , FITNESSE_EXPECTED_OUTPUT );
3638 }
3739
40+
3841 @ Test
3942 public void junitIntegrationTest () throws Exception {
4043 assertPackageCycles (JUNIT_TARGET_FOLDER , JUNIT_EXPECTED_OUTPUT );
4144 }
4245
46+
4347 private void assertPackageCycles (URL targetFolder , URL expectedOutput ) throws URISyntaxException , IOException {
4448 helper .setTestClassesDir (new File ("non-existent" ));
4549 helper .setClassesDir (new File (targetFolder .toURI ()));
4650 try {
4751 rule .execute (helper );
4852 fail ("expected EnforcerRuleException" );
49- } catch (EnforcerRuleException e ) {
53+ }
54+ catch (EnforcerRuleException e ) {
5055 // using assertEquals to get a nice comparison editor in eclipse
51- assertEquals (getExpectedOutput (expectedOutput ), e .getMessage ());
56+ assertEquals (getExpectedOutput (expectedOutput ), e .getMessage () + " \n " );
5257 }
5358 }
5459
60+
5561 private String getExpectedOutput (URL expectedOutput ) throws IOException {
5662 return IOUtils .toString (expectedOutput .openStream ()).replaceAll ("\r " , "" );
5763 }
5864
65+
5966 private static URL getResource (String path ) {
6067 return Thread .currentThread ().getContextClassLoader ().getResource (path );
6168 }
0 commit comments