1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25
26
27
28
29
30
31
32
33 public class MavenITmng6065FailOnSeverityTest
34 extends AbstractMavenIntegrationTestCase
35 {
36
37 public MavenITmng6065FailOnSeverityTest()
38 {
39 super( "[4.0.0-alpha-1,)" );
40 }
41
42 public void testItShouldFailOnWarnLogMessages()
43 throws Exception
44 {
45 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6065-fail-on-severity" );
46
47 Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
48 verifier.setForkJvm( true );
49 verifier.addCliOption( "--fail-on-severity" );
50 verifier.addCliOption( "WARN" );
51
52 boolean failed = false;
53
54 try
55 {
56 verifier.executeGoal( "compile" );
57 }
58 catch ( VerificationException e )
59 {
60 failed = true;
61 verifier.verifyTextInLog( "Enabled to break the build on log level WARN." );
62 verifier.verifyTextInLog( "Build failed due to log statements with a higher severity than allowed." );
63 }
64
65 assertTrue( "Build should have failed", failed );
66 }
67
68 public void testItShouldSucceedOnWarnLogMessagesWhenFailLevelIsError()
69 throws Exception
70 {
71 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6065-fail-on-severity" );
72
73 Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
74 verifier.setForkJvm( true );
75 verifier.addCliOption( "--fail-on-severity" );
76 verifier.addCliOption( "ERROR" );
77
78 verifier.executeGoal( "compile" );
79
80 verifier.verifyTextInLog( "Enabled to break the build on log level ERROR." );
81 }
82 }