You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/06/19 19:05:35 UTC

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

Branch: refs/heads/master
Commit: 29f58943877379080fa009b7d073c5746d483239
Parents: a5b066c
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Jun 18 15:43:26 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Jun 18 15:43:26 2012 -0700

----------------------------------------------------------------------
 .../tapestry5/ioc/util/OneShotLockSpec.groovy      |   42 +++++++++
 .../ioc/internal/util/OneShotLockTest.java         |   66 ---------------
 2 files changed, 42 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/29f58943/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
new file mode 100644
index 0000000..5c45193
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
@@ -0,0 +1,42 @@
+package org.apache.tapestry5.ioc.util
+
+import org.apache.tapestry5.ioc.internal.util.OneShotLockSubject
+import spock.lang.Specification
+
+class OneShotLockSpec extends Specification {
+
+  def subject = new OneShotLockSubject()
+
+  def "may only invoke locked method once"() {
+    subject.go()
+    subject.done()
+
+
+    when:
+
+    subject.go()
+
+    then:
+
+    IllegalStateException e = thrown()
+
+    e.message.contains "${subject.class.name}.go("
+    e.message.contains "may no longer be invoked"
+  }
+
+  def "the method that locks is itself checked"() {
+
+    subject.go()
+    subject.done()
+
+    when:
+
+    subject.done()
+
+    then:
+
+    IllegalStateException e = thrown()
+
+    e.message.contains "${subject.class.name}.done("
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/29f58943/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/OneShotLockTest.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/OneShotLockTest.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/OneShotLockTest.java
deleted file mode 100644
index 3a2bad7..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/OneShotLockTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2006 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.util;
-
-import org.apache.tapestry5.ioc.test.IOCTestCase;
-import org.testng.annotations.Test;
-
-public class OneShotLockTest extends IOCTestCase
-{
-    private static final String CLASS_NAME = OneShotLockSubject.class.getName();
-
-    @Test
-    public void basic_locking()
-    {
-        OneShotLockSubject s = new OneShotLockSubject();
-
-        s.go();
-
-        s.done();
-
-        try
-        {
-            s.go();
-            unreachable();
-        }
-        catch (IllegalStateException ex)
-        {
-            assertTrue(ex.getMessage().contains(CLASS_NAME + ".go"));
-            assertTrue(ex.getMessage().contains("may no longer be invoked."));
-        }
-    }
-
-    @Test
-    public void locking_method_includes_check()
-    {
-        OneShotLockSubject s = new OneShotLockSubject();
-
-        s.go();
-
-        s.done();
-
-        try
-        {
-            s.done();
-            unreachable();
-        }
-        catch (IllegalStateException ex)
-        {
-            assertTrue(ex.getMessage().contains(CLASS_NAME + ".done"));
-            assertTrue(ex.getMessage().contains("may no longer be invoked."));
-        }
-    }
-
-}