You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/16 20:50:31 UTC

[13/44] git commit: Convert TestNG to Spock

Convert TestNG to Spock


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/63ad333c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/63ad333c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/63ad333c

Branch: refs/heads/master
Commit: 63ad333cb131ae087d0b1c616d0f1124936baf6a
Parents: 6ba605f
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Mon May 14 11:42:32 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:50:14 2012 -0700

----------------------------------------------------------------------
 .../ioc/internal/GlobPatternMatcherSpec.groovy     |   63 +++++++++++
 .../ioc/internal/GlobPatternMatcherTest.java       |   85 ---------------
 2 files changed, 63 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63ad333c/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/GlobPatternMatcherSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/GlobPatternMatcherSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/GlobPatternMatcherSpec.groovy
new file mode 100644
index 0000000..d2d368a
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/GlobPatternMatcherSpec.groovy
@@ -0,0 +1,63 @@
+package org.apache.tapestry5.ioc.internal
+
+import spock.lang.Specification
+import spock.lang.Unroll
+
+
+@Unroll
+class GlobPatternMatcherSpec extends Specification {
+
+  def "input '#input' matches pattern '#pattern'"() {
+
+    def matcher = new GlobPatternMatcher(pattern)
+
+    expect:
+
+    matcher.matches(input)
+
+    where:
+
+    input         | pattern
+    "fred"        | "fred"
+    "fred"        | "FRED"
+    "fred"        | "*"
+    ""            | "*"
+    "fred.Barney" | "*Barney"
+    "fred.Barney" | "*BARNEY"
+    "fred.Barney" | "fred*"
+    "fred.Barney" | "FRED*"
+    "fredBarney"  | "*dB*"
+    "fredBarney"  | "*DB*"
+    "fred.Barney" | "*Barney*"
+    "fred.Barney" | "*fred*"
+    "fred.Barney" | "*FRED*"
+    "MyEntityDAO" | ".*dao"
+    "FredDAO"     | "(fred|barney)dao"
+  }
+
+  def "input '#input' does not match pattern '#pattern'"() {
+
+    def matcher = new GlobPatternMatcher(pattern)
+
+    expect:
+
+    ! matcher.matches(input)
+
+    where:
+
+    input          | pattern
+    "xfred"        | "fred"
+    "fredx"        | "fred"
+    "fred"         | "xfred"
+    "fred"         | "fredx"
+    "fred.Barneyx" | "*Barney"
+    "fred.Barney"  | "*Barneyx"
+    "fred.Barney"  | "*xBarney"
+    "xfred.Barney" | "fred*"
+    "fred.Barney"  | "fredx*"
+    "fred.Barney"  | "xfred*"
+    "fred.Barney"  | "*flint*"
+    "MyEntityDAL"  | ".*dao"
+    "WilmaDAO"     | "(fred|barney)dao"
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63ad333c/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/GlobPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/GlobPatternMatcherTest.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/GlobPatternMatcherTest.java
deleted file mode 100644
index ab95d6b..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/GlobPatternMatcherTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2006, 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.ioc.internal;
-
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-public class GlobPatternMatcherTest extends Assert
-{
-    private boolean globMatch(String input, String pattern)
-    {
-        return new GlobPatternMatcher(pattern).matches(input);
-    }
-
-    @DataProvider
-    public Object[][] matches()
-    {
-        return new Object[][]
-                {
-                        { "fred", "fred" },
-                        { "fred", "FRED" },
-                        { "fred", "*" },
-                        { "", "*" },
-                        { "fred.Barney", "*Barney" },
-                        { "fred.Barney", "*BARNEY" },
-                        { "fred.Barney", "fred*" },
-                        { "fred.Barney", "FRED*" },
-                        { "fredBarney", "*dB*" },
-                        { "fredBarney", "*DB*" },
-                        { "fred.Barney", "*Barney*" },
-                        { "fred.Barney", "*fred*" },
-                        { "fred.Barney", "*FRED*" },
-                        { "MyEntityDAO", ".*dao" },
-                        { "FredDAO", "(fred|barney)dao" }
-                };
-    }
-
-    @Test(dataProvider = "matches")
-    public void successful_glob_match(String input, String pattern)
-    {
-        assertTrue(globMatch(input, pattern));
-    }
-
-
-    @DataProvider
-    public Object[][] mismatches()
-    {
-        return new Object[][]
-                {
-                        { "xfred", "fred" },
-                        { "fredx", "fred" },
-                        { "fred", "xfred" },
-                        { "fred", "fredx" },
-                        { "fred.Barneyx", "*Barney" },
-                        { "fred.Barney", "*Barneyx" },
-                        { "fred.Barney", "*xBarney" },
-                        { "xfred.Barney", "fred*" },
-                        { "fred.Barney", "fredx*" },
-                        { "fred.Barney", "xfred*" },
-                        { "fred.Barney", "*flint*" },
-                        { "MyEntityDAL", ".*dao" },
-                        { "WilmaDAO", "(fred|barney)dao" }
-                };
-    }
-
-
-    @Test(dataProvider = "mismatches")
-    public void unsuccessful_glob_match(String input, String pattern)
-    {
-        assertFalse(globMatch(input, pattern));
-    }
-}