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

Branch: refs/heads/master
Commit: f491e98a40ed4582a76c66462c9a693279c4f15c
Parents: 8912f06
Author: Howard M. Lewis Ship <[email protected]>
Authored: Mon Jun 11 15:45:05 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Mon Jun 11 15:45:05 2012 -0700

----------------------------------------------------------------------
 ...alidatingOrderedConfigurationWrapperSpec.groovy |   80 +++++++++++
 .../ValidatingOrderedConfigurationWrapperTest.java |  106 ---------------
 2 files changed, 80 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f491e98a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperSpec.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperSpec.groovy
 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperSpec.groovy
new file mode 100644
index 0000000..0e7fc43
--- /dev/null
+++ 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperSpec.groovy
@@ -0,0 +1,80 @@
+package org.apache.tapestry5.ioc.internal
+
+import org.apache.tapestry5.ioc.ObjectLocator
+import org.apache.tapestry5.ioc.OrderedConfiguration
+import org.apache.tapestry5.ioc.internal.util.Orderer
+import org.slf4j.Logger
+import spock.lang.Specification
+
+class ValidatingOrderedConfigurationWrapperSpec extends Specification {
+
+  def "contribution of a coerceable instance"() {
+    Runnable contribution = Mock()
+    Runnable coerced = Mock()
+    Runnable pre = Mock()
+    Runnable post = Mock()
+    Logger logger = Mock()
+    TypeCoercerProxy tc = Mock()
+
+    def orderer = new Orderer(logger)
+
+    orderer.add "pre", pre
+    orderer.add "post", post
+
+    OrderedConfiguration config = new 
ValidatingOrderedConfigurationWrapper(Runnable, null, tc, orderer, null, null)
+
+    when:
+
+    config.add("id", contribution, "after:pre", "before:post")
+
+    then:
+
+    1 * tc.coerce(contribution, Runnable) >> coerced
+
+    orderer.ordered == [pre, coerced, post]
+  }
+
+  def "contribution of a valid type"() {
+    Map instance = new HashMap()
+    Map pre = Mock()
+    Map post = Mock()
+    ObjectLocator locator = Mock()
+    TypeCoercerProxy tc = Mock()
+    Logger logger = Mock()
+
+    def orderer = new Orderer(logger)
+
+    orderer.add "pre", pre
+    orderer.add "post", post
+
+    OrderedConfiguration config = new 
ValidatingOrderedConfigurationWrapper(Map, locator, tc, orderer, null, null)
+
+    when:
+
+    config.addInstance("id", HashMap, "after:pre", "before:post")
+
+    then:
+
+    1 * locator.autobuild(HashMap) >> instance
+    1 * tc.coerce(instance, Map) >> instance
+
+    orderer.ordered == [pre, instance, post]
+  }
+
+  def "null objected passed through"() {
+    Logger logger = Mock()
+
+    Orderer orderer = new Orderer(logger)
+    OrderedConfiguration config = new 
ValidatingOrderedConfigurationWrapper(Runnable, null, null, orderer, null, null)
+
+    when:
+
+    config.add("id", null)
+
+    then:
+
+    orderer.ordered.empty
+
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f491e98a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
deleted file mode 100644
index bb021c9..0000000
--- 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2006, 2007, 2008, 2009, 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.internal;
-
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.internal.util.Orderer;
-import org.slf4j.Logger;
-import org.testng.annotations.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@SuppressWarnings(
-{ "rawtypes", "unchecked" })
-public class ValidatingOrderedConfigurationWrapperTest extends 
IOCInternalTestCase
-{
-    @Test
-    public void valid_type_long_form()
-    {
-        Runnable contribution = mockRunnable();
-        Runnable coerced = mockRunnable();
-        Runnable pre = mockRunnable();
-        Runnable post = mockRunnable();
-        Logger logger = mockLogger();
-        Orderer<Runnable> orderer = new Orderer<Runnable>(logger);
-        TypeCoercerProxy tc = mockTypeCoercerProxy();
-
-        expect(tc.coerce(contribution, Runnable.class)).andReturn(coerced);
-
-        orderer.add("pre", pre);
-        orderer.add("post", post);
-
-        replay();
-
-        OrderedConfiguration<Runnable> wrapper = new 
ValidatingOrderedConfigurationWrapper<Runnable>(Runnable.class,
-                null, tc, orderer, null, null);
-
-        wrapper.add("id", contribution, "after:pre", "before:post");
-
-        verify();
-
-        assertListsEquals(orderer.getOrdered(), pre, coerced, post);
-    }
-
-    @Test
-    public void contribute_valid_class()
-    {
-        Logger logger = mockLogger();
-        Orderer<Map> orderer = new Orderer<Map>(logger);
-        Map pre = new HashMap();
-        Map post = new HashMap();
-        HashMap contribution = new HashMap();
-        ObjectLocator locator = mockObjectLocator();
-        TypeCoercerProxy tc = mockTypeCoercerProxy();
-
-        train_autobuild(locator, HashMap.class, contribution);
-
-        expect(tc.coerce(contribution, Map.class)).andReturn(contribution);
-
-        orderer.add("pre", pre);
-        orderer.add("post", post);
-
-        replay();
-
-        OrderedConfiguration<Map> wrapper = new 
ValidatingOrderedConfigurationWrapper<Map>(Map.class, locator, tc,
-                orderer, null, null);
-
-        wrapper.addInstance("id", HashMap.class, "after:pre", "before:post");
-
-        verify();
-
-        assertListsEquals(orderer.getOrdered(), pre, contribution, post);
-    }
-
-    @Test
-    public void null_object_passed_through()
-    {
-        Logger logger = mockLogger();
-        Orderer<Runnable> orderer = new Orderer<Runnable>(logger);
-
-        replay();
-
-        OrderedConfiguration<Runnable> wrapper = new 
ValidatingOrderedConfigurationWrapper<Runnable>(Runnable.class,
-                null, null, orderer, null, null);
-
-        wrapper.add("id", null);
-
-        verify();
-
-        assertTrue(orderer.getOrdered().isEmpty());
-    }
-
-}

Reply via email to