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/121a9b6d
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/121a9b6d
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/121a9b6d

Branch: refs/heads/master
Commit: 121a9b6dfe46c4dc34c52414441016baf0de6eb5
Parents: ae5d153
Author: Howard M. Lewis Ship <[email protected]>
Authored: Sat Jun 2 14:50:07 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Sat Jun 2 14:50:07 2012 -0700

----------------------------------------------------------------------
 .../ioc/util/LocalizedNameGeneratorTest.java       |   77 ---------------
 .../ioc/util/LocalizedNamesGeneratorSpec.groovy    |   39 ++++++++
 2 files changed, 39 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/121a9b6d/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNameGeneratorTest.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNameGeneratorTest.java
 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNameGeneratorTest.java
deleted file mode 100644
index fd8e2bc..0000000
--- 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNameGeneratorTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2006, 2008, 2011 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.util;
-
-import org.apache.tapestry5.ioc.test.IOCTestCase;
-import org.apache.tapestry5.ioc.util.LocalizedNameGenerator;
-import org.testng.annotations.Test;
-
-import java.util.Locale;
-
-public class LocalizedNameGeneratorTest extends IOCTestCase
-{
-
-    private void run(String path, Locale locale, String... expected)
-    {
-        LocalizedNameGenerator g = new LocalizedNameGenerator(path, locale);
-
-        for (String s : expected)
-        {
-            assertTrue(g.hasNext());
-            assertEquals(g.next(), s);
-        }
-
-        assertFalse(g.hasNext());
-    }
-
-    @Test
-    public void locale_with_language_and_country()
-    {
-        run("basic.test", Locale.US, "basic_en_US.test", "basic_en.test", 
"basic.test");
-    }
-
-    @Test
-    public void locale_with_just_language()
-    {
-        run("noCountry.zap", Locale.FRENCH, "noCountry_fr.zap", 
"noCountry.zap");
-    }
-
-    @Test
-    public void locale_with_variant_but_no_country()
-    {
-
-        // The double-underscore is correct, it's a kind
-        // of placeholder for the null country.
-        // JDK1.3 always converts the locale to upper case. JDK 1.4
-        // does not. To keep this test happyt, we selected an all-uppercase
-        // locale.
-
-        run("fred.foo", new Locale("en", "", "GEEK"), "fred_en__GEEK.foo", 
"fred_en.foo", "fred.foo");
-    }
-
-    @Test
-    public void locale_with_just_language_no_period()
-    {
-        run("context:/blah", Locale.FRENCH, "context:/blah_fr", 
"context:/blah");
-    }
-
-    @Test
-    public void locale_with_variant_but_no_country_no_period()
-    {
-        run("context:/blah", new Locale("fr", "", "GEEK"), 
"context:/blah_fr__GEEK", "context:/blah_fr",
-            "context:/blah");
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/121a9b6d/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
new file mode 100644
index 0000000..95a6cb0
--- /dev/null
+++ 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
@@ -0,0 +1,39 @@
+package org.apache.tapestry5.ioc.util
+
+import spock.lang.Specification
+import spock.lang.Unroll
+
+
+class LocalizedNamesGeneratorSpec extends Specification {
+
+  @Unroll
+  def "Localized names for #path and #locale are '#expected'"() {
+
+    when:
+
+    LocalizedNameGenerator g = new LocalizedNameGenerator(path, locale)
+
+    then:
+
+    expected.tokenize().each {
+      assert g.hasNext()
+      assert g.next() == it
+    }
+
+    !g.hasNext()
+
+    where:
+
+    path            | locale                       | expected
+
+    "basic.test"    | Locale.US                    | "basic_en_US.test 
basic_en.test basic.test"
+    "noCountry.zap" | Locale.FRENCH                | "noCountry_fr.zap 
noCountry.zap"
+    "fred.foo"      | new Locale("en", "", "GEEK") | "fred_en__GEEK.foo 
fred_en.foo fred.foo"
+    "context:/blah" | Locale.FRENCH                | "context:/blah_fr 
context:/blah"
+    "context:/blah" | new Locale("fr", "", "GEEK") | "context:/blah_fr__GEEK 
context:/blah_fr context:/blah"
+
+    // The double-underscore is correct, it's a kind of placeholder for the 
null country. JDK1.3 always converts the locale to upper case. JDK 1.4
+    // does not. To keep this test happyt, we selected an all-uppercase locale.
+
+  }
+}

Reply via email to