[maven-enforcer] branch IMPROVE_TESTS created (now 9d53b59)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-enforcer] branch IMPROVE_TESTS created (now 9d53b59)

khmarbaise
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a change to branch IMPROVE_TESTS
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git.


      at 9d53b59  Improved tests.

This branch includes the following new commits:

     new 9d53b59  Improved tests.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven-enforcer] 01/01: Improved tests.

khmarbaise
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch IMPROVE_TESTS
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit 9d53b592d21e59f003af75ee07e3fa5bf9ed509d
Author: Karl Heinz Marbaise <[hidden email]>
AuthorDate: Sat Oct 6 18:47:19 2018 +0200

    Improved tests.
---
 .../enforcer/TestRequireEnvironmentVariable.java   | 46 ++++++++++++++++++++--
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java
index 27ba381..71a069f 100755
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/TestRequireEnvironmentVariable.java
@@ -19,10 +19,11 @@ package org.apache.maven.plugins.enforcer;
  * under the License.
  */
 
-import junit.framework.TestCase;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
 
+import junit.framework.TestCase;
+
 /**
  * Unit test for {@link RequireEnvironmentVariable}}
  *
@@ -75,7 +76,7 @@ public class TestRequireEnvironmentVariable
      *
      * @throws EnforcerRuleException the enforcer rule exception
      */
-    public void testRuleWithRegex()
+    public void testRuleWithRegexNot()
         throws EnforcerRuleException
     {
         EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
@@ -96,6 +97,21 @@ public class TestRequireEnvironmentVariable
             // expected to catch this.
         }
 
+    }
+
+    /**
+     * Test rule with regex.
+     *
+     * @throws EnforcerRuleException the enforcer rule exception
+     */
+    public void testRuleWithRegex()
+        throws EnforcerRuleException
+    {
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+
+        RequireEnvironmentVariable rule = new RequireEnvironmentVariable();
+        rule.setVariableName( "PATH" );
+
         // can't really predict what a PATH will looks like, just enforce it ain't empty
         rule.setRegex( ".{1,}" );
         try
@@ -104,8 +120,32 @@ public class TestRequireEnvironmentVariable
         }
         catch ( EnforcerRuleException e )
         {
-            fail( "This should not throw an exception" );
+            fail( "This should not throw an exception " + e.getMessage() );
         }
     }
 
+    /**
+     * Test rule with regex.
+     *
+     * @throws EnforcerRuleException the enforcer rule exception
+     */
+    public void testRuleWithRegexDifferent()
+        throws EnforcerRuleException
+    {
+        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
+
+        RequireEnvironmentVariable rule = new RequireEnvironmentVariable();
+        rule.setVariableName( "PATH" );
+
+        // can't really predict what a PATH will looks like, just enforce it ain't empty
+        rule.setRegex( ".+" );
+        try
+        {
+            rule.execute( helper );
+        }
+        catch ( EnforcerRuleException e )
+        {
+            fail( "This should not throw an exception " + e.getMessage() );
+        }
+    }
 }